]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix timing issue in portaudio
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 28 Jan 2008 18:16:17 +0000 (18:16 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 28 Jan 2008 18:16:17 +0000 (18:16 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7408 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_portaudio/mod_portaudio.c

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