fix timing issue in portaudio

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7408 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-01-28 18:16:17 +00:00
parent cbc856fab9
commit 3de64f171b
1 changed files with 4 additions and 2 deletions

View File

@ -540,12 +540,14 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
} }
switch_mutex_lock(globals.device_lock); switch_mutex_lock(globals.device_lock);
get_samples:
if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
globals.read_codec.implementation->samples_per_frame, globals.read_codec.implementation->samples_per_frame,
&globals.timer)) == 0) { &globals.timer)) == 0) {
switch_mutex_unlock(globals.device_lock); switch_mutex_unlock(globals.device_lock);
goto cng; switch_yield(1000);
goto get_samples;
} else { } else {
globals.read_frame.datalen = samples * 2; globals.read_frame.datalen = samples * 2;
globals.read_frame.samples = samples; globals.read_frame.samples = samples;
@ -731,7 +733,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
globals.read_frame.buflen = sizeof(globals.databuf); globals.read_frame.buflen = sizeof(globals.databuf);
globals.cng_frame.data = globals.cngbuf; globals.cng_frame.data = globals.cngbuf;
globals.cng_frame.buflen = sizeof(globals.cngbuf); globals.cng_frame.buflen = sizeof(globals.cngbuf);
globals.cng_frame.datalen = sizeof(globals.cngbuf); globals.cng_frame.datalen = switch_bytes_per_frame(globals.sample_rate, globals.codec_ms) * 2;
switch_set_flag((&globals.cng_frame), SFF_CNG); switch_set_flag((&globals.cng_frame), SFF_CNG);
/* connect my internal structure to the blank pointer passed to me */ /* connect my internal structure to the blank pointer passed to me */