]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
buffer regressions
authorBrian West <brian@freeswitch.org>
Tue, 13 Jan 2009 21:43:55 +0000 (21:43 +0000)
committerBrian West <brian@freeswitch.org>
Tue, 13 Jan 2009 21:43:55 +0000 (21:43 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11162 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/formats/mod_local_stream/mod_local_stream.c
support-d/.emacs

index 49ca2bafa745c04aa0cf53592f49dd35ffc7583b..f099a3fc9430a8cc1270b18dc977f0f76c85258f 100644 (file)
@@ -183,7 +183,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
 
                        fname = path_buf;
                        fh.prebuf = source->prebuf;
-                       fh.pre_buffer_datalen = 65536;
+                       fh.pre_buffer_datalen = source->prebuf;
 
                        if (switch_core_file_open(&fh,
                                                                          (char *) fname,
@@ -206,16 +206,23 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
                        while (RUNNING) {
                                switch_core_timer_next(&timer);
                                olen = source->samples;
+                               int is_open = switch_test_flag((&fh), SWITCH_FILE_OPEN);
 
-                               if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
-                                       switch_core_file_close(&fh);
-                                       break;
+                               if (is_open) {
+                                       if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
+                                               switch_core_file_close(&fh);
+                                       }
+
+                                       switch_buffer_write(audio_buffer, abuf, olen * 2);
                                }
 
-                               switch_buffer_write(audio_buffer, abuf, olen * 2);
                                used = switch_buffer_inuse(audio_buffer);
 
-                               if (used >= source->prebuf || (source->total && used > source->samples * 2)) {
+                               if (!used && !is_open) {
+                                       break;
+                               }
+
+                               if (!is_open || used >= source->prebuf || (source->total && used > source->samples * 2)) {
                                        used = switch_buffer_read(audio_buffer, dist_buf, source->samples * 2);
                                        if (source->total) {
 
@@ -285,6 +292,9 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
        char *alt_path = NULL;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
+       /* already buffering a step back, so always disable it */
+       handle->pre_buffer_datalen = 0;
+
        if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
                return SWITCH_STATUS_FALSE;
index 2fa7cb24bb6fbc837c9df90658c6dc3850f1c042..fe2e33af2e14bad5e228100d9c7ee92ce6c8b944 100644 (file)
@@ -7,7 +7,7 @@
 ;(setq cperl-hairy t)
 (global-unset-key "\C-h")
 (global-set-key "\C-h" 'delete-backward-char)
-(load "/usr/share/emacs/site-lisp/rng-auto.el")
+;(load "/usr/share/emacs/site-lisp/rng-auto.el")
 
 (require 'cc-mode)
 (defun my-build-tab-stop-list (width)