|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: /* ! 25: * audio_snd_reply.c ! 26: * ! 27: * Copyright (c) 1991, NeXT Computer, Inc. All rights reserved. ! 28: * ! 29: * Snd reply message routines. ! 30: * ! 31: * HISTORY ! 32: * 08/07/92/mtm Original coding from m68k snd_reply.c. ! 33: */ ! 34: ! 35: #import "snd_reply.h" ! 36: #import <bsd/dev/snd_msgs.h> ! 37: ! 38: /* ! 39: * Interface routines for composing messages to send in response to ! 40: * sound facility services. ! 41: */ ! 42: ! 43: static msg_type_long_t snd_type_ool_template = { ! 44: { ! 45: 0, /* msg_type_name */ ! 46: 0, /* msg_type_size */ ! 47: 0, /* msg_type_number */ ! 48: FALSE, /* msg_type_inline */ ! 49: TRUE, /* msg_type_longform */ ! 50: TRUE /* msg_type_deallocate */ ! 51: }, ! 52: MSG_TYPE_INTEGER_8, /* msg_type_long_name */ ! 53: 8, /* msg_type_long_size */ ! 54: 0, /* msg_type_long_number */ ! 55: }; ! 56: ! 57: static msg_type_t snd_type_int_template = { ! 58: MSG_TYPE_INTEGER_32, /* msg_type_name */ ! 59: 32, /* msg_type_size */ ! 60: 1, /* msg_type_number */ ! 61: TRUE, /* msg_type_inline */ ! 62: FALSE, /* msg_type_longform */ ! 63: FALSE /* msg_type_deallocate */ ! 64: }; ! 65: ! 66: /* ! 67: * Generic replies ! 68: */ ! 69: /* ! 70: * Message to return the device port. ! 71: */ ! 72: void audio_snd_reply_ret_device(msg_header_t *msg, ! 73: port_name_t remote_port, ! 74: port_name_t device_port) ! 75: { ! 76: msg->msg_id = SND_MSG_RET_DEVICE; ! 77: msg->msg_local_port = device_port; ! 78: msg->msg_remote_port = remote_port; ! 79: } ! 80: ! 81: /* ! 82: * Message to return a stream port. ! 83: */ ! 84: void audio_snd_reply_ret_stream(msg_header_t *msg, ! 85: port_name_t remote_port, ! 86: port_name_t stream_port) ! 87: { ! 88: msg->msg_id = SND_MSG_RET_STREAM; ! 89: msg->msg_local_port = stream_port; ! 90: msg->msg_remote_port = remote_port; ! 91: } ! 92: ! 93: static void snd_reply_with_tag(msg_header_t *msg, port_name_t port, ! 94: int tag, int msg_id) ! 95: { ! 96: snd_taged_reply_t *smsg = (snd_taged_reply_t *)msg; ! 97: ! 98: msg->msg_id = msg_id; ! 99: msg->msg_size = sizeof(snd_taged_reply_t); ! 100: msg->msg_remote_port = port; ! 101: smsg->data_tagType = snd_type_int_template; ! 102: smsg->data_tag = tag; ! 103: } ! 104: ! 105: /* ! 106: * Message return on illegal message. ! 107: */ ! 108: void audio_snd_reply_illegal_msg(msg_header_t *msg, ! 109: port_name_t local_port, ! 110: port_name_t remote_port, ! 111: int msg_id, ! 112: int error) ! 113: { ! 114: snd_illegal_msg_t *smsg = (snd_illegal_msg_t *)msg; ! 115: ! 116: msg->msg_id = SND_MSG_ILLEGAL_MSG; ! 117: msg->msg_size = sizeof(snd_illegal_msg_t); ! 118: msg->msg_local_port = local_port; ! 119: msg->msg_remote_port = remote_port; ! 120: ! 121: smsg->dataType = snd_type_int_template; ! 122: smsg->dataType.msg_type_number = 2; ! 123: smsg->ill_msgid = msg_id; ! 124: smsg->ill_error = error; ! 125: } ! 126: ! 127: /* ! 128: * Replies specific to streaming soundout/soundin ! 129: */ ! 130: /* ! 131: * Message returning recorded data. ! 132: */ ! 133: void audio_snd_reply_recorded_data(msg_header_t *msg, ! 134: port_name_t remote_port, ! 135: int data_tag, ! 136: pointer_t data, ! 137: int nbytes) ! 138: { ! 139: snd_recorded_data_t *smsg = (snd_recorded_data_t *)msg; ! 140: ! 141: msg->msg_simple = FALSE; ! 142: msg->msg_size = sizeof(snd_recorded_data_t); ! 143: msg->msg_type = MSG_TYPE_NORMAL; ! 144: msg->msg_remote_port = remote_port; ! 145: msg->msg_local_port = PORT_NULL; ! 146: msg->msg_id = SND_MSG_RECORDED_DATA; ! 147: ! 148: smsg->data_tagType = snd_type_int_template; ! 149: smsg->data_tag = data_tag; ! 150: smsg->dataType = snd_type_ool_template; ! 151: smsg->dataType.msg_type_long_number = nbytes; ! 152: smsg->recorded_data = data; ! 153: } ! 154: ! 155: /* ! 156: * Message to return a timeout indication. ! 157: */ ! 158: void audio_snd_reply_timed_out(msg_header_t *msg, ! 159: port_name_t remote_port, ! 160: int data_tag) ! 161: { ! 162: return snd_reply_with_tag(msg, remote_port, data_tag, ! 163: SND_MSG_TIMED_OUT); ! 164: } ! 165: ! 166: /* ! 167: * Message to return an integer count of number samples played/recorded. ! 168: */ ! 169: void audio_snd_reply_ret_samples(msg_header_t *msg, ! 170: port_name_t remote_port, ! 171: int nsamples, int timeStamp) ! 172: { ! 173: snd_ret_samples_t *smsg = (snd_ret_samples_t *)msg; ! 174: ! 175: msg->msg_size = sizeof(snd_ret_samples_t); ! 176: msg->msg_id = SND_MSG_RET_SAMPLES; ! 177: msg->msg_remote_port = remote_port; ! 178: ! 179: smsg->dataType = snd_type_int_template; ! 180: smsg->nsamples = nsamples; ! 181: smsg->timeStamp = timeStamp; ! 182: } ! 183: ! 184: /* ! 185: * Message to return an overflow indication. ! 186: */ ! 187: void audio_snd_reply_overflow(msg_header_t *msg, ! 188: port_name_t remote_port, ! 189: int data_tag) ! 190: { ! 191: return snd_reply_with_tag(msg, remote_port, data_tag, ! 192: SND_MSG_OVERFLOW); ! 193: } ! 194: ! 195: /* ! 196: * Message to return a region started indication. ! 197: */ ! 198: void audio_snd_reply_started(msg_header_t *msg, ! 199: port_name_t remote_port, ! 200: int data_tag) ! 201: { ! 202: return snd_reply_with_tag(msg, remote_port, data_tag, ! 203: SND_MSG_STARTED); ! 204: } ! 205: ! 206: /* ! 207: * Message to return region completed indication. ! 208: */ ! 209: void audio_snd_reply_completed(msg_header_t *msg, ! 210: port_name_t remote_port, ! 211: int data_tag) ! 212: { ! 213: return snd_reply_with_tag(msg, remote_port, data_tag, ! 214: SND_MSG_COMPLETED); ! 215: } ! 216: ! 217: /* ! 218: * Message to return region aborted indication. ! 219: */ ! 220: void audio_snd_reply_aborted(msg_header_t *msg, ! 221: port_name_t remote_port, ! 222: int data_tag) ! 223: { ! 224: return snd_reply_with_tag(msg, remote_port, data_tag, ! 225: SND_MSG_ABORTED); ! 226: } ! 227: ! 228: /* ! 229: * Message to return region paused indication. ! 230: */ ! 231: void audio_snd_reply_paused(msg_header_t *msg, ! 232: port_name_t remote_port, ! 233: int data_tag) ! 234: { ! 235: return snd_reply_with_tag(msg, remote_port, data_tag, ! 236: SND_MSG_PAUSED); ! 237: } ! 238: ! 239: /* ! 240: * Message to return region resumed indication. ! 241: */ ! 242: void audio_snd_reply_resumed(msg_header_t *msg, ! 243: port_name_t remote_port, ! 244: int data_tag) ! 245: { ! 246: return snd_reply_with_tag(msg, remote_port, data_tag, ! 247: SND_MSG_RESUMED); ! 248: } ! 249: ! 250: /* ! 251: * Replies specific to the sound device. ! 252: */ ! 253: /* ! 254: * Message to return the set of parameters. ! 255: */ ! 256: void audio_snd_reply_ret_parms(msg_header_t *msg, ! 257: port_name_t remote_port, ! 258: u_int parms) ! 259: { ! 260: snd_ret_parms_t *smsg = (snd_ret_parms_t *)msg; ! 261: ! 262: msg->msg_id = SND_MSG_RET_PARMS; ! 263: msg->msg_size = sizeof(snd_ret_parms_t); ! 264: msg->msg_remote_port = remote_port; ! 265: ! 266: smsg->dataType = snd_type_int_template; ! 267: smsg->parms = parms; ! 268: } ! 269: ! 270: /* ! 271: * Message to return the volume. ! 272: */ ! 273: void audio_snd_reply_ret_volume(msg_header_t *msg, ! 274: port_name_t remote_port, ! 275: u_int volume) ! 276: { ! 277: snd_ret_volume_t *smsg = (snd_ret_volume_t *)msg; ! 278: ! 279: msg->msg_id = SND_MSG_RET_VOLUME; ! 280: msg->msg_size = sizeof(snd_ret_volume_t); ! 281: msg->msg_remote_port = remote_port; ! 282: ! 283: smsg->dataType = snd_type_int_template; ! 284: smsg->volume = volume; ! 285: } ! 286: ! 287: /* ! 288: * Message to return supported data formats. ! 289: */ ! 290: void audio_snd_reply_ret_formats(msg_header_t *msg, ! 291: port_name_t remote_port, ! 292: u_int rates, u_int low, u_int high, ! 293: u_int encodings, u_int chans) ! 294: { ! 295: snd_ret_stream_formats_t *smsg = (snd_ret_stream_formats_t *)msg; ! 296: ! 297: msg->msg_id = SND_MSG_RET_STREAM_FORMATS; ! 298: msg->msg_size = sizeof(snd_ret_stream_formats_t); ! 299: msg->msg_remote_port = remote_port; ! 300: ! 301: smsg->Type = snd_type_int_template; ! 302: smsg->Type.msg_type_number = 5; ! 303: smsg->rate = rates; ! 304: smsg->low_rate = low; ! 305: smsg->high_rate = high; ! 306: smsg->encoding = encodings; ! 307: smsg->chan_count = chans; ! 308: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.