From d84a8f8c1b3348372fef2c1da743af0cbaefd2d8 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 11 Jun 2012 12:36:38 -0700 Subject: audio: workaround for hdmi multi channel swap Workaround for HDMI multi channel channel swap on first playback after opening the output stream: force re-opening the HDMI pcm driver after writing a few periods. Bug 4282214. Change-Id: Ibe1452a8905a27bc3f95564a45cfb9bb490b65ae --- audio/audio_hw.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'audio') diff --git a/audio/audio_hw.c b/audio/audio_hw.c index fb5a423..85cfc7b 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -680,6 +680,10 @@ struct tuna_stream_out { audio_channel_mask_t channel_mask; audio_channel_mask_t sup_channel_masks[3]; + /* FIXME: workaround for HDMI multi channel channel swap on first playback after opening + * the output stream: force reopening the pcm driver after writing a few periods. */ + int restart_periods_cnt; + struct tuna_audio_device *dev; }; @@ -2123,6 +2127,11 @@ exit: usleep(bytes * 1000000 / audio_stream_frame_size(&stream->common) / out_get_sample_rate_hdmi(&stream->common)); } + /* FIXME: workaround for HDMI multi channel channel swap on first playback after opening + * the output stream: force reopening the pcm driver after writing a few periods. */ + if ((out->restart_periods_cnt > 0) && + (--out->restart_periods_cnt == 0)) + out_standby(&stream->common); return bytes; } @@ -3232,6 +3241,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev, out->config[PCM_HDMI] = pcm_config_hdmi_multi; out->config[PCM_HDMI].rate = config->sample_rate; out->config[PCM_HDMI].channels = popcount(config->channel_mask); + /* FIXME: workaround for channel swap on first playback after opening the output */ + out->restart_periods_cnt = out->config[PCM_HDMI].period_count * 2; } else if (flags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) { ALOGV("adev_open_output_stream() deep buffer"); if (ladev->outputs[OUTPUT_DEEP_BUF] != NULL) { -- cgit v1.1