[Freeswitch-trunk] [commit] r7042 - in freeswitch/trunk/src: . mod/formats/mod_local_stream mod/formats/mod_tone_stream
Freeswitch SVN
mikej at freeswitch.org
Mon Dec 31 14:41:40 EST 2007
Author: mikej
Date: Mon Dec 31 14:41:39 2007
New Revision: 7042
Modified:
freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c
freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c
freeswitch/trunk/src/switch_core_file.c
Log:
simplify file interface for stream file interfaces, cleanup.
Modified: freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c Mon Dec 31 14:41:39 2007
@@ -85,7 +85,6 @@
return index;
}
-
static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void *obj)
{
local_stream_source_t *source = obj;
@@ -151,7 +150,6 @@
}
continue;
}
-
}
if (skip > 0) {
@@ -180,7 +178,6 @@
return NULL;
}
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Playing %s rate: %d\n", fname, source->rate);
while (RUNNING) {
@@ -217,7 +214,6 @@
switch_dir_close(source->dir_handle);
source->dir_handle = NULL;
-
}
if (fd > -1) {
@@ -262,8 +258,6 @@
goto end;
}
-
-
handle->samples = 0;
handle->samplerate = source->rate;
handle->channels = source->channels;
@@ -318,11 +312,6 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t local_stream_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
-{
- return SWITCH_STATUS_FALSE;
-}
-
static switch_status_t local_stream_file_read(switch_file_handle_t *handle, void *data, size_t *len)
{
local_stream_context_t *context = handle->private_info;
@@ -344,21 +333,6 @@
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t local_stream_file_write(switch_file_handle_t *handle, void *data, size_t *len)
-{
- return SWITCH_STATUS_FALSE;
-}
-
-static switch_status_t local_stream_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
-{
- return SWITCH_STATUS_FALSE;
-}
-
-static switch_status_t local_stream_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
-{
- return SWITCH_STATUS_FALSE;
-}
-
/* Registration */
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
@@ -372,7 +346,6 @@
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
-
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return;
@@ -442,14 +415,11 @@
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);
-
}
switch_xml_free(xml);
-
}
-
SWITCH_MODULE_LOAD_FUNCTION(mod_local_stream_load)
{
switch_file_interface_t *file_interface;
@@ -462,10 +432,6 @@
file_interface->file_open = local_stream_file_open;
file_interface->file_close = local_stream_file_close;
file_interface->file_read = local_stream_file_read;
- file_interface->file_write = local_stream_file_write;
- file_interface->file_seek = local_stream_file_seek;
- file_interface->file_set_string = local_stream_file_set_string;
- file_interface->file_get_string = local_stream_file_get_string;
memset(&globals, 0, sizeof(globals));
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool);
Modified: freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c Mon Dec 31 14:41:39 2007
@@ -30,14 +30,11 @@
*
*/
#include <switch.h>
-/* for apr_pstrcat */
-#define DEFAULT_PREBUFFER_SIZE 1024 * 16
SWITCH_MODULE_LOAD_FUNCTION(mod_tone_stream_load);
SWITCH_MODULE_DEFINITION(mod_tone_stream, mod_tone_stream_load, NULL, NULL);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_tone_stream_shutdown);
-
static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
{
switch_buffer_t *audio_buffer = ts->user_data;
@@ -113,44 +110,21 @@
switch_buffer_t *audio_buffer = handle->private_info;
switch_buffer_destroy(&audio_buffer);
-
return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t tone_stream_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence)
-{
- return SWITCH_STATUS_FALSE;
-}
-
static switch_status_t tone_stream_file_read(switch_file_handle_t *handle, void *data, size_t *len)
{
switch_buffer_t *audio_buffer = handle->private_info;
switch_size_t bytes;
- if ((bytes = (uint32_t) switch_buffer_read_loop(audio_buffer, data, *len * 2)) <= 0) {
+ if ((bytes = switch_buffer_read_loop(audio_buffer, data, *len * 2)) <= 0) {
*len = 0;
return SWITCH_STATUS_FALSE;
- } else {
- *len = bytes / 2;
}
-
- return SWITCH_STATUS_SUCCESS;
-}
-
-static switch_status_t tone_stream_file_write(switch_file_handle_t *handle, void *data, size_t *len)
-{
- return SWITCH_STATUS_FALSE;
-}
-
-static switch_status_t tone_stream_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string)
-{
- return SWITCH_STATUS_FALSE;
-}
-
-static switch_status_t tone_stream_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string)
-{
- return SWITCH_STATUS_FALSE;
+ *len = bytes / 2;
+ return SWITCH_STATUS_SUCCESS;
}
/* Registration */
@@ -169,10 +143,6 @@
file_interface->file_open = tone_stream_file_open;
file_interface->file_close = tone_stream_file_close;
file_interface->file_read = tone_stream_file_read;
- file_interface->file_write = tone_stream_file_write;
- file_interface->file_seek = tone_stream_file_seek;
- file_interface->file_set_string = tone_stream_file_set_string;
- file_interface->file_get_string = tone_stream_file_get_string;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/switch_core_file.c
==============================================================================
--- freeswitch/trunk/src/switch_core_file.c (original)
+++ freeswitch/trunk/src/switch_core_file.c Mon Dec 31 14:41:39 2007
@@ -178,6 +178,10 @@
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+
+ if (!fh->file_interface->file_write) {
+ return SWITCH_STATUS_FALSE;
+ }
if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
if (!fh->resampler) {
@@ -225,6 +229,10 @@
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+ if (!fh->file_interface->file_seek) {
+ return SWITCH_STATUS_FALSE;
+ }
+
switch_set_flag(fh, SWITCH_FILE_SEEK);
status = fh->file_interface->file_seek(fh, cur_pos, samples, whence);
if (samples) {
@@ -238,6 +246,10 @@
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+ if (!fh->file_interface->file_set_string) {
+ return SWITCH_STATUS_FALSE;
+ }
+
return fh->file_interface->file_set_string(fh, col, string);
}
@@ -246,6 +258,10 @@
switch_assert(fh != NULL);
switch_assert(fh->file_interface != NULL);
+ if (!fh->file_interface->file_get_string) {
+ return SWITCH_STATUS_FALSE;
+ }
+
return fh->file_interface->file_get_string(fh, col, string);
}
More information about the Freeswitch-trunk
mailing list