]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_native_file: add fh->pos setting (MODFORM-34)
authorMichael Jerris <mike@jerris.com>
Mon, 27 Jul 2009 18:54:27 +0000 (18:54 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 27 Jul 2009 18:54:27 +0000 (18:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14388 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/formats/mod_native_file/mod_native_file.c

index d1974d9e58aea4fb9be1c1e7b4032836363e8fe4..bea388bbe8a1cb423201ba98e7925884174bf77a 100644 (file)
@@ -76,6 +76,7 @@ static switch_status_t native_file_file_open(switch_file_handle_t *handle, const
        handle->sections = 0;
        handle->seekable = 1;
        handle->speed = 0;
+       handle->pos = 0;
        handle->private_info = context;
        handle->flags |= SWITCH_FILE_NATIVE;
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening File [%s] %dhz\n", path, handle->samplerate);
@@ -97,18 +98,28 @@ static switch_status_t native_file_file_close(switch_file_handle_t *handle)
 
 static switch_status_t native_file_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
 {
-       native_file_context *context = handle->private_info;
+       switch_status_t status;
 
-       switch_file_seek(context->fd, whence, &samples);
+       native_file_context *context = handle->private_info;
 
+       status = switch_file_seek(context->fd, whence, &samples);
+       if (status == SWITCH_STATUS_SUCCESS) {
+               handle->pos += samples;
+       }
        return SWITCH_STATUS_FALSE;
 }
 
 static switch_status_t native_file_file_read(switch_file_handle_t *handle, void *data, size_t *len)
 {
+       switch_status_t status;
+
        native_file_context *context = handle->private_info;
 
-       return switch_file_read(context->fd, data, len);
+       status = switch_file_read(context->fd, data, len);
+       if (status == SWITCH_STATUS_SUCCESS) {
+               handle->pos += *len;
+       }
+       return status;
 }
 
 static switch_status_t native_file_file_write(switch_file_handle_t *handle, void *data, size_t *len)
@@ -120,8 +131,6 @@ static switch_status_t native_file_file_write(switch_file_handle_t *handle, void
 
 static switch_status_t native_file_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
 {
-       //native_file_context *context = handle->private_info;
-
        return SWITCH_STATUS_FALSE;
 }