@@ -1458,7 +1458,8 @@ status_t MediaPlayerService::AudioOutput::getPosition(uint32_t *position)
14581458}
14591459
14601460status_t MediaPlayerService::AudioOutput::open (
1461- uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
1461+ uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
1462+ audio_format_t format, int bufferCount,
14621463 AudioCallback cb, void *cookie)
14631464{
14641465 mCallback = cb;
@@ -1470,7 +1471,8 @@ status_t MediaPlayerService::AudioOutput::open(
14701471 bufferCount = mMinBufferCount ;
14711472
14721473 }
1473- ALOGV (" open(%u, %d, %d, %d, %d)" , sampleRate, channelCount, format, bufferCount,mSessionId );
1474+ ALOGV (" open(%u, %d, 0x%x, %d, %d, %d)" , sampleRate, channelCount, channelMask,
1475+ format, bufferCount, mSessionId );
14741476 if (mTrack ) close ();
14751477 int afSampleRate;
14761478 int afFrameCount;
@@ -1485,13 +1487,21 @@ status_t MediaPlayerService::AudioOutput::open(
14851487
14861488 frameCount = (sampleRate*afFrameCount*bufferCount)/afSampleRate;
14871489
1490+ if (channelMask == CHANNEL_MASK_USE_CHANNEL_ORDER) {
1491+ channelMask = audio_channel_mask_from_count (channelCount);
1492+ if (0 == channelMask) {
1493+ ALOGE (" open() error, can\' t derive mask for %d audio channels" , channelCount);
1494+ return NO_INIT;
1495+ }
1496+ }
1497+
14881498 AudioTrack *t;
14891499 if (mCallback != NULL ) {
14901500 t = new AudioTrack (
14911501 mStreamType ,
14921502 sampleRate,
14931503 format,
1494- (channelCount == 2 ) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO ,
1504+ channelMask ,
14951505 frameCount,
14961506 0 /* flags */ ,
14971507 CallbackWrapper,
@@ -1503,7 +1513,7 @@ status_t MediaPlayerService::AudioOutput::open(
15031513 mStreamType ,
15041514 sampleRate,
15051515 format,
1506- (channelCount == 2 ) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO ,
1516+ channelMask ,
15071517 frameCount,
15081518 0 ,
15091519 NULL ,
@@ -1751,10 +1761,11 @@ bool CallbackThread::threadLoop() {
17511761// //////////////////////////////////////////////////////////////////////////////
17521762
17531763status_t MediaPlayerService::AudioCache::open (
1754- uint32_t sampleRate, int channelCount, audio_format_t format, int bufferCount,
1764+ uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
1765+ audio_format_t format, int bufferCount,
17551766 AudioCallback cb, void *cookie)
17561767{
1757- ALOGV (" open(%u, %d, % d, %d)" , sampleRate, channelCount, format, bufferCount);
1768+ ALOGV (" open(%u, %d, 0x%x, % d, %d)" , sampleRate, channelCount, channelMask , format, bufferCount);
17581769 if (mHeap ->getHeapID () < 0 ) {
17591770 return NO_INIT;
17601771 }
0 commit comments