]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix file string when being used in ringback
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Nov 2010 22:48:59 +0000 (16:48 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 11 Nov 2010 22:48:59 +0000 (16:48 -0600)
src/mod/formats/mod_file_string/mod_file_string.c

index f706000a8af711b165b3247f9220f10b264feac9..a222f7bc1d8ce1d4d59a87f5712eff6306640325 100644 (file)
@@ -71,7 +71,7 @@ static int next_file(switch_file_handle_t *handle)
                switch_core_file_close(&context->fh);
        }
 
-       if (context->index == context->argc) {
+       if (context->index >= context->argc) {
                return 0;
        }
 
@@ -110,6 +110,24 @@ static int next_file(switch_file_handle_t *handle)
        return 1;
 }
 
+
+static switch_status_t file_string_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
+{
+       file_string_context_t *context = handle->private_info;
+
+       if (samples == 0 && whence == SEEK_SET) {
+               context->index = -1;
+               return SWITCH_STATUS_SUCCESS;
+       }
+       
+       if (!handle->seekable) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File is not seekable\n");
+               return SWITCH_STATUS_NOTIMPL;
+       }
+
+       return switch_core_file_seek(&context->fh, cur_sample, samples, whence);
+}
+
 static switch_status_t file_string_file_open(switch_file_handle_t *handle, const char *path)
 {
        file_string_context_t *context;
@@ -185,6 +203,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_file_string_load)
        file_interface->file_open = file_string_file_open;
        file_interface->file_close = file_string_file_close;
        file_interface->file_read = file_string_file_read;
+       file_interface->file_seek = file_string_file_seek;
 
        memset(&globals, 0, sizeof(globals));
        /* indicate that the module should continue to be loaded */