summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-04-04 09:27:52 -0700
committerEric Laurent <elaurent@google.com>2013-04-04 09:59:42 -0700
commit85bc970188265ae38c495a49909cdf96b20d50d3 (patch)
tree3cb6cdf5147a7bafb0cce16d0ccb2b0bc728c517 /audio
parent6f870cfff81fe664b7c0d0ee7b5557550dbab2ca (diff)
downloaddevice_samsung_tuna-85bc970188265ae38c495a49909cdf96b20d50d3.zip
device_samsung_tuna-85bc970188265ae38c495a49909cdf96b20d50d3.tar.gz
device_samsung_tuna-85bc970188265ae38c495a49909cdf96b20d50d3.tar.bz2
audio: implement mute on hdmi multichannel
On direct output streams the audio HAL must implement the volume function. In the case of HDMI the only function required is to mute audio when volume is 0 as volume is defined as fixed on digital output streams. Bug 8541062 Change-Id: I4b4e28a910e7b321b3a68567e9ad03fede065ca8
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index c5f1867..6f14e1e 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -691,6 +691,7 @@ struct tuna_stream_out {
/* 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;
+ bool muted;
struct tuna_audio_device *dev;
};
@@ -1918,6 +1919,16 @@ static int out_set_volume(struct audio_stream_out *stream, float left,
return -ENOSYS;
}
+static int out_set_volume_hdmi(struct audio_stream_out *stream, float left,
+ float right)
+{
+ struct tuna_stream_out *out = (struct tuna_stream_out *)stream;
+
+ /* only take left channel into account: the API is for stereo anyway */
+ out->muted = (left == 0.0f);
+ return 0;
+}
+
static ssize_t out_write_low_latency(struct audio_stream_out *stream, const void* buffer,
size_t bytes)
{
@@ -2127,6 +2138,9 @@ static ssize_t out_write_hdmi(struct audio_stream_out *stream, const void* buffe
}
pthread_mutex_unlock(&adev->lock);
+ if (out->muted)
+ memset((void *)buffer, 0, bytes);
+
ret = pcm_write(out->pcm[PCM_HDMI],
buffer,
pcm_frames_to_bytes(out->pcm[PCM_HDMI], in_frames));
@@ -3248,6 +3262,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.common.get_sample_rate = out_get_sample_rate_hdmi;
out->stream.get_latency = out_get_latency_hdmi;
out->stream.write = out_write_hdmi;
+ out->stream.set_volume = out_set_volume_hdmi;
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);
@@ -3265,6 +3280,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.common.get_sample_rate = out_get_sample_rate;
out->stream.get_latency = out_get_latency_deep_buffer;
out->stream.write = out_write_deep_buffer;
+ out->stream.set_volume = out_set_volume;
} else {
ALOGV("adev_open_output_stream() normal buffer");
if (ladev->outputs[OUTPUT_LOW_LATENCY] != NULL) {
@@ -3276,6 +3292,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.common.get_sample_rate = out_get_sample_rate;
out->stream.get_latency = out_get_latency_low_latency;
out->stream.write = out_write_low_latency;
+ out->stream.set_volume = out_set_volume;
}
ret = create_resampler(DEFAULT_OUT_SAMPLING_RATE,
@@ -3297,11 +3314,11 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->stream.common.get_parameters = out_get_parameters;
out->stream.common.add_audio_effect = out_add_audio_effect;
out->stream.common.remove_audio_effect = out_remove_audio_effect;
- out->stream.set_volume = out_set_volume;
out->stream.get_render_position = out_get_render_position;
out->dev = ladev;
out->standby = 1;
+ /* out->muted = false; by calloc() */
/* FIXME: when we support multiple output devices, we will want to
* do the following: