mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-29 14:44:17 +00:00
[core] add audio channels limit when opening files, configurable through switch.conf.xml (param "max-audio-channels"), add unit-test.
This commit is contained in:
1 parent
e94d8cfdfc
commit
c1b66f650f
7 files changed
+71
-1
No files matched your search
@@ -76,6 +76,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
||||
char *fp = NULL;
|
||||
int to = 0;
|
||||
int force_channels = 0;
|
||||
uint32_t core_channel_limit;
|
||||
|
||||
if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n");
|
||||
@@ -361,6 +362,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fh->channels > 2) {
|
||||
/* just show a warning for more than 2 channels, no matter if we allow them or not */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File [%s] has more than 2 channels: [%u]\n", file_path, fh->channels);
|
||||
}
|
||||
|
||||
core_channel_limit = switch_core_max_audio_channels(0);
|
||||
if (core_channel_limit && fh->channels > core_channel_limit) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File [%s] has more channels (%u) than limit (%u). Closing.\n", file_path, fh->channels, core_channel_limit);
|
||||
fh->file_interface->file_close(fh);
|
||||
UNPROTECT_INTERFACE(fh->file_interface);
|
||||
switch_goto_status(SWITCH_STATUS_FALSE, fail);
|
||||
}
|
||||
|
||||
if (!force_channels && !fh->real_channels) {
|
||||
fh->real_channels = fh->channels;
|
||||
|
||||
|
||||
Reference in new issue
Block a user