mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-04 09:44:26 +00:00
fix pa play bug
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16188 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a4b094ddc5
commit
2d015e2644
@ -2010,6 +2010,7 @@ SWITCH_STANDARD_API(pa_cmd)
|
|||||||
char *playfile = NULL;
|
char *playfile = NULL;
|
||||||
int samples = 0;
|
int samples = 0;
|
||||||
int seconds = 5;
|
int seconds = 5;
|
||||||
|
int wrote = 0;
|
||||||
|
|
||||||
if (globals.call_list) {
|
if (globals.call_list) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
|
||||||
@ -2034,27 +2035,32 @@ SWITCH_STANDARD_API(pa_cmd)
|
|||||||
|
|
||||||
if (argv[2]) {
|
if (argv[2]) {
|
||||||
int i = atoi(argv[2]);
|
int i = atoi(argv[2]);
|
||||||
if (i > 0) {
|
if (i >= 0) {
|
||||||
seconds = i;
|
seconds = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
samples = globals.read_codec.implementation->actual_samples_per_second * seconds;
|
samples = globals.read_codec.implementation->actual_samples_per_second * seconds;
|
||||||
stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",
|
|
||||||
playfile, seconds, samples, globals.read_codec.implementation->actual_samples_per_second);
|
|
||||||
|
|
||||||
while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) {
|
while (switch_core_file_read(&fh, abuf, &olen) == SWITCH_STATUS_SUCCESS) {
|
||||||
WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.read_timer);
|
WriteAudioStream(globals.audio_stream, abuf, (long) olen, &globals.read_timer);
|
||||||
switch_core_timer_next(&globals.read_timer);
|
wrote += (int) olen;
|
||||||
|
if (samples) {
|
||||||
samples -= (int) olen;
|
samples -= (int) olen;
|
||||||
if (samples <= 0) {
|
if (samples <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
olen = globals.read_codec.implementation->samples_per_packet;
|
olen = globals.read_codec.implementation->samples_per_packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_file_close(&fh);
|
switch_core_file_close(&fh);
|
||||||
deactivate_audio_device();
|
deactivate_audio_device();
|
||||||
|
|
||||||
|
seconds = wrote / globals.read_codec.implementation->actual_samples_per_second;
|
||||||
|
stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",
|
||||||
|
playfile, seconds, wrote, globals.read_codec.implementation->actual_samples_per_second);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "Cannot play requested file %s\n", argv[1]);
|
stream->write_function(stream, "Cannot play requested file %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user