tweaks to file buffering

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4575 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-03-12 20:17:34 +00:00
parent 82be2101db
commit 78c058423b
4 changed files with 18 additions and 7 deletions

View File

@ -730,7 +730,8 @@ SWITCH_FILE_DATA_FLOAT = (1 << 5) - Read data in floats
SWITCH_FILE_DATA_DOUBLE = (1 << 6) - Read data in doubles
SWITCH_FILE_DATA_RAW = (1 << 7) - Read data as is
SWITCH_FILE_PAUSE = (1 << 8) - Pause
SWITCH_FILE_NATIVE = (1 << 8) - File is in native format (no transcoding)
SWITCH_FILE_NATIVE = (1 << 9) - File is in native format (no transcoding)
SWITCH_FILE_SEEK = (1 << 10) - File has done a seek
</pre>
*/
typedef enum {
@ -743,7 +744,8 @@ typedef enum {
SWITCH_FILE_DATA_DOUBLE = (1 << 6),
SWITCH_FILE_DATA_RAW = (1 << 7),
SWITCH_FILE_PAUSE = (1 << 8),
SWITCH_FILE_NATIVE = (1 << 9)
SWITCH_FILE_NATIVE = (1 << 9),
SWITCH_FILE_SEEK = (1 << 10)
} switch_file_flag_t;
typedef enum {

View File

@ -432,7 +432,8 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_state(switch_channel_t
SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel)
{
assert(channel != NULL);
return (channel->state > CS_RING && channel->state < CS_HANGUP && !switch_test_flag(channel, CF_TRANSFER)) ? 1 : 0;
return (!channel->hangup_cause && channel->state > CS_RING && channel->state < CS_HANGUP && !switch_test_flag(channel, CF_TRANSFER)) ? 1 : 0;
}
static const char *state_names[] = {
@ -1059,7 +1060,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
assert(channel != NULL);
if (channel->state >= CS_HANGUP) {
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
@ -1093,7 +1094,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
assert(channel != NULL);
if (channel->state >= CS_HANGUP) {
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
@ -1127,7 +1128,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
assert(channel != NULL);
if (channel->state >= CS_HANGUP) {
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}
@ -1169,7 +1170,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
{
assert(channel != NULL);
if (channel->state >= CS_HANGUP) {
if (channel->hangup_cause || channel->state >= CS_HANGUP) {
return SWITCH_STATUS_FALSE;
}

View File

@ -1070,6 +1070,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_seek(switch_file_handle_t *fh,
int whence)
{
assert(fh != NULL);
switch_set_flag(fh, SWITCH_FILE_SEEK);
return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
}

View File

@ -1377,6 +1377,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
switch_buffer_zero(fh->audio_buffer);
}
if (switch_test_flag(fh, SWITCH_FILE_SEEK)) {
/* file position has changed flush the buffer */
switch_buffer_zero(fh->audio_buffer);
switch_clear_flag(fh, SWITCH_FILE_SEEK);
}
if (!asis && fh->speed && do_speed) {
float factor = 0.25f * abs(fh->speed);