Revision
14199
Author
brian
Date
2009-07-10 12:18:02 -0500 (Fri, 10 Jul 2009)

Log Message

 MODAPP-305 FSCORE-401 

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (14198 => 14199)


--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	2009-07-10 16:32:48 UTC (rev 14198)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c	2009-07-10 17:18:02 UTC (rev 14199)
@@ -902,8 +902,8 @@
 			}
 
 			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;
 			}
 		}

Modified: freeswitch/trunk/src/switch_core_file.c (14198 => 14199)


--- freeswitch/trunk/src/switch_core_file.c	2009-07-10 16:32:48 UTC (rev 14198)
+++ freeswitch/trunk/src/switch_core_file.c	2009-07-10 17:18:02 UTC (rev 14199)
@@ -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_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 @@
 		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) {