summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChinyue Chen <chinyue@google.com>2017-05-09 17:52:58 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-12 03:25:35 -0700
commit3615ecbae09a43a52ddc716a0c038729fe24f5fd (patch)
tree10c216a3c02e8d226abf633687955b4a5386fdf6
parent5082f2462775c1e215d187496cc8fda3058ddd86 (diff)
downloadadhd-3615ecbae09a43a52ddc716a0c038729fe24f5fd.tar.gz
CRAS: iodev - Skip update_channel_layout for 2-channel output.
If the requested channel count when opening an output device <= 2 then we can skip the update channel layout call and reduce the time spent to init a device. BUG=chromium:719812 TEST=Tested on reef. Change-Id: I46cba552751440a2043b0778b8b22a51a6113e3e Reviewed-on: https://chromium-review.googlesource.com/499910 Commit-Ready: Chinyue Chen <chinyue@chromium.org> Tested-by: Chinyue Chen <chinyue@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org>
-rw-r--r--cras/src/server/cras_iodev.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/cras/src/server/cras_iodev.c b/cras/src/server/cras_iodev.c
index 1733cb02..69e65dbf 100644
--- a/cras/src/server/cras_iodev.c
+++ b/cras/src/server/cras_iodev.c
@@ -324,10 +324,8 @@ static snd_pcm_format_t get_best_pcm_format(struct cras_iodev *iodev,
return iodev->supported_formats[0];
}
-/* Set default channel count and layout to an iodev.
- * iodev->format->num_channels is from get_best_channel_count.
- */
-static void set_default_channel_count_layout(struct cras_iodev *iodev)
+/* Set default channel layout to an iodev. */
+static void set_default_channel_layout(struct cras_iodev *iodev)
{
int8_t default_layout[CRAS_CH_MAX];
size_t i;
@@ -335,7 +333,6 @@ static void set_default_channel_count_layout(struct cras_iodev *iodev)
for (i = 0; i < CRAS_CH_MAX; i++)
default_layout[i] = i < iodev->format->num_channels ? i : -1;
- iodev->ext_format->num_channels = iodev->format->num_channels;
cras_audio_format_set_channel_layout(iodev->format, default_layout);
cras_audio_format_set_channel_layout(iodev->ext_format, default_layout);
}
@@ -401,12 +398,25 @@ static inline void adjust_dev_channel_for_dsp(const struct cras_iodev *iodev)
static void update_channel_layout(struct cras_iodev *iodev)
{
int rc;
+
+ /*
+ * Output devices like internal speakers and headphones are 2-channel
+ * and do not need to update channel layout.
+ * For HDMI and USB devices that might have more than 2 channels, update
+ * channel layout only if more than 2 channel is requested.
+ */
+ if (iodev->direction == CRAS_STREAM_OUTPUT &&
+ iodev->format->num_channels <= 2) {
+ set_default_channel_layout(iodev);
+ return;
+ }
+
if (iodev->update_channel_layout == NULL)
return;
rc = iodev->update_channel_layout(iodev);
if (rc < 0) {
- set_default_channel_count_layout(iodev);
+ set_default_channel_layout(iodev);
} else {
cras_audio_format_set_channel_layout(
iodev->ext_format,