summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7af2b02)
raw | patch | inline | side by side (parent: 7af2b02)
author | Sergii Iegorov <x0155539@ti.com> | |
Thu, 28 Mar 2013 13:10:05 +0000 (15:10 +0200) | ||
committer | Sergii Iegorov <x0155539@ti.com> | |
Thu, 28 Mar 2013 13:10:05 +0000 (15:10 +0200) |
In the case of USB input device doesn't support default input
parameters, i.e. 48kHz and 1 channel - that tries to open
the input with all possible sets of sample rates and channels
numbers. If none of them succeeds, the input won't be created.
Change-Id: Ie341e7b6d1a3efa5a9405db1a91084549defd325
Signed-off-by: Sergii Iegorov <x0155539@ti.com>
parameters, i.e. 48kHz and 1 channel - that tries to open
the input with all possible sets of sample rates and channels
numbers. If none of them succeeds, the input won't be created.
Change-Id: Ie341e7b6d1a3efa5a9405db1a91084549defd325
Signed-off-by: Sergii Iegorov <x0155539@ti.com>
audio/audio_hw.c | patch | blob | history |
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 2a7bc239de9858bc720fbade6eaa4a8830f65b45..56c07e465952a9ada365de49bcd031008d208465 100644 (file)
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
/* sampling rate when using VX port for wide band */
#define VX_WB_SAMPLING_RATE 16000
+#define SAMPLE_RATE_8000 8000
+#define SAMPLE_RATE_11025 11025
+
/* conversions from dB to ABE and codec gains */
#define DB_TO_ABE_GAIN(x) ((x) + MIXER_ABE_GAIN_0DB)
#define DB_TO_CAPTURE_PREAMPLIFIER_VOLUME(x) (((x) + 6) / 6)
goto err;
}
+ if (devices & (AUDIO_DEVICE_IN_USB_HEADSET & ~AUDIO_DEVICE_BIT_IN)) {
+ in->dev = ladev;
+ in->device = devices;
+
+ pthread_mutex_lock(&ladev->lock);
+ pthread_mutex_lock(&in->lock);
+
+ ret = start_input_stream(in);
+ if (ret == 0) {
+ do_input_standby(in);
+ } else {
+ int channels_tmp;
+ for (channels_tmp = 1; channels_tmp <= 2; channels_tmp++) {
+ in->config.channels = channels_tmp;
+ int rate_multiplier;
+ for (rate_multiplier = 4; rate_multiplier > 0; rate_multiplier >>= 1) {
+ in->config.rate = rate_multiplier * SAMPLE_RATE_11025;
+ ret = start_input_stream(in);
+ if (ret != 0) {
+ in->config.rate = rate_multiplier * SAMPLE_RATE_8000;
+ ret = start_input_stream(in);
+ }
+ if (ret == 0) {
+ do_input_standby(in);
+ ALOGV("input was opened with rate = %d, channels = %d",
+ in->config.rate, in->config.channels);
+ break;
+ }
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&ladev->lock);
+ pthread_mutex_unlock(&in->lock);
+ if (ret != 0) {
+ goto err;
+ }
+ }
+
if (in->requested_rate != in->config.rate) {
in->buf_provider.get_next_buffer = get_next_buffer;
in->buf_provider.release_buffer = release_buffer;