]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
MODAPP-305 FSCORE-401
authorBrian West <brian@freeswitch.org>
Fri, 10 Jul 2009 17:18:02 +0000 (17:18 +0000)
committerBrian West <brian@freeswitch.org>
Fri, 10 Jul 2009 17:18:02 +0000 (17:18 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14199 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_voicemail/mod_voicemail.c
src/switch_core_file.c

index 116430f47e5b7c07131b860eb88e39f04ae0add7..bed51901c05af533ed8b7dbc4b7b625aa6493b58 100644 (file)
@@ -902,8 +902,8 @@ static switch_status_t control_playback(switch_core_session_t *session, void *in
                        }
 
                        if (dtmf->digit == *cc->profile->rew_key) {
-                               int samps = 24000;
-                               switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+                               int samps = -48000;
+                               switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
                                return SWITCH_STATUS_SUCCESS;
                        }
                }
index fbbbe873d618c9ebb6b18da66c125fa5f3962401..8c179562882dbcc0830fa6b885e8968daf1306b1 100644 (file)
@@ -26,6 +26,7 @@
  * Anthony Minessale II <anthm@freeswitch.org>
  * Michael Jerris <mike@jerris.com>
  * Paul D. Tinsley <pdt at jackhammer.org>
+ * John Wehle <john@feith.com>
  *
  *
  * switch_core_file.c -- Main Core Library (File I/O Functions)
@@ -335,12 +336,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
 
 SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence)
 {
+       size_t bytes = 0;
        switch_status_t status;
 
        switch_assert(fh != NULL);
        switch_assert(fh->file_interface != NULL);
 
-       if (!switch_test_flag(fh, SWITCH_FILE_OPEN)) {
+       if (!switch_test_flag(fh, SWITCH_FILE_OPEN) || !switch_test_flag(fh, SWITCH_FILE_FLAG_READ)) {
                return SWITCH_STATUS_FALSE;
        }
 
@@ -348,6 +350,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
                return SWITCH_STATUS_FALSE;
        }
 
+       if (fh->buffer) {
+               bytes += switch_buffer_inuse(fh->buffer);
+               switch_buffer_zero(fh->buffer);
+       }
+
+       if (fh->pre_buffer) {
+               bytes += switch_buffer_inuse(fh->pre_buffer);
+               switch_buffer_zero(fh->pre_buffer);
+       }
+
+       if (whence == SWITCH_SEEK_CUR) {
+               samples -= bytes / sizeof(int16_t);
+       }
+
        switch_set_flag(fh, SWITCH_FILE_SEEK);
        status = fh->file_interface->file_seek(fh, cur_pos, samples, whence);
        if (samples) {