Changeset 352 for pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
- Timestamp:
- Mar 23, 2006 1:15:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r321 r352 24 24 struct pjmedia_snd_port 25 25 { 26 int snd_index; 26 int rec_id; 27 int play_id; 27 28 pjmedia_snd_stream *snd_stream; 28 29 pjmedia_dir dir; … … 124 125 125 126 /* Open sound stream. */ 126 if (snd_port->dir == PJMEDIA_DIR_ENCODING) { 127 status = pjmedia_snd_open_recorder( snd_port->snd_index, 128 snd_port->clock_rate, 129 snd_port->channel_count, 130 snd_port->samples_per_frame, 131 snd_port->bits_per_sample, 132 &rec_cb, 133 snd_port, 134 &snd_port->snd_stream); 135 } else { 136 status = pjmedia_snd_open_player( snd_port->snd_index, 127 if (snd_port->dir == PJMEDIA_DIR_CAPTURE) { 128 status = pjmedia_snd_open_rec( snd_port->rec_id, 129 snd_port->clock_rate, 130 snd_port->channel_count, 131 snd_port->samples_per_frame, 132 snd_port->bits_per_sample, 133 &rec_cb, 134 snd_port, 135 &snd_port->snd_stream); 136 137 } else if (snd_port->dir == PJMEDIA_DIR_PLAYBACK) { 138 status = pjmedia_snd_open_player( snd_port->play_id, 137 139 snd_port->clock_rate, 138 140 snd_port->channel_count, … … 142 144 snd_port, 143 145 &snd_port->snd_stream); 146 147 } else if (snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) { 148 status = pjmedia_snd_open( snd_port->rec_id, 149 snd_port->play_id, 150 snd_port->clock_rate, 151 snd_port->channel_count, 152 snd_port->samples_per_frame, 153 snd_port->bits_per_sample, 154 &rec_cb, 155 &play_cb, 156 snd_port, 157 &snd_port->snd_stream); 158 } else { 159 pj_assert(!"Invalid dir"); 160 status = PJ_EBUG; 144 161 } 145 162 … … 177 194 178 195 /* 196 * Create bidirectional port. 197 */ 198 PJ_DEF(pj_status_t) pjmedia_snd_port_create( pj_pool_t *pool, 199 int rec_id, 200 int play_id, 201 unsigned clock_rate, 202 unsigned channel_count, 203 unsigned samples_per_frame, 204 unsigned bits_per_sample, 205 unsigned options, 206 pjmedia_snd_port **p_port) 207 { 208 pjmedia_snd_port *snd_port; 209 210 PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL); 211 PJ_ASSERT_RETURN(options == 0, PJ_EINVAL); 212 213 snd_port = pj_pool_zalloc(pool, sizeof(pjmedia_snd_port)); 214 PJ_ASSERT_RETURN(snd_port, PJ_ENOMEM); 215 216 snd_port->rec_id = rec_id; 217 snd_port->play_id = play_id; 218 snd_port->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 219 snd_port->clock_rate = clock_rate; 220 snd_port->channel_count = channel_count; 221 snd_port->samples_per_frame = samples_per_frame; 222 snd_port->bits_per_sample = bits_per_sample; 223 224 *p_port = snd_port; 225 226 /* Start sound device immediately. 227 * If there's no port connected, the sound callback will return 228 * empty signal. 229 */ 230 return start_sound_device( snd_port ); 231 232 } 233 234 /* 179 235 * Create sound recorder port. 180 236 */ 181 237 PJ_DEF(pj_status_t) pjmedia_snd_port_create_rec( pj_pool_t *pool, 182 int index,238 int dev_id, 183 239 unsigned clock_rate, 184 240 unsigned channel_count, … … 196 252 PJ_ASSERT_RETURN(snd_port, PJ_ENOMEM); 197 253 198 snd_port-> snd_index = index;199 snd_port->dir = PJMEDIA_DIR_ ENCODING;254 snd_port->rec_id = dev_id; 255 snd_port->dir = PJMEDIA_DIR_CAPTURE; 200 256 snd_port->clock_rate = clock_rate; 201 257 snd_port->channel_count = channel_count; … … 217 273 */ 218 274 PJ_DEF(pj_status_t) pjmedia_snd_port_create_player( pj_pool_t *pool, 219 int index,275 int dev_id, 220 276 unsigned clock_rate, 221 277 unsigned channel_count, … … 233 289 PJ_ASSERT_RETURN(snd_port, PJ_ENOMEM); 234 290 235 snd_port-> snd_index = index;236 snd_port->dir = PJMEDIA_DIR_ DECODING;291 snd_port->play_id = dev_id; 292 snd_port->dir = PJMEDIA_DIR_PLAYBACK; 237 293 snd_port->clock_rate = clock_rate; 238 294 snd_port->channel_count = channel_count; … … 262 318 263 319 /* 320 * Retrieve the sound stream associated by this sound device port. 321 */ 322 PJ_DEF(pjmedia_snd_stream*) pjmedia_snd_port_get_snd_stream( 323 pjmedia_snd_port *snd_port) 324 { 325 PJ_ASSERT_RETURN(snd_port, NULL); 326 return snd_port->snd_stream; 327 } 328 329 330 /* 264 331 * Connect a port. 265 332 */
Note: See TracChangeset
for help on using the changeset viewer.