From: Brian West Date: Fri, 10 Jul 2009 17:18:02 +0000 (+0000) Subject: MODAPP-305 FSCORE-401 X-Git-Tag: v1.0.4~191 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a99020173d1766194c9491bdf585e4d400dad10f;p=thirdparty%2Ffreeswitch.git MODAPP-305 FSCORE-401 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14199 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 116430f47e..bed51901c0 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -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; } } diff --git a/src/switch_core_file.c b/src/switch_core_file.c index fbbbe873d6..8c17956288 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -26,6 +26,7 @@ * Anthony Minessale II * Michael Jerris * Paul D. Tinsley + * John Wehle * * * 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) {