]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
sndfile tweak
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 10 Sep 2012 19:13:07 +0000 (14:13 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 10 Sep 2012 19:13:12 +0000 (14:13 -0500)
src/mod/formats/mod_sndfile/mod_sndfile.c

index 42d2a71a716daf73a2d07e3f5d9d0c33cf4d81df..e941524b1c5c415e1d91e25f0d4a9c048d1b14fc 100644 (file)
@@ -65,6 +65,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
        size_t alt_len = 0;
        int rates[4] = { 8000, 16000, 32000, 48000 };
        int i;
+       sf_count_t frames = 0;
 #ifdef WIN32
        char ps = '\\';
 #else
@@ -209,12 +210,16 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
        handle->speed = 0;
        handle->private_info = context;
 
+       if (handle->offset_pos) {
+               frames = handle->offset_pos;
+               handle->offset_pos = 0;
+       }
+
        if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
-               handle->pos = sf_seek(context->handle, 0, SEEK_END);
+               handle->pos = sf_seek(context->handle, frames, SEEK_END);
        } else if (switch_test_flag(handle, SWITCH_FILE_WRITE_OVER)) {
-               handle->pos = sf_seek(context->handle, 0, SEEK_SET);
-       } else {
-               sf_count_t frames = 0;
+               handle->pos = sf_seek(context->handle, frames, SEEK_SET);
+       } else {                
                sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
        }