Ignore:
Timestamp:
Jun 12, 2008 12:48:59 PM (16 years ago)
Author:
nanang
Message:

Ticket #542: added new API and macro for sound device latency settings, also added new param for this in pjsua

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/pasound.c

    r1919 r2007  
    2929#define THIS_FILE       "pasound.c" 
    3030 
    31 #define MAX_LATENCY     (PJMEDIA_PASOUND_MAX_LATENCY / 1000.0) 
    32  
    3331static int snd_init_count; 
     32 
     33/* Latency settings */ 
     34static unsigned snd_input_latency  = PJMEDIA_SND_DEFAULT_REC_LATENCY; 
     35static unsigned snd_output_latency = PJMEDIA_SND_DEFAULT_PLAY_LATENCY; 
    3436 
    3537static struct snd_mgr 
     
    562564    inputParam.hostApiSpecificStreamInfo = NULL; 
    563565    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; 
    567567 
    568568    paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); 
     
    664664    outputParam.hostApiSpecificStreamInfo = NULL; 
    665665    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; 
    669667 
    670668    paHostApiInfo = Pa_GetHostApiInfo(paDevInfo->hostApi); 
     
    795793    inputParam.hostApiSpecificStreamInfo = NULL; 
    796794    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; 
    800796 
    801797    paRecHostApiInfo = Pa_GetHostApiInfo(paRecDevInfo->hostApi); 
     
    806802    outputParam.hostApiSpecificStreamInfo = NULL; 
    807803    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; 
    811805 
    812806    paPlayHostApiInfo = Pa_GetHostApiInfo(paPlayDevInfo->hostApi); 
     
    10131007} 
    10141008 
     1009/* 
     1010 * Set sound latency. 
     1011 */ 
     1012PJ_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} 
    10151022 
    10161023#endif  /* PJMEDIA_SOUND_IMPLEMENTATION */ 
Note: See TracChangeset for help on using the changeset viewer.