]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix for MODAPP-21
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 5 Jul 2007 18:52:19 +0000 (18:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 5 Jul 2007 18:52:19 +0000 (18:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5499 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_portaudio/mod_portaudio.c

index e949936f6d5dd95940dea1e29d36e78d6b9586d3..20605f9cb3c1f9314740646d315be8418b7d3196 100644 (file)
@@ -242,6 +242,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
                switch_channel_mark_ring_ready(channel);
 
                while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
+                       switch_size_t olen = globals.timer.samples;
+                               
                        if (switch_time_now() - last >= waitsec) {
                                char buf[512];
                                switch_event_t *event;
@@ -254,25 +256,22 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
                                        switch_channel_event_set_data(channel, event);
                                        switch_event_fire(&event);
                                }
-
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
                                last = switch_time_now();
-                               if (ring_file) {
+                       }
+                       
+                       if (ring_file) {
+                               if (switch_core_timer_next(&globals.timer) != SWITCH_STATUS_SUCCESS) {
+                                       switch_core_file_close(&fh);
+                                       break;
+                               }
+                               switch_core_file_read(&fh, abuf, &olen);
+                               if (olen == 0) {
                                        unsigned int pos = 0;
                                        switch_core_file_seek(&fh, &pos, 0, SEEK_SET);
-                                       for (;;) {
-                                               switch_size_t olen = 1024;
-                                               switch_core_file_read(&fh, abuf, &olen);
-                                               if (olen == 0) {
-                                                       break;
-                                               }
-                                               WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.timer);
-                                       }
                                }
+                               WriteAudioStream(globals.ring_stream, abuf, (long) olen, &globals.timer);
                        }
-
-                       switch_yield(globals.read_codec.implementation->microseconds_per_frame);
-
                }
                switch_clear_flag_locked((&globals), GFLAG_RING);
        }