- Timestamp:
- Jun 12, 2008 12:48:59 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/config.h
r1971 r2007 84 84 85 85 /** 86 * Specify PortAudio maximum buffering latency, in milliseconds. 87 */ 88 #ifndef PJMEDIA_PASOUND_MAX_LATENCY 89 # define PJMEDIA_PASOUND_MAX_LATENCY 100 86 * Specify sound device latency default, in milisecond. 87 */ 88 #ifndef PJMEDIA_SND_DEFAULT_REC_LATENCY 89 # define PJMEDIA_SND_DEFAULT_REC_LATENCY 10 90 #endif 91 92 #ifndef PJMEDIA_SND_DEFAULT_PLAY_LATENCY 93 # define PJMEDIA_SND_DEFAULT_PLAY_LATENCY 100 90 94 #endif 91 95 -
pjproject/trunk/pjmedia/include/pjmedia/sound.h
r974 r2007 152 152 */ 153 153 PJ_DECL(const pjmedia_snd_dev_info*) pjmedia_snd_get_dev_info(unsigned index); 154 155 156 /** 157 * Set sound device latency, this function must be called before sound device 158 * opened, or otherwise default latency setting will be used, @see 159 * PJMEDIA_SND_DEFAULT_REC_LATENCY & PJMEDIA_SND_DEFAULT_PLAY_LATENCY. 160 * 161 * Choosing latency value is not straightforward, it should accomodate both 162 * minimum latency and stability. Lower latency tends to cause sound device 163 * less reliable (producing audio dropouts) on CPU load disturbance. Moreover, 164 * the best latency setting may vary based on many aspects, e.g: sound card, 165 * CPU, OS, kernel, etc. 166 * 167 * @param input_latency The latency of input device, in ms, set to 0 168 * for default PJMEDIA_SND_DEFAULT_REC_LATENCY. 169 * @param output_latency The latency of output device, in ms, set to 0 170 * for default PJMEDIA_SND_DEFAULT_PLAY_LATENCY. 171 * 172 * @return PJ_SUCCESS on success. 173 */ 174 PJ_DECL(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency, 175 unsigned output_latency); 154 176 155 177 -
pjproject/trunk/pjmedia/src/pjmedia/dsound.c
r1422 r2007 60 60 static int snd_init_count; 61 61 62 /* Latency settings */ 63 static unsigned snd_input_latency = PJMEDIA_SND_DEFAULT_REC_LATENCY; 64 static unsigned snd_output_latency = PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 65 62 66 63 67 /* Individual DirectSound capture/playback stream descriptor */ … … 987 991 988 992 993 /* 994 * Set sound latency. 995 */ 996 PJ_DEF(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency, 997 unsigned output_latency) 998 { 999 PJ_TODO(APPLY_LATENCY_SETTINGS_ON_DSOUND); 1000 1001 snd_input_latency = (input_latency == 0)? 1002 PJMEDIA_SND_DEFAULT_REC_LATENCY : input_latency; 1003 snd_output_latency = (output_latency == 0)? 1004 PJMEDIA_SND_DEFAULT_PLAY_LATENCY : output_latency; 1005 1006 return PJ_SUCCESS; 1007 } 1008 989 1009 #endif /* PJMEDIA_SOUND_IMPLEMENTATION */ 990 1010 -
pjproject/trunk/pjmedia/src/pjmedia/nullsound.c
r1269 r2007 182 182 } 183 183 184 /* 185 * Set sound latency. 186 */ 187 PJ_DEF(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency, 188 unsigned output_latency) 189 { 190 /* Nothing to do */ 191 PJ_UNUSED_ARG(input_latency); 192 PJ_UNUSED_ARG(output_latency); 193 return PJ_SUCCESS; 194 } 195 184 196 #endif /* PJMEDIA_SOUND_IMPLEMENTATION */ -
pjproject/trunk/pjmedia/src/pjmedia/pasound.c
r1919 r2007 29 29 #define THIS_FILE "pasound.c" 30 30 31 #define MAX_LATENCY (PJMEDIA_PASOUND_MAX_LATENCY / 1000.0)32 33 31 static int snd_init_count; 32 33 /* Latency settings */ 34 static unsigned snd_input_latency = PJMEDIA_SND_DEFAULT_REC_LATENCY; 35 static unsigned snd_output_latency = PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 34 36 35 37 static struct snd_mgr … … 562 564 inputParam.hostApiSpecificStreamInfo = NULL; 563 565 inputParam.sampleFormat = sampleFormat; 564 inputParam.suggestedLatency = paDevInfo->defaultLowInputLatency; 565 if (inputParam.suggestedLatency > MAX_LATENCY) 566 inputParam.suggestedLatency = MAX_LATENCY; 566 inputParam.suggestedLatency = snd_input_latency / 1000.0; 567 567 568 568 paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); … … 664 664 outputParam.hostApiSpecificStreamInfo = NULL; 665 665 outputParam.sampleFormat = sampleFormat; 666 outputParam.suggestedLatency = paDevInfo->defaultLowOutputLatency; 667 if (outputParam.suggestedLatency > MAX_LATENCY) 668 outputParam.suggestedLatency = MAX_LATENCY; 666 outputParam.suggestedLatency = snd_output_latency / 1000.0; 669 667 670 668 paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); … … 795 793 inputParam.hostApiSpecificStreamInfo = NULL; 796 794 inputParam.sampleFormat = sampleFormat; 797 inputParam.suggestedLatency = paRecDevInfo->defaultLowInputLatency; 798 if (inputParam.suggestedLatency > MAX_LATENCY) 799 inputParam.suggestedLatency = MAX_LATENCY; 795 inputParam.suggestedLatency = snd_input_latency / 1000.0; 800 796 801 797 paRecHostApiInfo = Pa_GetHostApiInfo(paRecDevInfo->hostApi); … … 806 802 outputParam.hostApiSpecificStreamInfo = NULL; 807 803 outputParam.sampleFormat = sampleFormat; 808 outputParam.suggestedLatency = paPlayDevInfo->defaultLowOutputLatency; 809 if (outputParam.suggestedLatency > MAX_LATENCY) 810 outputParam.suggestedLatency = MAX_LATENCY; 804 outputParam.suggestedLatency = snd_output_latency / 1000.0; 811 805 812 806 paPlayHostApiInfo = Pa_GetHostApiInfo(paPlayDevInfo->hostApi); … … 1013 1007 } 1014 1008 1009 /* 1010 * Set sound latency. 1011 */ 1012 PJ_DEF(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency, 1013 unsigned output_latency) 1014 { 1015 snd_input_latency = (input_latency == 0)? 1016 PJMEDIA_SND_DEFAULT_REC_LATENCY : input_latency; 1017 snd_output_latency = (output_latency == 0)? 1018 PJMEDIA_SND_DEFAULT_PLAY_LATENCY : output_latency; 1019 1020 return PJ_SUCCESS; 1021 } 1015 1022 1016 1023 #endif /* PJMEDIA_SOUND_IMPLEMENTATION */ -
pjproject/trunk/pjmedia/src/pjmedia/rtcp_xr.c
r1984 r2007 327 327 * is taken to be totally around 30ms + sound device latency. 328 328 */ 329 est_extra_delay = 30 + 330 #if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_PORTAUDIO_SOUND 331 PJMEDIA_PASOUND_MAX_LATENCY 332 #elif PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_NULL_SOUND 333 0 334 #else 335 (PJMEDIA_SOUND_BUFFER_COUNT * 15) 329 est_extra_delay = 30; 330 331 #if PJMEDIA_SOUND_IMPLEMENTATION!=PJMEDIA_SOUND_NULL_SOUND 332 est_extra_delay += PJMEDIA_SND_DEFAULT_REC_LATENCY + 333 PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 336 334 #endif 337 ; 335 338 336 sess->stat.rx.voip_mtc.end_sys_delay = (pj_uint16_t) 339 337 (sess->stat.rx.voip_mtc.rnd_trip_delay / 2 + -
pjproject/trunk/pjmedia/src/pjmedia/symbian_sound.cpp
r1688 r2007 928 928 } 929 929 930 931 /* 932 * Set sound latency. 933 */ 934 PJ_DEF(pj_status_t) pjmedia_snd_set_latency(unsigned input_latency, 935 unsigned output_latency) 936 { 937 /* Nothing to do */ 938 PJ_UNUSED_ARG(input_latency); 939 PJ_UNUSED_ARG(output_latency); 940 return PJ_SUCCESS; 941 } -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r1990 r2007 86 86 87 87 int capture_dev, playback_dev; 88 unsigned capture_lat, playback_lat; 88 89 } app_config; 89 90 … … 195 196 puts (" --capture-dev=id Audio capture device ID (default=-1)"); 196 197 puts (" --playback-dev=id Audio playback device ID (default=-1)"); 198 puts (" --capture-lat=N Audio capture latency, in ms (default=10)"); 199 puts (" --playback-lat=N Audio playback latency, in ms (default=100)"); 197 200 198 201 puts (""); … … 253 256 cfg->capture_dev = PJSUA_INVALID_ID; 254 257 cfg->playback_dev = PJSUA_INVALID_ID; 258 cfg->capture_lat = PJMEDIA_SND_DEFAULT_REC_LATENCY; 259 cfg->playback_lat = PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 255 260 256 261 for (i=0; i<PJ_ARRAY_SIZE(cfg->acc_cfg); ++i) … … 414 419 OPT_TLS_NEG_TIMEOUT, 415 420 OPT_CAPTURE_DEV, OPT_PLAYBACK_DEV, 421 OPT_CAPTURE_LAT, OPT_PLAYBACK_LAT, 416 422 OPT_AUTO_UPDATE_NAT,OPT_USE_COMPACT_FORM,OPT_DIS_CODEC 417 423 }; … … 500 506 { "capture-dev", 1, 0, OPT_CAPTURE_DEV}, 501 507 { "playback-dev", 1, 0, OPT_PLAYBACK_DEV}, 508 { "capture-lat", 1, 0, OPT_CAPTURE_LAT}, 509 { "playback-lat", 1, 0, OPT_PLAYBACK_LAT}, 502 510 { NULL, 0, 0, 0} 503 511 }; … … 1076 1084 case OPT_PLAYBACK_DEV: 1077 1085 cfg->playback_dev = atoi(pj_optarg); 1086 break; 1087 1088 case OPT_CAPTURE_LAT: 1089 cfg->capture_lat = atoi(pj_optarg); 1090 break; 1091 1092 case OPT_PLAYBACK_LAT: 1093 cfg->playback_lat = atoi(pj_optarg); 1078 1094 break; 1079 1095 … … 1472 1488 if (config->playback_dev != PJSUA_INVALID_ID) { 1473 1489 pj_ansi_sprintf(line, "--playback-dev %d\n", config->playback_dev); 1490 pj_strcat2(&cfg, line); 1491 } 1492 1493 /* Sound device latency */ 1494 if (config->capture_lat != PJMEDIA_SND_DEFAULT_REC_LATENCY) { 1495 pj_ansi_sprintf(line, "--capture-lat %d\n", config->capture_lat); 1496 pj_strcat2(&cfg, line); 1497 } 1498 if (config->playback_dev != PJMEDIA_SND_DEFAULT_PLAY_LATENCY) { 1499 pj_ansi_sprintf(line, "--playback-lat %d\n", config->playback_lat); 1474 1500 pj_strcat2(&cfg, line); 1475 1501 } … … 3714 3740 goto on_error; 3715 3741 3742 /* Set sound device latency */ 3743 pjmedia_snd_set_latency(app_config.capture_lat, app_config.playback_lat); 3744 3716 3745 /* Use null sound device? */ 3717 3746 #ifndef STEREO_DEMO
Note: See TracChangeset
for help on using the changeset viewer.