summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/SpdifStreamOut.cpp
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2015-07-14 09:42:29 -0700
committerLajos Molnar <lajos@google.com>2015-07-17 20:56:04 +0000
commitca5e6143740299c877d69e97f7968cd04476d32c (patch)
tree50101b57406c5abce066ec90120d91d3dfd0152b /services/audioflinger/SpdifStreamOut.cpp
parentbc24bb8a552097e7975d0c16fad80158b542ba62 (diff)
downloadframeworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.zip
frameworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.tar.gz
frameworks_av-ca5e6143740299c877d69e97f7968cd04476d32c.tar.bz2
AudioFlinger: fix repeated underruns for compressed audio
The AudioFlinger kept pausing the audio when playing compressed AC3 or DTS. This caused pause/resume loops that were hard to break out of. The AudioFlinger was thinking that the compressed audio was PCM because the HAL was in PCM mode playing SPDIF data bursts. It also thought that EAC3 was at 192000 Hz instead of 48000 Hz because the data bursts are played at a higher rate. This CL adds more calls to the shim that separates the AudioFlinger. Now the AudioFlinger gets information about the HAL sample rate, channel masks and format from the shim instead of calling the HAL directly. The AudioFlinger now uses a different threshold for detecting underruns when the audio is compressed. Bug: 19938315 Bug: 20891646 Change-Id: Ib16f539346d1c7a273ea4feb3d3afcc3dc60237d Signed-off-by: Phil Burk <philburk@google.com>
Diffstat (limited to 'services/audioflinger/SpdifStreamOut.cpp')
-rw-r--r--services/audioflinger/SpdifStreamOut.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/services/audioflinger/SpdifStreamOut.cpp b/services/audioflinger/SpdifStreamOut.cpp
index 6af7bce..6b6f5db 100644
--- a/services/audioflinger/SpdifStreamOut.cpp
+++ b/services/audioflinger/SpdifStreamOut.cpp
@@ -37,6 +37,9 @@ SpdifStreamOut::SpdifStreamOut(AudioHwDevice *dev,
audio_format_t format)
: AudioStreamOut(dev,flags)
, mSpdifEncoder(this, format)
+ , mApplicationFormat(AUDIO_FORMAT_DEFAULT)
+ , mApplicationSampleRate(0)
+ , mApplicationChannelMask(0)
{
}
@@ -48,6 +51,10 @@ status_t SpdifStreamOut::open(
{
struct audio_config customConfig = *config;
+ mApplicationFormat = config->format;
+ mApplicationSampleRate = config->sample_rate;
+ mApplicationChannelMask = config->channel_mask;
+
// Some data bursts run at a higher sample rate.
// TODO Move this into the audio_utils as a static method.
switch(config->format) {
@@ -106,20 +113,15 @@ int SpdifStreamOut::standby()
return AudioStreamOut::standby();
}
-size_t SpdifStreamOut::getFrameSize()
-{
- return sizeof(int8_t);
-}
-
ssize_t SpdifStreamOut::writeDataBurst(const void* buffer, size_t bytes)
{
return AudioStreamOut::write(buffer, bytes);
}
-ssize_t SpdifStreamOut::write(const void* buffer, size_t bytes)
+ssize_t SpdifStreamOut::write(const void* buffer, size_t numBytes)
{
// Write to SPDIF wrapper. It will call back to writeDataBurst().
- return mSpdifEncoder.write(buffer, bytes);
+ return mSpdifEncoder.write(buffer, numBytes);
}
} // namespace android