summaryrefslogtreecommitdiffstats
path: root/alsa_utils/alsa_device_proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'alsa_utils/alsa_device_proxy.c')
-rw-r--r--alsa_utils/alsa_device_proxy.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/alsa_utils/alsa_device_proxy.c b/alsa_utils/alsa_device_proxy.c
index 9236a9b4..9b06d16f 100644
--- a/alsa_utils/alsa_device_proxy.c
+++ b/alsa_utils/alsa_device_proxy.c
@@ -39,9 +39,11 @@ static const unsigned format_byte_size_map[] = {
3, /* PCM_FORMAT_S24_3LE */
};
-void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile,
+int proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile,
struct pcm_config * config)
{
+ int ret = 0;
+
ALOGV("proxy_prepare(c:%d, d:%d)", profile->card, profile->device);
proxy->profile = profile;
@@ -53,17 +55,25 @@ void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile,
if (config->format != PCM_FORMAT_INVALID && profile_is_format_valid(profile, config->format)) {
proxy->alsa_config.format = config->format;
} else {
+ proxy->alsa_config.format = profile->default_config.format;
ALOGW("Invalid format %d - using default %d.",
config->format, profile->default_config.format);
- proxy->alsa_config.format = profile->default_config.format;
+ // Indicate override when default format was not requested
+ if (config->format != PCM_FORMAT_INVALID) {
+ ret = -EINVAL;
+ }
}
if (config->rate != 0 && profile_is_sample_rate_valid(profile, config->rate)) {
proxy->alsa_config.rate = config->rate;
} else {
+ proxy->alsa_config.rate = profile->default_config.rate;
ALOGW("Invalid sample rate %u - using default %u.",
config->rate, profile->default_config.rate);
- proxy->alsa_config.rate = profile->default_config.rate;
+ // Indicate override when default rate was not requested
+ if (config->rate != 0) {
+ ret = -EINVAL;
+ }
}
if (config->channels != 0 && profile_is_channel_count_valid(profile, config->channels)) {
@@ -72,6 +82,10 @@ void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile,
proxy->alsa_config.channels = profile_get_closest_channel_count(profile, config->channels);
ALOGW("Invalid channel count %u - using closest %u.",
config->channels, proxy->alsa_config.channels);
+ // Indicate override when default channel count was not requested
+ if (config->channels != 0) {
+ ret = -EINVAL;
+ }
}
proxy->alsa_config.period_count = profile->default_config.period_count;
@@ -98,8 +112,14 @@ void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile* profile,
// us the highest working rate
int max_rate_index = proxy_scan_rates(proxy, profile->sample_rates);
if (max_rate_index >= 0) {
- proxy->alsa_config.rate = profile->sample_rates[max_rate_index];
+ if (proxy->alsa_config.rate > profile->sample_rates[max_rate_index]) {
+ ALOGW("Limiting samplnig rate from %u to %u.",
+ proxy->alsa_config.rate, profile->sample_rates[max_rate_index]);
+ proxy->alsa_config.rate = profile->sample_rates[max_rate_index];
+ ret = -EINVAL;
+ }
}
+ return ret;
}
int proxy_open(alsa_device_proxy * proxy)