mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-11 20:17:05 +00:00
run indent on the whole tree and update copyright dates in prep for 1.0.5
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
7b347417e5
commit
886e1ddb4d
229 files changed
+20252
-20192
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -63,10 +63,10 @@ static int next_file(switch_file_handle_t *handle)
|
||||
char *file;
|
||||
const char *prefix = handle->prefix;
|
||||
|
||||
top:
|
||||
top:
|
||||
|
||||
context->index++;
|
||||
|
||||
|
||||
if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(&context->fh);
|
||||
}
|
||||
@@ -89,13 +89,10 @@ static int next_file(switch_file_handle_t *handle)
|
||||
}
|
||||
|
||||
if (switch_core_file_open(&context->fh,
|
||||
file,
|
||||
handle->channels,
|
||||
handle->samplerate,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
file, handle->channels, handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
goto top;
|
||||
}
|
||||
|
||||
|
||||
handle->samples = context->fh.samples;
|
||||
handle->samplerate = context->fh.samplerate;
|
||||
handle->channels = context->fh.channels;
|
||||
@@ -122,15 +119,15 @@ static switch_status_t file_string_file_open(switch_file_handle_t *handle, const
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
context = switch_core_alloc(handle->memory_pool, sizeof(*context));
|
||||
|
||||
|
||||
file_dup = switch_core_strdup(handle->memory_pool, path);
|
||||
context->argc = switch_separate_string(file_dup, '!', context->argv, (sizeof(context->argv) / sizeof(context->argv[0])));
|
||||
context->index = -1;
|
||||
|
||||
|
||||
handle->private_info = context;
|
||||
|
||||
|
||||
return next_file(handle) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
@@ -150,17 +147,17 @@ static switch_status_t file_string_file_read(switch_file_handle_t *handle, void
|
||||
size_t llen = *len;
|
||||
|
||||
if (context->samples > 0) {
|
||||
if (*len > (size_t)context->samples) {
|
||||
if (*len > (size_t) context->samples) {
|
||||
*len = context->samples;
|
||||
}
|
||||
|
||||
|
||||
context->samples -= *len;
|
||||
switch_generate_sln_silence((int16_t *) data, *len, 400);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
status = switch_core_file_read(&context->fh, data, len);
|
||||
}
|
||||
|
||||
|
||||
if (status != SWITCH_STATUS_SUCCESS) {
|
||||
if (!next_file(handle)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -137,7 +137,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
}
|
||||
|
||||
switch_thread_rwlock_create(&source->rwlock, source->pool);
|
||||
|
||||
|
||||
if (RUNNING) {
|
||||
switch_mutex_lock(globals.mutex);
|
||||
switch_core_hash_insert(globals.source_hash, source->name, source);
|
||||
@@ -156,7 +156,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error creating pool");
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (switch_dir_open(&source->dir_handle, source->location, temp_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", source->location);
|
||||
goto done;
|
||||
@@ -203,7 +203,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
fname = path_buf;
|
||||
fh.prebuf = source->prebuf;
|
||||
fh.pre_buffer_datalen = source->prebuf;
|
||||
|
||||
|
||||
if (switch_core_file_open(&fh,
|
||||
(char *) fname,
|
||||
source->channels, source->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
@@ -211,7 +211,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
switch_yield(1000000);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, temp_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n");
|
||||
switch_dir_close(source->dir_handle);
|
||||
@@ -231,10 +231,10 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
if (source->chime_counter > 0) {
|
||||
source->chime_counter -= source->samples;
|
||||
}
|
||||
|
||||
|
||||
if (!switch_test_flag((&source->chime_fh), SWITCH_FILE_OPEN) && source->chime_counter <= 0) {
|
||||
char *val;
|
||||
|
||||
|
||||
val = source->chime_list[source->chime_cur++];
|
||||
|
||||
if (source->chime_cur >= source->chime_total) {
|
||||
@@ -243,9 +243,8 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
|
||||
if (switch_core_file_open(&source->chime_fh,
|
||||
(char *) val,
|
||||
source->channels,
|
||||
source->rate,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
source->channels,
|
||||
source->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s\n", val);
|
||||
}
|
||||
}
|
||||
@@ -255,7 +254,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
}
|
||||
}
|
||||
|
||||
retry:
|
||||
retry:
|
||||
|
||||
is_open = switch_test_flag(use_fh, SWITCH_FILE_OPEN);
|
||||
|
||||
@@ -287,7 +286,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
if (!used && !is_open) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!is_open || used >= source->prebuf || (source->total && used > source->samples * 2)) {
|
||||
used = switch_buffer_read(audio_buffer, dist_buf, source->samples * 2);
|
||||
if (source->total) {
|
||||
@@ -322,7 +321,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
source->dir_handle = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) {
|
||||
switch_core_file_close(&fh);
|
||||
@@ -339,7 +338,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
|
||||
switch_thread_rwlock_wrlock(source->rwlock);
|
||||
switch_thread_rwlock_unlock(source->rwlock);
|
||||
|
||||
|
||||
switch_buffer_destroy(&audio_buffer);
|
||||
|
||||
if (fd > -1) {
|
||||
@@ -376,7 +375,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
|
||||
top:
|
||||
top:
|
||||
|
||||
alt_path = switch_mprintf("%s/%d", path, handle->samplerate);
|
||||
|
||||
@@ -439,7 +438,7 @@ static switch_status_t local_stream_file_open(switch_file_handle_t *handle, cons
|
||||
source->total++;
|
||||
switch_mutex_unlock(source->mutex);
|
||||
|
||||
end:
|
||||
end:
|
||||
switch_safe_free(alt_path);
|
||||
return status;
|
||||
}
|
||||
@@ -464,7 +463,7 @@ static switch_status_t local_stream_file_close(switch_file_handle_t *handle)
|
||||
switch_mutex_unlock(context->source->mutex);
|
||||
switch_buffer_destroy(&context->audio_buffer);
|
||||
switch_thread_rwlock_unlock(context->source->rwlock);
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -573,7 +572,8 @@ static void launch_threads(void)
|
||||
}
|
||||
} else if (!strcasecmp(var, "chime-list")) {
|
||||
char *list_dup = switch_core_strdup(source->pool, val);
|
||||
source->chime_total = switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));
|
||||
source->chime_total =
|
||||
switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));
|
||||
} else if (!strcasecmp(var, "interval")) {
|
||||
int tmp = atoi(val);
|
||||
if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
|
||||
@@ -644,19 +644,19 @@ SWITCH_STANDARD_API(stop_local_stream_function)
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
if (!source) {
|
||||
stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n",local_stream_name);
|
||||
stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n", local_stream_name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
source->stopped = 1;
|
||||
stream->write_function(stream,"+OK");
|
||||
stream->write_function(stream, "+OK");
|
||||
goto done;
|
||||
|
||||
usage:
|
||||
usage:
|
||||
stream->write_function(stream, "-USAGE: %s\n", STOP_LOCAL_STREAM_SYNTAX);
|
||||
switch_safe_free(mycmd);
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
switch_safe_free(mycmd);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@@ -694,7 +694,7 @@ SWITCH_STANDARD_API(show_local_stream_function)
|
||||
xml = SWITCH_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!local_stream_name) {
|
||||
goto usage;
|
||||
}
|
||||
@@ -730,18 +730,18 @@ SWITCH_STANDARD_API(show_local_stream_function)
|
||||
stream->write_function(stream, " stopped: %s\n", (source->stopped) ? "true" : "false");
|
||||
}
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n",local_stream_name);
|
||||
stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n", local_stream_name);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
stream->write_function(stream,"+OK");
|
||||
stream->write_function(stream, "+OK");
|
||||
goto done;
|
||||
|
||||
usage:
|
||||
usage:
|
||||
stream->write_function(stream, "-USAGE: %s\n", SHOW_LOCAL_STREAM_SYNTAX);
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
switch_safe_free(mycmd);
|
||||
@@ -796,29 +796,28 @@ SWITCH_STANDARD_API(start_local_stream_function)
|
||||
if (argv[5]) {
|
||||
tmp = atoi(argv[5]);
|
||||
if (tmp == 1 || tmp == 2) {
|
||||
channels = (uint8_t)tmp;
|
||||
channels = (uint8_t) tmp;
|
||||
}
|
||||
}
|
||||
|
||||
interval = argv[6] ? atoi(argv[6]) : 20;
|
||||
|
||||
if (!SWITCH_ACCEPTABLE_INTERVAL(interval)){
|
||||
|
||||
if (!SWITCH_ACCEPTABLE_INTERVAL(interval)) {
|
||||
interval = 20;
|
||||
}
|
||||
|
||||
if (!path){
|
||||
if (!path) {
|
||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
|
||||
stream->write_function(stream, "-ERR unable to open file %s!\n",cf);
|
||||
stream->write_function(stream, "-ERR unable to open file %s!\n", cf);
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (directory = switch_xml_child(cfg, "directory"); directory; directory = directory->next) {
|
||||
char *name = (char *) switch_xml_attr(directory, "name");
|
||||
if (!name || !local_stream_name || strcasecmp(name, local_stream_name)){
|
||||
if (!name || !local_stream_name || strcasecmp(name, local_stream_name)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
path = (char *) switch_xml_attr(directory, "path");
|
||||
if (!(name && path)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid config!\n");
|
||||
@@ -868,7 +867,7 @@ SWITCH_STANDARD_API(start_local_stream_function)
|
||||
}
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
|
||||
|
||||
if (zstr(local_stream_name) || zstr(path)) {
|
||||
goto usage;
|
||||
}
|
||||
@@ -878,13 +877,13 @@ SWITCH_STANDARD_API(start_local_stream_function)
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
if (source) {
|
||||
source->stopped = 0;
|
||||
stream->write_function(stream,"+OK");
|
||||
goto done;
|
||||
stream->write_function(stream, "+OK");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool for new local_stream\n");
|
||||
stream->write_function(stream, "-ERR unable to allocate memory for local_stream %s!\n",local_stream_name);
|
||||
stream->write_function(stream, "-ERR unable to allocate memory for local_stream %s!\n", local_stream_name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -910,13 +909,13 @@ SWITCH_STANDARD_API(start_local_stream_function)
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);
|
||||
|
||||
stream->write_function(stream,"+OK");
|
||||
stream->write_function(stream, "+OK");
|
||||
goto done;
|
||||
|
||||
usage:
|
||||
usage:
|
||||
stream->write_function(stream, "-USAGE: %s\n", START_LOCAL_STREAM_SYNTAX);
|
||||
|
||||
done:
|
||||
done:
|
||||
|
||||
switch_safe_free(path);
|
||||
switch_safe_free(timer_name);
|
||||
@@ -960,7 +959,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_local_stream_shutdown)
|
||||
RUNNING = 0;
|
||||
switch_event_unbind_callback(event_handler);
|
||||
|
||||
while(THREADS > 0) {
|
||||
while (THREADS > 0) {
|
||||
switch_yield(100000);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -104,7 +104,7 @@ static switch_status_t native_file_file_truncate(switch_file_handle_t *handle, i
|
||||
if ((status = switch_file_trunc(context->fd, offset)) == SWITCH_STATUS_SUCCESS) {
|
||||
handle->pos = 0;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -154,9 +154,9 @@ static int get_dev_by_name(char *name, int in)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static switch_status_t engage_device(portaudio_stream_source_t *source,int restart)
|
||||
static switch_status_t engage_device(portaudio_stream_source_t *source, int restart)
|
||||
{
|
||||
PaStreamParameters inputParameters,outputParameters;
|
||||
PaStreamParameters inputParameters, outputParameters;
|
||||
PaError err;
|
||||
int sample_rate = source->rate;
|
||||
int codec_ms = source->interval;
|
||||
@@ -187,8 +187,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source,int resta
|
||||
if (switch_core_codec_init(&source->write_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
|
||||
NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||
switch_core_codec_destroy(&source->read_codec);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -198,7 +197,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source,int resta
|
||||
|
||||
if (!source->timer.timer_interface) {
|
||||
if (switch_core_timer_init(&source->timer,
|
||||
source->timer_name, codec_ms, source->read_codec.implementation->samples_per_packet,
|
||||
source->timer_name, codec_ms, source->read_codec.implementation->samples_per_packet,
|
||||
module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
|
||||
switch_core_codec_destroy(&source->read_codec);
|
||||
@@ -224,14 +223,13 @@ static switch_status_t engage_device(portaudio_stream_source_t *source,int resta
|
||||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
|
||||
err = OpenAudioStream(&source->audio_stream, &inputParameters, NULL, sample_rate, paClipOff,
|
||||
source->read_codec.implementation->samples_per_packet, 0);
|
||||
err = OpenAudioStream(&source->audio_stream, &inputParameters, NULL, sample_rate, paClipOff, source->read_codec.implementation->samples_per_packet, 0);
|
||||
/* UNLOCKED ************************************************************************************************* */
|
||||
if (err != paNoError) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening audio device retrying\n");
|
||||
switch_yield(1000000);
|
||||
err = OpenAudioStream(&source->audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
|
||||
source->read_codec.implementation->samples_per_packet, 0);
|
||||
source->read_codec.implementation->samples_per_packet, 0);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(source->device_lock);
|
||||
@@ -251,7 +249,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
portaudio_stream_source_t *source = obj;
|
||||
portaudio_stream_context_t *cp;
|
||||
int samples = 0;
|
||||
int bused, bytesToWrite;
|
||||
int bused, bytesToWrite;
|
||||
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
@@ -271,14 +269,14 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
|
||||
switch_thread_rwlock_create(&source->rwlock, source->pool);
|
||||
|
||||
if (engage_device(source,0)!=SWITCH_STATUS_SUCCESS){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Dev %d cant be engaged !\n",(int) source->sourcedev);
|
||||
if (engage_device(source, 0) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Dev %d cant be engaged !\n", (int) source->sourcedev);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Dev %d engaged at %d rate!\n",(int) source->sourcedev, (int) source->rate);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Dev %d engaged at %d rate!\n", (int) source->sourcedev, (int) source->rate);
|
||||
if (globals.running && !source->stopped) {
|
||||
source->ready = 1;
|
||||
|
||||
if (!source->audio_stream){
|
||||
if (!source->audio_stream) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Audio Stream wops!\n");
|
||||
source->stopped = 0;
|
||||
source->ready = 0;
|
||||
@@ -287,7 +285,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
samples = 0;
|
||||
switch_mutex_lock(source->device_lock);
|
||||
samples = ReadAudioStream(source->audio_stream, source->databuf,
|
||||
source->read_codec.implementation->samples_per_packet , &source->timer);
|
||||
source->read_codec.implementation->samples_per_packet, &source->timer);
|
||||
switch_mutex_unlock(source->device_lock);
|
||||
|
||||
|
||||
@@ -306,9 +304,9 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
switch_mutex_lock(cp->audio_mutex);
|
||||
|
||||
bused = switch_buffer_inuse(cp->audio_buffer);
|
||||
if (bused > source->samples * 768 ) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Leaking stream handle! [%s() %s:%d] %d used %d max\n", cp->func, cp->file,
|
||||
cp->line,(int) bused, (int) ( source->samples * 768));
|
||||
if (bused > source->samples * 768) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Leaking stream handle! [%s() %s:%d] %d used %d max\n",
|
||||
cp->func, cp->file, cp->line, (int) bused, (int) (source->samples * 768));
|
||||
switch_buffer_zero(cp->audio_buffer);
|
||||
} else {
|
||||
switch_buffer_write(cp->audio_buffer, source->databuf, bytesToWrite);
|
||||
@@ -357,7 +355,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " thread ending succesfully !\n");
|
||||
switch_thread_exit(thread,SWITCH_STATUS_SUCCESS);
|
||||
switch_thread_exit(thread, SWITCH_STATUS_SUCCESS);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -365,14 +363,14 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
|
||||
static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle, const char *path)
|
||||
{
|
||||
portaudio_stream_context_t *context ;
|
||||
portaudio_stream_context_t *context;
|
||||
portaudio_stream_source_t *source;
|
||||
switch_memory_pool_t *pool;
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
uint32_t rate = PREFERRED_RATE;
|
||||
char *npath ;
|
||||
char *npath;
|
||||
int devNumber;
|
||||
int tmp;
|
||||
|
||||
@@ -383,7 +381,7 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||
return status;
|
||||
}
|
||||
|
||||
npath = switch_core_strdup(module_pool, path);
|
||||
npath = switch_core_strdup(module_pool, path);
|
||||
|
||||
tmp = handle->samplerate;
|
||||
if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
|
||||
@@ -391,11 +389,11 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||
}
|
||||
|
||||
if (*path == '#') {
|
||||
devNumber = get_dev_by_number(npath + 1, 1);
|
||||
devNumber = get_dev_by_number(npath + 1, 1);
|
||||
} else {
|
||||
devNumber = get_dev_by_name(npath , 1);
|
||||
devNumber = get_dev_by_name(npath, 1);
|
||||
}
|
||||
npath = switch_mprintf("device-%d at %d",devNumber,rate);
|
||||
npath = switch_mprintf("device-%d at %d", devNumber, rate);
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
source = switch_core_hash_find(globals.source_hash, npath);
|
||||
@@ -408,7 +406,7 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, " :S no pool\n");
|
||||
} else {
|
||||
source = switch_core_alloc(pool, sizeof(*source));
|
||||
if (source!=NULL){
|
||||
if (source != NULL) {
|
||||
source->pool = pool;
|
||||
source->sourcedev = devNumber;
|
||||
source->sourcename = switch_core_strdup(source->pool, npath);
|
||||
@@ -436,8 +434,8 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||
/* dev already engaged */
|
||||
if (source) {
|
||||
|
||||
/*wait for source to be ready*/
|
||||
while(source->ready==0) {
|
||||
/*wait for source to be ready */
|
||||
while (source->ready == 0) {
|
||||
switch_yield(100000);
|
||||
}
|
||||
|
||||
@@ -596,7 +594,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_portaudio_stream_shutdown)
|
||||
globals.running = 0;
|
||||
switch_event_unbind_callback(shutdown_event_handler);
|
||||
|
||||
while(globals.threads > 0) {
|
||||
while (globals.threads > 0) {
|
||||
switch_yield(100000);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -43,7 +43,7 @@ struct shell_stream_context {
|
||||
int pid;
|
||||
char *command;
|
||||
switch_buffer_t *audio_buffer;
|
||||
switch_mutex_t *mutex;
|
||||
switch_mutex_t *mutex;
|
||||
switch_thread_rwlock_t *rwlock;
|
||||
int running;
|
||||
};
|
||||
@@ -63,15 +63,15 @@ static void *SWITCH_THREAD_FUNC buffer_thread_run(switch_thread_t *thread, void
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
while(context->running) {
|
||||
|
||||
|
||||
while (context->running) {
|
||||
|
||||
rlen = read(context->fds[0], data, MY_BUF_LEN);
|
||||
|
||||
if (rlen <= 3) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(context->mutex);
|
||||
switch_buffer_write(context->audio_buffer, data, rlen);
|
||||
switch_mutex_unlock(context->mutex);
|
||||
@@ -79,7 +79,7 @@ static void *SWITCH_THREAD_FUNC buffer_thread_run(switch_thread_t *thread, void
|
||||
|
||||
switch_thread_rwlock_unlock(context->rwlock);
|
||||
|
||||
end:
|
||||
end:
|
||||
|
||||
context->running = 0;
|
||||
|
||||
@@ -92,26 +92,26 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
|
||||
|
||||
if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
context = switch_core_alloc(handle->memory_pool, sizeof(*context));
|
||||
|
||||
|
||||
context->fds[0] = -1;
|
||||
context->fds[1] = -1;
|
||||
context->command = switch_core_sprintf(handle->memory_pool, "%s -r %d -c %d", path, handle->samplerate, handle->channels);
|
||||
|
||||
if (pipe(context->fds)) {
|
||||
goto error;
|
||||
} else { /* good to go*/
|
||||
} else { /* good to go */
|
||||
context->pid = fork();
|
||||
|
||||
if (context->pid < 0) { /* ok maybe not */
|
||||
|
||||
if (context->pid < 0) { /* ok maybe not */
|
||||
goto error;
|
||||
} else if (context->pid) { /* parent */
|
||||
} else if (context->pid) { /* parent */
|
||||
handle->private_info = context;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
close(context->fds[1]);
|
||||
@@ -124,19 +124,19 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons
|
||||
|
||||
switch_thread_rwlock_create(&context->rwlock, handle->memory_pool);
|
||||
switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
|
||||
|
||||
|
||||
switch_threadattr_create(&thd_attr, handle->memory_pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||
switch_thread_create(&thread, thd_attr, buffer_thread_run, context, handle->memory_pool);
|
||||
context->running = 2;
|
||||
|
||||
while(context->running == 2) {
|
||||
while (context->running == 2) {
|
||||
switch_cond_next();
|
||||
}
|
||||
|
||||
goto end;
|
||||
} else { /* child */
|
||||
} else { /* child */
|
||||
close(context->fds[0]);
|
||||
dup2(context->fds[1], STDOUT_FILENO);
|
||||
switch_system(context->command, SWITCH_TRUE);
|
||||
@@ -146,22 +146,22 @@ static switch_status_t shell_stream_file_open(switch_file_handle_t *handle, cons
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
error:
|
||||
|
||||
close(context->fds[0]);
|
||||
close(context->fds[1]);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
|
||||
|
||||
end:
|
||||
|
||||
|
||||
end:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t shell_stream_file_close(switch_file_handle_t *handle)
|
||||
{
|
||||
shell_stream_context_t *context = handle->private_info;
|
||||
|
||||
|
||||
context->running = 0;
|
||||
|
||||
if (context->fds[0] > -1) {
|
||||
@@ -184,10 +184,10 @@ static switch_status_t shell_stream_file_read(switch_file_handle_t *handle, void
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
switch_size_t rlen = *len * 2;
|
||||
|
||||
while(context->running && switch_buffer_inuse(context->audio_buffer) < rlen) {
|
||||
while (context->running && switch_buffer_inuse(context->audio_buffer) < rlen) {
|
||||
switch_cond_next();
|
||||
}
|
||||
|
||||
|
||||
switch_mutex_lock(context->mutex);
|
||||
*len = switch_buffer_read(context->audio_buffer, data, rlen) / 2;
|
||||
switch_mutex_unlock(context->mutex);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -55,12 +55,12 @@ static struct {
|
||||
uint32_t outscale;
|
||||
} globals;
|
||||
|
||||
mpg123_handle *our_mpg123_new(const char* decoder, int *error)
|
||||
mpg123_handle *our_mpg123_new(const char *decoder, int *error)
|
||||
{
|
||||
mpg123_handle *mh;
|
||||
const char *arch = "auto";
|
||||
int x64 = 0;
|
||||
|
||||
|
||||
if (*globals.decoder || globals.outscale || globals.vol) {
|
||||
if (*globals.decoder) {
|
||||
arch = globals.decoder;
|
||||
@@ -159,17 +159,17 @@ static inline void free_context(shout_context_t *context)
|
||||
mpg123_close(context->mh);
|
||||
mpg123_delete(context->mh);
|
||||
}
|
||||
|
||||
|
||||
if (context->fp) {
|
||||
unsigned char mp3buffer[8192];
|
||||
int len;
|
||||
int16_t blank[2048] = {0}, *r = NULL;
|
||||
|
||||
|
||||
int16_t blank[2048] = { 0 }, *r = NULL;
|
||||
|
||||
|
||||
if (context->channels == 2) {
|
||||
r = blank;
|
||||
}
|
||||
|
||||
|
||||
len = lame_encode_buffer(context->gfp, blank, r, sizeof(blank) / 2, mp3buffer, sizeof(mp3buffer));
|
||||
|
||||
if (len) {
|
||||
@@ -182,7 +182,7 @@ static inline void free_context(shout_context_t *context)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lame_mp3_tags_fid(context->gfp, context->fp);
|
||||
|
||||
fclose(context->fp);
|
||||
@@ -292,7 +292,7 @@ static void decode_fd(shout_context_t *context, void *data, size_t bytes)
|
||||
{
|
||||
int decode_status = 0;
|
||||
size_t usedlen;
|
||||
|
||||
|
||||
while (!context->err && !context->eof && switch_buffer_inuse(context->audio_buffer) < bytes) {
|
||||
usedlen = 0;
|
||||
|
||||
@@ -332,8 +332,8 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
shout_context_t *context = data;
|
||||
int decode_status = 0;
|
||||
size_t usedlen;
|
||||
uint32_t used, buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after
|
||||
first 64k buffer is dry */
|
||||
uint32_t used, buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after
|
||||
first 64k buffer is dry */
|
||||
|
||||
if (context->prebuf) {
|
||||
buf_size = context->prebuf;
|
||||
@@ -387,7 +387,7 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
if (context->err) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
return realsize;
|
||||
|
||||
error:
|
||||
@@ -405,7 +405,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
CURL *curl_handle = NULL;
|
||||
CURLcode cc;
|
||||
shout_context_t *context = (shout_context_t *) obj;
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(context->rwlock);
|
||||
|
||||
curl_handle = curl_easy_init();
|
||||
@@ -416,13 +416,14 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
|
||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) context);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "FreeSWITCH(mod_shout)/1.0");
|
||||
curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 30); /* eventually timeout connect */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_LIMIT, 100); /* handle trickle connections */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 30); /* eventually timeout connect */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_LIMIT, 100); /* handle trickle connections */
|
||||
curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_TIME, 30);
|
||||
curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, context->curl_error_buff);
|
||||
cc = curl_easy_perform(curl_handle);
|
||||
if (cc && cc != CURLE_WRITE_ERROR) { /* write error is ok, we just exited from callback early */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "CURL returned error:[%d] %s : %s [%s]\n", cc, curl_easy_strerror(cc), context->curl_error_buff, context->stream_url);
|
||||
if (cc && cc != CURLE_WRITE_ERROR) { /* write error is ok, we just exited from callback early */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "CURL returned error:[%d] %s : %s [%s]\n", cc, curl_easy_strerror(cc),
|
||||
context->curl_error_buff, context->stream_url);
|
||||
}
|
||||
curl_easy_cleanup(curl_handle);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read Thread Done\n");
|
||||
@@ -453,7 +454,7 @@ static void launch_read_stream_thread(shout_context_t *context)
|
||||
switch_mutex_unlock(context->audio_mutex);
|
||||
|
||||
if (used >= (2 * context->samplerate)) {
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
switch_yield(500000);
|
||||
@@ -566,7 +567,8 @@ static void launch_write_stream_thread(shout_context_t *context)
|
||||
|
||||
while (context->thread_running && context->thread_running != 2) {
|
||||
switch_yield(100000);
|
||||
if (!--sanity) break;
|
||||
if (!--sanity)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,9 +592,9 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
|
||||
context->memory_pool = handle->memory_pool;
|
||||
context->samplerate = handle->samplerate;
|
||||
context->handle = handle;
|
||||
|
||||
|
||||
switch_thread_rwlock_create(&(context->rwlock), context->memory_pool);
|
||||
|
||||
|
||||
switch_thread_rwlock_rdlock(context->rwlock);
|
||||
|
||||
switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
|
||||
@@ -605,10 +607,10 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
|
||||
|
||||
context->mh = our_mpg123_new(NULL, NULL);
|
||||
mpg123_format_all(context->mh);
|
||||
mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0);
|
||||
mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0);
|
||||
|
||||
if (handle->handler) {
|
||||
mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER|MPG123_MONO_MIX, 0);
|
||||
mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_MONO_MIX, 0);
|
||||
if (mpg123_open_feed(context->mh) != MPG123_OK) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening mpg feed\n");
|
||||
goto error;
|
||||
@@ -800,7 +802,7 @@ static switch_status_t shout_file_seek(switch_file_handle_t *handle, unsigned in
|
||||
}
|
||||
|
||||
switch_buffer_zero(context->audio_buffer);
|
||||
*cur_sample = mpg123_seek (context->mh, (off_t)samples, whence);
|
||||
*cur_sample = mpg123_seek(context->mh, (off_t) samples, whence);
|
||||
|
||||
return *cur_sample >= 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||
}
|
||||
@@ -827,9 +829,9 @@ static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data,
|
||||
if (!rb && (context->eof || context->err)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rb: %d, bytes: %d\n", (int) rb, (int) bytes); */
|
||||
|
||||
|
||||
if (rb) {
|
||||
*len = rb / sizeof(int16_t);
|
||||
} else {
|
||||
@@ -839,7 +841,7 @@ static switch_status_t shout_file_read(switch_file_handle_t *handle, void *data,
|
||||
bytes = newbytes;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with 1s of empty audio. (%s)\n", context->stream_url);
|
||||
|
||||
|
||||
memset(data, 255, bytes);
|
||||
*len = bytes / sizeof(int16_t);
|
||||
}
|
||||
@@ -918,18 +920,18 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data
|
||||
|
||||
if (handle->channels == 2) {
|
||||
switch_size_t i, j = 0;
|
||||
|
||||
|
||||
if (context->llen < nsamples) {
|
||||
context->l = switch_core_alloc(context->memory_pool, nsamples * 2);
|
||||
context->r = switch_core_alloc(context->memory_pool, nsamples * 2);
|
||||
context->llen = context->rlen = nsamples;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < nsamples; i++) {
|
||||
context->l[i] = audio[j++];
|
||||
context->r[i] = audio[j++];
|
||||
}
|
||||
|
||||
|
||||
if ((rlen = lame_encode_buffer(context->gfp, context->l, context->r, nsamples, context->mp3buf, context->mp3buflen)) < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
@@ -1130,7 +1132,7 @@ void do_telecast(switch_stream_handle_t *stream)
|
||||
switch_mutex_t *mutex;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(tsession);
|
||||
lame_global_flags *gfp = NULL;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_codec_implementation_t read_impl = { 0 };
|
||||
switch_core_session_get_read_impl(tsession, &read_impl);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
|
||||
@@ -1322,7 +1324,7 @@ void do_broadcast(switch_stream_handle_t *stream)
|
||||
|
||||
void do_index(switch_stream_handle_t *stream)
|
||||
{
|
||||
switch_cache_db_handle_t *db;
|
||||
switch_cache_db_handle_t *db;
|
||||
const char *sql = "select * from channels";
|
||||
struct holder holder;
|
||||
char *errmsg;
|
||||
@@ -1407,7 +1409,7 @@ static switch_status_t load_config(void)
|
||||
switch_xml_t cfg, xml, settings, param;
|
||||
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
|
||||
|
||||
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 SWITCH_STATUS_TERM;
|
||||
@@ -1417,11 +1419,11 @@ static switch_status_t load_config(void)
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
|
||||
|
||||
if (!strcmp(var, "decoder")) {
|
||||
switch_set_string(globals.decoder, val);
|
||||
} else if (!strcmp(var, "volume")) {
|
||||
globals.vol = (float)atof(val);
|
||||
globals.vol = (float) atof(val);
|
||||
} else if (!strcmp(var, "outscale")) {
|
||||
int tmp = atoi(val);
|
||||
if (tmp > 0) {
|
||||
@@ -1430,7 +1432,7 @@ static switch_status_t load_config(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch_xml_free(xml);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -64,7 +64,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
char *alt_path = NULL, *last, *ldup = NULL;
|
||||
size_t alt_len = 0;
|
||||
int rates[4] = {8000, 16000, 32000, 48000};
|
||||
int rates[4] = { 8000, 16000, 32000, 48000 };
|
||||
int i;
|
||||
#ifdef WIN32
|
||||
char ps = '\\';
|
||||
@@ -161,12 +161,12 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
/* This block attempts to add the sample rate to the path
|
||||
if the sample rate is already present in the path it does nothing
|
||||
and reverts to the original file name.
|
||||
*/
|
||||
*/
|
||||
if ((last = strrchr(alt_path, ps))) {
|
||||
last++;
|
||||
#ifdef WIN32
|
||||
if (strrchr(last, '/')) {
|
||||
last = strrchr(alt_path, '/'); /* do not swallow a forward slash if they are intermixed under windows*/
|
||||
last = strrchr(alt_path, '/'); /* do not swallow a forward slash if they are intermixed under windows */
|
||||
last++;
|
||||
}
|
||||
#endif
|
||||
@@ -178,7 +178,7 @@ static switch_status_t sndfile_file_open(switch_file_handle_t *handle, const cha
|
||||
} else {
|
||||
/* Try to find the file at the highest rate possible if we can't find one that matches the exact rate.
|
||||
If we don't find any, we will default back to the original file name.
|
||||
*/
|
||||
*/
|
||||
for (i = 3; i >= 0; i--) {
|
||||
switch_snprintf(last, alt_len - (last - alt_path), "%d%s%s", rates[i], SWITCH_PATH_SEPARATOR, ldup);
|
||||
if ((context->handle = sf_open(alt_path, mode, &context->sfinfo))) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
@@ -58,7 +58,7 @@ static switch_status_t silence_stream_file_open(switch_file_handle_t *handle, co
|
||||
sh->samples = 0;
|
||||
sh->forever = 1;
|
||||
}
|
||||
|
||||
|
||||
if ((p = strchr(path, ','))) {
|
||||
p++;
|
||||
ms = atoi(p);
|
||||
@@ -80,19 +80,19 @@ static switch_status_t silence_stream_file_close(switch_file_handle_t *handle)
|
||||
static switch_status_t silence_stream_file_read(switch_file_handle_t *handle, void *data, size_t *len)
|
||||
{
|
||||
struct silence_handle *sh = handle->private_info;
|
||||
|
||||
|
||||
if (!sh->forever) {
|
||||
if (sh->samples <= 0) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (*len > (size_t)sh->samples) {
|
||||
if (*len > (size_t) sh->samples) {
|
||||
*len = sh->samples;
|
||||
}
|
||||
|
||||
sh->samples -= *len;
|
||||
}
|
||||
|
||||
|
||||
if (sh->silence) {
|
||||
switch_generate_sln_silence((int16_t *) data, *len, sh->silence);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user