summaryrefslogtreecommitdiff
path: root/media/libmediaplayerservice/MediaPlayerService.cpp
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2012-03-02 14:54:07 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2012-03-02 17:26:49 -0800
commit786618ffe881aceb64d65a6a2e2d76ede6e01ec0 (patch)
tree3e88f6c457f47529026207badf835dfa448ec8b8 /media/libmediaplayerservice/MediaPlayerService.cpp
parente7c795f3300814aa3f26ceb845f29695383c7edc (diff)
Add channel mask in AudioSink
Add support for specifying a channel mask when opening an AudioSink. This parameter does not replace the channel count parameter in order to not have to duplicate the logic to derive a mask from the channel count everywhere an AudioSink is used without a known mask. A mask of 0 (CHANNEL_MASK_USE_CHANNEL_ORDER) means a mask will be automatically derived from the number of channels. Update existing AudioSink implementations to use the channel mask, and users of AudioSink to specify the mask if available, and CHANNEL_MASK_USE_CHANNEL_ORDER otherwise. Change-Id: Ifa9bd259874816dbc25ead2b03ea52e873cff474
Diffstat (limited to 'media/libmediaplayerservice/MediaPlayerService.cpp')
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 1e2abf02..bd3e07a0 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -1458,7 +1458,8 @@ status_t MediaPlayerService::AudioOutput::getPosition(uint32_t *position)
}
status_t MediaPlayerService::AudioOutput::open(
- uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
+ uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
+ audio_format_t format, int bufferCount,
AudioCallback cb, void *cookie)
{
mCallback = cb;
@@ -1470,7 +1471,8 @@ status_t MediaPlayerService::AudioOutput::open(
bufferCount = mMinBufferCount;
}
- ALOGV("open(%u, %d, %d, %d, %d)", sampleRate, channelCount, format, bufferCount,mSessionId);
+ ALOGV("open(%u, %d, 0x%x, %d, %d, %d)", sampleRate, channelCount, channelMask,
+ format, bufferCount, mSessionId);
if (mTrack) close();
int afSampleRate;
int afFrameCount;
@@ -1485,13 +1487,21 @@ status_t MediaPlayerService::AudioOutput::open(
frameCount = (sampleRate*afFrameCount*bufferCount)/afSampleRate;
+ if (channelMask == CHANNEL_MASK_USE_CHANNEL_ORDER) {
+ channelMask = audio_channel_mask_from_count(channelCount);
+ if (0 == channelMask) {
+ ALOGE("open() error, can\'t derive mask for %d audio channels", channelCount);
+ return NO_INIT;
+ }
+ }
+
AudioTrack *t;
if (mCallback != NULL) {
t = new AudioTrack(
mStreamType,
sampleRate,
format,
- (channelCount == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
+ channelMask,
frameCount,
0 /* flags */,
CallbackWrapper,
@@ -1503,7 +1513,7 @@ status_t MediaPlayerService::AudioOutput::open(
mStreamType,
sampleRate,
format,
- (channelCount == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
+ channelMask,
frameCount,
0,
NULL,
@@ -1751,10 +1761,11 @@ bool CallbackThread::threadLoop() {
////////////////////////////////////////////////////////////////////////////////
status_t MediaPlayerService::AudioCache::open(
- uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
+ uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
+ audio_format_t format, int bufferCount,
AudioCallback cb, void *cookie)
{
- ALOGV("open(%u, %d, %d, %d)", sampleRate, channelCount, format, bufferCount);
+ ALOGV("open(%u, %d, 0x%x, %d, %d)", sampleRate, channelCount, channelMask, format, bufferCount);
if (mHeap->getHeapID() < 0) {
return NO_INIT;
}