summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/SpdifStreamOut.h
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.h
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.h')
-rw-r--r--services/audioflinger/SpdifStreamOut.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/services/audioflinger/SpdifStreamOut.h b/services/audioflinger/SpdifStreamOut.h
index a61a7bd..c870250 100644
--- a/services/audioflinger/SpdifStreamOut.h
+++ b/services/audioflinger/SpdifStreamOut.h
@@ -64,7 +64,27 @@ public:
*/
virtual ssize_t write(const void* buffer, size_t bytes);
- virtual size_t getFrameSize();
+ /**
+ * @return frame size from the perspective of the application and the AudioFlinger.
+ */
+ virtual size_t getFrameSize() const { return sizeof(int8_t); }
+
+ /**
+ * @return format from the perspective of the application and the AudioFlinger.
+ */
+ virtual audio_format_t getFormat() const { return mApplicationFormat; }
+
+ /**
+ * The HAL may be running at a higher sample rate if, for example, playing wrapped EAC3.
+ * @return sample rate from the perspective of the application and the AudioFlinger.
+ */
+ virtual uint32_t getSampleRate() const { return mApplicationSampleRate; }
+
+ /**
+ * The HAL is in stereo mode when playing multi-channel compressed audio over HDMI.
+ * @return channel mask from the perspective of the application and the AudioFlinger.
+ */
+ virtual audio_channel_mask_t getChannelMask() const { return mApplicationChannelMask; }
virtual status_t flush();
virtual status_t standby();
@@ -89,6 +109,9 @@ private:
};
MySPDIFEncoder mSpdifEncoder;
+ audio_format_t mApplicationFormat;
+ uint32_t mApplicationSampleRate;
+ audio_channel_mask_t mApplicationChannelMask;
ssize_t writeDataBurst(const void* data, size_t bytes);
ssize_t writeInternal(const void* buffer, size_t bytes);