code before decl and whitespace
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15795 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
10db68adce
commit
d1be73ed83
|
@ -374,10 +374,7 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
uint32_t rate = PREFERRED_RATE;
|
uint32_t rate = PREFERRED_RATE;
|
||||||
char *npath ;
|
char *npath ;
|
||||||
int devNumber;
|
int devNumber;
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handle->pre_buffer_datalen = 0;
|
handle->pre_buffer_datalen = 0;
|
||||||
|
|
||||||
|
@ -388,7 +385,7 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
|
|
||||||
npath = switch_core_strdup(module_pool, path);
|
npath = switch_core_strdup(module_pool, path);
|
||||||
|
|
||||||
int tmp = handle->samplerate;
|
tmp = handle->samplerate;
|
||||||
if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
|
if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
|
||||||
rate = tmp;
|
rate = tmp;
|
||||||
}
|
}
|
||||||
|
@ -400,8 +397,6 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
}
|
}
|
||||||
npath = switch_mprintf("device-%d at %d",devNumber,rate);
|
npath = switch_mprintf("device-%d at %d",devNumber,rate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_lock(globals.mutex);
|
switch_mutex_lock(globals.mutex);
|
||||||
source = switch_core_hash_find(globals.source_hash, npath);
|
source = switch_core_hash_find(globals.source_hash, npath);
|
||||||
|
|
||||||
|
@ -426,22 +421,15 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
source->ready = 0;
|
source->ready = 0;
|
||||||
source->samples = switch_samples_per_packet(source->rate, source->interval);
|
source->samples = switch_samples_per_packet(source->rate, source->interval);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);
|
switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch_threadattr_create(&thd_attr, source->pool);
|
switch_threadattr_create(&thd_attr, source->pool);
|
||||||
switch_threadattr_detach_set(thd_attr, 1);
|
switch_threadattr_detach_set(thd_attr, 1);
|
||||||
|
|
||||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
|
||||||
switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);
|
switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(globals.mutex);
|
switch_mutex_unlock(globals.mutex);
|
||||||
switch_yield(1000000);
|
switch_yield(1000000);
|
||||||
|
@ -449,19 +437,16 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
if (source) {
|
if (source) {
|
||||||
|
|
||||||
/*wait for source to be ready*/
|
/*wait for source to be ready*/
|
||||||
|
while(source->ready==0) {
|
||||||
while(source->ready==0){switch_yield(100000);}
|
switch_yield(100000);
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_thread_rwlock_tryrdlock(source->rwlock) != SWITCH_STATUS_SUCCESS) {
|
if (switch_thread_rwlock_tryrdlock(source->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " error rwlock !\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, " error rwlock !\n");
|
||||||
source = NULL;
|
source = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -480,7 +465,6 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
handle->private_info = context;
|
handle->private_info = context;
|
||||||
handle->interval = source->interval;
|
handle->interval = source->interval;
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
|
switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
|
||||||
if (switch_buffer_create_dynamic(&context->audio_buffer, 512, 1024, 0) != SWITCH_STATUS_SUCCESS) {
|
if (switch_buffer_create_dynamic(&context->audio_buffer, 512, 1024, 0) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
||||||
|
@ -497,7 +481,6 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
source->context_list = context;
|
source->context_list = context;
|
||||||
source->total++;
|
source->total++;
|
||||||
switch_mutex_unlock(source->mutex);
|
switch_mutex_unlock(source->mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -505,8 +488,6 @@ static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle,
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,8 +525,6 @@ static switch_status_t portaudio_stream_file_read(switch_file_handle_t *handle,
|
||||||
int bytesPerSample = context->source->audio_stream->bytesPerFrame;
|
int bytesPerSample = context->source->audio_stream->bytesPerFrame;
|
||||||
size_t need = *len * bytesPerSample;
|
size_t need = *len * bytesPerSample;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!context->source->ready) {
|
if (!context->source->ready) {
|
||||||
*len = 0;
|
*len = 0;
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue