- Timestamp:
- Mar 19, 2006 12:48:43 AM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/errno.h
r321 r334 443 443 444 444 445 /************************************************************ 446 * SOUND DEVICE ERRORS 447 ***********************************************************/ 448 /** 449 * @hideinitializer 450 * No suitable audio capture device. 451 */ 452 #define PJMEDIA_ENOSNDREC (PJMEDIA_ERRNO_START+200) /* 220200 */ 453 /** 454 * @hideinitializer 455 * No suitable audio playback device. 456 */ 457 #define PJMEDIA_ENOSNDPLAY (PJMEDIA_ERRNO_START+201) /* 220201 */ 458 /** 459 * @hideinitializer 460 * Invalid sound device ID. 461 */ 462 #define PJMEDIA_ESNDINDEVID (PJMEDIA_ERRNO_START+202) /* 220202 */ 463 /** 464 * @hideinitializer 465 * Invalid sample format for sound device. 466 */ 467 #define PJMEDIA_ESNDINSAMPLEFMT (PJMEDIA_ERRNO_START+203) /* 220203 */ 468 469 470 445 471 PJ_END_DECL 446 472 -
pjproject/trunk/pjmedia/src/pjmedia/errno.c
r330 r334 123 123 { PJMEDIA_EWAVEUNSUPP, "Unsupported WAVE file format" }, 124 124 { PJMEDIA_EWAVETOOSHORT, "WAVE file too short" }, 125 126 /* Sound device errors: */ 127 { PJMEDIA_ENOSNDREC, "No suitable sound capture device" }, 128 { PJMEDIA_ENOSNDPLAY, "No suitable sound playback device" }, 129 { PJMEDIA_ESNDINDEVID, "Invalid sound device ID" }, 130 { PJMEDIA_ESNDINSAMPLEFMT, "Invalid sample format for sound device" }, 125 131 }; 126 132 -
pjproject/trunk/pjmedia/src/pjmedia/file_port.c
r322 r334 200 200 } 201 201 202 /* Must be PCM with 16bits per sample */ 202 203 if (wave_hdr.fmt_hdr.fmt_tag != 1 || 203 wave_hdr.fmt_hdr.bits_per_sample != 16 || 204 wave_hdr.fmt_hdr.block_align != 2) 204 wave_hdr.fmt_hdr.bits_per_sample != 16) 205 205 { 206 pj_file_close(fport->fd); 207 return PJMEDIA_EWAVEUNSUPP; 208 } 209 210 /* Block align must be 2*nchannels */ 211 if (wave_hdr.fmt_hdr.block_align != wave_hdr.fmt_hdr.nchan*2) { 206 212 pj_file_close(fport->fd); 207 213 return PJMEDIA_EWAVEUNSUPP; … … 228 234 fport->base.info.bits_per_sample = wave_hdr.fmt_hdr.bits_per_sample; 229 235 fport->base.info.samples_per_frame = fport->base.info.sample_rate * 230 20 / 1000; 236 wave_hdr.fmt_hdr.nchan * 237 20 / 1000; 231 238 fport->base.info.bytes_per_frame = 232 239 fport->base.info.samples_per_frame * -
pjproject/trunk/pjmedia/src/pjmedia/pasound.c
r321 r334 86 86 87 87 status = (*stream->rec_cb)(stream->user_data, stream->timestamp, 88 input, frameCount * stream->bytes_per_sample); 88 input, frameCount * stream->bytes_per_sample * 89 stream->channel_count); 89 90 90 91 if (status==0) … … 105 106 pjmedia_snd_stream *stream = userData; 106 107 pj_status_t status; 107 unsigned size = frameCount * stream->bytes_per_sample; 108 unsigned size = frameCount * stream->bytes_per_sample * 109 stream->channel_count; 108 110 109 111 PJ_UNUSED_ARG(input); … … 207 209 int sampleFormat; 208 210 const PaDeviceInfo *paDevInfo = NULL; 211 unsigned paFrames; 209 212 PaError err; 210 213 … … 218 221 if (index == count) { 219 222 /* No such device. */ 220 return PJ _ENOTFOUND;223 return PJMEDIA_ENOSNDREC; 221 224 } 222 225 } else { … … 224 227 if (!paDevInfo) { 225 228 /* Assumed it is "No such device" error. */ 226 return PJ _ENOTFOUND;229 return PJMEDIA_ESNDINDEVID; 227 230 } 228 231 } … … 235 238 sampleFormat = paInt32; 236 239 else 237 return PJ _ENOTSUP;240 return PJMEDIA_ESNDINSAMPLEFMT; 238 241 239 242 pool = pj_pool_create( snd_mgr.factory, "sndstream", 1024, 1024, NULL); … … 258 261 inputParam.suggestedLatency = paDevInfo->defaultLowInputLatency; 259 262 263 /* Frames in PortAudio is number of samples in a single channel */ 264 paFrames = samples_per_frame / channel_count; 265 260 266 err = Pa_OpenStream( &stream->stream, &inputParam, NULL, 261 clock_rate, samples_per_frame,262 0, &PaRecorderCallback, stream );267 clock_rate, paFrames, 268 paClipOff, &PaRecorderCallback, stream ); 263 269 if (err != paNoError) { 264 270 pj_pool_release(pool); … … 292 298 int sampleFormat; 293 299 const PaDeviceInfo *paDevInfo = NULL; 300 unsigned paFrames; 294 301 PaError err; 295 302 … … 303 310 if (index == count) { 304 311 /* No such device. */ 305 return PJ _ENOTFOUND;312 return PJMEDIA_ENOSNDPLAY; 306 313 } 307 314 } else { … … 309 316 if (!paDevInfo) { 310 317 /* Assumed it is "No such device" error. */ 311 return PJ _ENOTFOUND;318 return PJMEDIA_ESNDINDEVID; 312 319 } 313 320 } … … 320 327 sampleFormat = paInt32; 321 328 else 322 return PJ _ENOTSUP;329 return PJMEDIA_ESNDINSAMPLEFMT; 323 330 324 331 pool = pj_pool_create( snd_mgr.factory, "sndstream", 1024, 1024, NULL); … … 343 350 outputParam.suggestedLatency = paDevInfo->defaultLowInputLatency; 344 351 352 /* Frames in PortAudio is number of samples in a single channel */ 353 paFrames = samples_per_frame / channel_count; 354 345 355 err = Pa_OpenStream( &stream->stream, NULL, &outputParam, 346 clock_rate, samples_per_frame,347 0, &PaPlayerCallback, stream );356 clock_rate, paFrames, 357 paClipOff, &PaPlayerCallback, stream ); 348 358 if (err != paNoError) { 349 359 pj_pool_release(pool); … … 353 363 PJ_LOG(5,(THIS_FILE, "%s opening device %s for playing, sample rate=%d, " 354 364 "channel count=%d, " 355 "%d bits per sample, %d samples per buffer",365 "%d bits per sample, %d samples per frame", 356 366 (err==0 ? "Success" : "Error"), 357 367 paDevInfo->name, clock_rate, channel_count,
Note: See TracChangeset
for help on using the changeset viewer.