summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2015-04-10 16:22:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-10 16:22:36 +0000
commitde5e5d7141e7816a006e9a890bb68fc2d6581e0e (patch)
tree746e10786cdba136ac803b3e34e1f37eda70a1ee /services
parent7d014e50b3acd60e73ed7d7a74dc58485c7a413c (diff)
parent23d8997f58bb9c59fa3a1b9a6b2edbf1b2b0f4c6 (diff)
downloadframeworks_av-de5e5d7141e7816a006e9a890bb68fc2d6581e0e.zip
frameworks_av-de5e5d7141e7816a006e9a890bb68fc2d6581e0e.tar.gz
frameworks_av-de5e5d7141e7816a006e9a890bb68fc2d6581e0e.tar.bz2
Merge "AudioFlinger: more DTS passthrough support"
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioHwDevice.cpp25
-rw-r--r--services/audioflinger/SpdifStreamOut.cpp15
-rw-r--r--services/audioflinger/SpdifStreamOut.h8
3 files changed, 29 insertions, 19 deletions
diff --git a/services/audioflinger/AudioHwDevice.cpp b/services/audioflinger/AudioHwDevice.cpp
index 09d86ea..3191598 100644
--- a/services/audioflinger/AudioHwDevice.cpp
+++ b/services/audioflinger/AudioHwDevice.cpp
@@ -44,7 +44,7 @@ status_t AudioHwDevice::openOutputStream(
AudioStreamOut *outputStream = new AudioStreamOut(this, flags);
// Try to open the HAL first using the current format.
- ALOGV("AudioHwDevice::openOutputStream(), try "
+ ALOGV("openOutputStream(), try "
" sampleRate %d, Format %#x, "
"channelMask %#x",
config->sample_rate,
@@ -59,7 +59,7 @@ status_t AudioHwDevice::openOutputStream(
// FIXME Look at any modification to the config.
// The HAL might modify the config to suggest a wrapped format.
// Log this so we can see what the HALs are doing.
- ALOGI("AudioHwDevice::openOutputStream(), HAL returned"
+ ALOGI("openOutputStream(), HAL returned"
" sampleRate %d, Format %#x, "
"channelMask %#x, status %d",
config->sample_rate,
@@ -72,16 +72,19 @@ status_t AudioHwDevice::openOutputStream(
&& ((flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)
&& ((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0);
- // FIXME - Add isEncodingSupported() query to SPDIF wrapper then
- // call it from here.
if (wrapperNeeded) {
- outputStream = new SpdifStreamOut(this, flags);
- status = outputStream->open(handle, devices, &originalConfig, address);
- if (status != NO_ERROR) {
- ALOGE("ERROR - AudioHwDevice::openOutputStream(), SPDIF open returned %d",
- status);
- delete outputStream;
- outputStream = NULL;
+ if (SPDIFEncoder::isFormatSupported(originalConfig.format)) {
+ outputStream = new SpdifStreamOut(this, flags, originalConfig.format);
+ status = outputStream->open(handle, devices, &originalConfig, address);
+ if (status != NO_ERROR) {
+ ALOGE("ERROR - openOutputStream(), SPDIF open returned %d",
+ status);
+ delete outputStream;
+ outputStream = NULL;
+ }
+ } else {
+ ALOGE("ERROR - openOutputStream(), SPDIFEncoder does not support format 0x%08x",
+ originalConfig.format);
}
}
}
diff --git a/services/audioflinger/SpdifStreamOut.cpp b/services/audioflinger/SpdifStreamOut.cpp
index d23588e..45b541a 100644
--- a/services/audioflinger/SpdifStreamOut.cpp
+++ b/services/audioflinger/SpdifStreamOut.cpp
@@ -32,10 +32,12 @@ namespace android {
* If the AudioFlinger is processing encoded data and the HAL expects
* PCM then we need to wrap the data in an SPDIF wrapper.
*/
-SpdifStreamOut::SpdifStreamOut(AudioHwDevice *dev, audio_output_flags_t flags)
+SpdifStreamOut::SpdifStreamOut(AudioHwDevice *dev,
+ audio_output_flags_t flags,
+ audio_format_t format)
: AudioStreamOut(dev,flags)
, mRateMultiplier(1)
- , mSpdifEncoder(this)
+ , mSpdifEncoder(this, format)
, mRenderPositionHal(0)
, mPreviousHalPosition32(0)
{
@@ -49,15 +51,15 @@ status_t SpdifStreamOut::open(
{
struct audio_config customConfig = *config;
- customConfig.format = AUDIO_FORMAT_PCM_16_BIT;
- customConfig.channel_mask = AUDIO_CHANNEL_OUT_STEREO;
-
// Some data bursts run at a higher sample rate.
+ // TODO Move this into the audio_utils as a static method.
switch(config->format) {
case AUDIO_FORMAT_E_AC3:
mRateMultiplier = 4;
break;
case AUDIO_FORMAT_AC3:
+ case AUDIO_FORMAT_DTS:
+ case AUDIO_FORMAT_DTS_HD:
mRateMultiplier = 1;
break;
default:
@@ -67,6 +69,9 @@ status_t SpdifStreamOut::open(
}
customConfig.sample_rate = config->sample_rate * mRateMultiplier;
+ customConfig.format = AUDIO_FORMAT_PCM_16_BIT;
+ customConfig.channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+
// Always print this because otherwise it could be very confusing if the
// HAL and AudioFlinger are using different formats.
// Print before open() because HAL may modify customConfig.
diff --git a/services/audioflinger/SpdifStreamOut.h b/services/audioflinger/SpdifStreamOut.h
index cb82ac7..d81c064 100644
--- a/services/audioflinger/SpdifStreamOut.h
+++ b/services/audioflinger/SpdifStreamOut.h
@@ -38,7 +38,8 @@ namespace android {
class SpdifStreamOut : public AudioStreamOut {
public:
- SpdifStreamOut(AudioHwDevice *dev, audio_output_flags_t flags);
+ SpdifStreamOut(AudioHwDevice *dev, audio_output_flags_t flags,
+ audio_format_t format);
virtual ~SpdifStreamOut() { }
@@ -77,8 +78,9 @@ private:
class MySPDIFEncoder : public SPDIFEncoder
{
public:
- MySPDIFEncoder(SpdifStreamOut *spdifStreamOut)
- : mSpdifStreamOut(spdifStreamOut)
+ MySPDIFEncoder(SpdifStreamOut *spdifStreamOut, audio_format_t format)
+ : SPDIFEncoder(format)
+ , mSpdifStreamOut(spdifStreamOut)
{
}