diff options
author | vivek mehta <mvivek@codeaurora.org> | 2012-12-04 11:46:08 -0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2012-12-23 21:26:55 -0800 |
commit | 3a05365a93afccc5bb7db3bdc9f5d2efef69c8d3 (patch) | |
tree | 9384cf4640e68fb4eb9652bc6549b75ed074f5e0 /media/libstagefright/AwesomePlayer.cpp | |
parent | 97343328d2920ec95fb06794b65ec467bce793af (diff) | |
download | frameworks_av-3a05365a93afccc5bb7db3bdc9f5d2efef69c8d3.zip frameworks_av-3a05365a93afccc5bb7db3bdc9f5d2efef69c8d3.tar.gz frameworks_av-3a05365a93afccc5bb7db3bdc9f5d2efef69c8d3.tar.bz2 |
Squashed commit of audio changes from CodeAurora
libstagefright: Add QC specific media format
- Add QC specific media extensions
- Add QC specific media definitions
Change-Id: I7dca90be3b977701d9537f5e017117790a030f1f
audio: Compile AudioParameter as shared library
- AudioParameter as shared lib is needed by BT
support in WFD source.
Change-Id: I464b428ace0cbb57ce6bf7bf3b57d51a7d56f032
libstagefright: Send flush on both i/p and o/p ports together
- ANR occurs in music due to race condition in OMX component if
flush is issued separately for i/p and o/p ports as DSP only
handles simultaneous flush on i/p and o/p ports.
Change-Id: I5b16cd5a9b57c857dc8bed489d2663b8f54769e3
libstagefright: Enable extended A\V format
- Add new files to support extended A\V format
Change-Id: I1e61d78d35b868d55fd8e99f95de8cab9c465db4
libstagefright: Framework to plug-in propritory parser
- Extend the current framework to plug-in propritory
parser
Change-Id: Ia586a3048420ddf1515261f20035589447263b7b
audio: add support for QCOM audio formats
- Add support for EVRC, QCELP, and WMA formats.
Change-Id: Iaf80f982fc8b08617132dbd7d524a1748866745c
frameworks/av: Support Tunnel Playback
- Implement DirectTrack and DirectTrackClient
- DirectTrack exposes API to client so it can create a direct
output.
- DirectTrackClient allows notifications to be sent to the
client from DirectTrack
- DirectTrack is being used for Tunnel Audio
Change-Id: I2fbb18a781d8e44b8d65da9a357f6e39375f063a
frameworks/av: Support LPA Playback
Add support to enable Playback in LPA mode
Change-Id: I1b8ac4904f4735017d62f3757ede7bbb56e62fd3
audio: Send correct channel mask in voice call recording.
-Using popCount function to get channel count gives incorrect value on
voice call recording.
-Only STEREO and MONO bits to be considered to count
channels on input
Change-Id: I04c2c802422e868bdba0538ff8623dbf9eb659fe
libstagefright: Thumbnail mode initial commit
- use sync frame decoding mode when kClientNeedsFrameBuffer
is set for hardware decoders
- hardware decoder will only expect I frames, OMXCodec will
set EOS on first ETB to stop more frames from being pulled
- skip EOS check on FTB so that the first frame will be
handled
Change-Id: I0e8974e088fdcc468e27764861c128cfe291499f
audio: Add support for QCOM's VOIP solution
Change-Id: I1150f536fa204b535ca4019fdaa84f33f4695d93
audio: define QCOM audio parameters
- Define QCOM audio paramters for FM, VOIP,
fluence, SSR, and A2DP
Change-Id: I29d02e37685846f6d4f00dee02e2726b015eaae7
Add ifdefs for QCOM enhanced features
Change-Id: Ic8e5fe6ecc058466ced71030883b1af6c2bc055c
Diffstat (limited to 'media/libstagefright/AwesomePlayer.cpp')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 188 |
1 files changed, 182 insertions, 6 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 48b6371..5cffad8 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -2,6 +2,10 @@ * Copyright (C) 2009 The Android Open Source Project * Copyright (c) 2012, The Linux Foundation. All rights reserved. * + * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. + * Not a Contribution, Apache license notifications and license are retained + * for attribution purposes only. + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -40,6 +44,12 @@ #include <media/stagefright/foundation/ADebug.h> #include <media/stagefright/timedtext/TimedTextDriver.h> #include <media/stagefright/AudioPlayer.h> +#ifdef QCOM_ENHANCED_AUDIO +#include <media/stagefright/LPAPlayer.h> +#ifdef USE_TUNNEL_MODE +#include <media/stagefright/TunnelPlayer.h> +#endif +#endif #include <media/stagefright/DataSource.h> #include <media/stagefright/FileSource.h> #include <media/stagefright/MediaBuffer.h> @@ -65,6 +75,9 @@ static int64_t kLowWaterMarkUs = 2000000ll; // 2secs static int64_t kHighWaterMarkUs = 5000000ll; // 5secs static const size_t kLowWaterMarkBytes = 40000; static const size_t kHighWaterMarkBytes = 200000; +#ifdef QCOM_ENHANCED_AUDIO +int AwesomePlayer::mTunnelAliveAP = 0; +#endif struct AwesomeEvent : public TimedEventQueue::Event { AwesomeEvent( @@ -215,6 +228,9 @@ AwesomePlayer::AwesomePlayer() mAudioStatusEventPending = false; reset(); +#ifdef QCOM_ENHANCED_AUDIO + mIsTunnelAudio = false; +#endif } AwesomePlayer::~AwesomePlayer() { @@ -224,6 +240,17 @@ AwesomePlayer::~AwesomePlayer() { reset(); +#ifdef QCOM_ENHANCED_AUDIO + // Disable Tunnel Mode Audio + if (mIsTunnelAudio) { + if(mTunnelAliveAP > 0) { + mTunnelAliveAP--; + ALOGV("mTunnelAliveAP = %d", mTunnelAliveAP); + } + } + mIsTunnelAudio = false; +#endif + mClient.disconnect(); } @@ -858,6 +885,9 @@ status_t AwesomePlayer::play() { } status_t AwesomePlayer::play_l() { +#ifdef QCOM_ENHANCED_AUDIO + int tunnelObjectsAlive = 0; +#endif modifyFlags(SEEK_PREVIEW, CLEAR); if (mFlags & PLAYING) { @@ -885,6 +915,13 @@ status_t AwesomePlayer::play_l() { if (mAudioSource != NULL) { if (mAudioPlayer == NULL) { if (mAudioSink != NULL) { +#ifdef QCOM_ENHANCED_AUDIO + sp<MetaData> format = mAudioTrack->getFormat(); + const char *mime; + bool success = format->findCString(kKeyMIMEType, &mime); + CHECK(success); +#endif + bool allowDeepBuffering; int64_t cachedDurationUs; bool eos; @@ -896,8 +933,64 @@ status_t AwesomePlayer::play_l() { } else { allowDeepBuffering = false; } - - mAudioPlayer = new AudioPlayer(mAudioSink, allowDeepBuffering, this); +#ifdef QCOM_ENHANCED_AUDIO +#ifdef USE_TUNNEL_MODE + // Create tunnel player if tunnel mode is enabled + ALOGW("Trying to create tunnel player mIsTunnelAudio %d, \ + LPAPlayer::objectsAlive %d, \ + TunnelPlayer::mTunnelObjectsAlive = %d,\ + (mAudioPlayer == NULL) %d", + mIsTunnelAudio, TunnelPlayer::mTunnelObjectsAlive, + LPAPlayer::objectsAlive,(mAudioPlayer == NULL)); + + if(mIsTunnelAudio && (mAudioPlayer == NULL) && + (LPAPlayer::objectsAlive == 0) && + (TunnelPlayer::mTunnelObjectsAlive == 0)) { + ALOGD("Tunnel player created for mime %s duration %lld\n",\ + mime, mDurationUs); + bool initCheck = false; + if(mVideoSource != NULL) { + // The parameter true is to inform tunnel player that + // clip is audio video + mAudioPlayer = new TunnelPlayer(mAudioSink, initCheck, + this, true); + } + else { + mAudioPlayer = new TunnelPlayer(mAudioSink, initCheck, + this); + } + if(!initCheck) { + ALOGE("deleting Tunnel Player - initCheck failed"); + delete mAudioPlayer; + mAudioPlayer = NULL; + } + } + tunnelObjectsAlive = (TunnelPlayer::mTunnelObjectsAlive); +#endif + char lpaDecode[128]; + property_get("lpa.decode",lpaDecode,"0"); + if((strcmp("true",lpaDecode) == 0) && (mAudioPlayer == NULL) && tunnelObjectsAlive==0 ) + { + ALOGV("LPAPlayer::getObjectsAlive() %d",LPAPlayer::objectsAlive); + if ( mDurationUs > 60000000 + && (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG) || !strcasecmp(mime,MEDIA_MIMETYPE_AUDIO_AAC)) + && LPAPlayer::objectsAlive == 0 && mVideoSource == NULL) { + ALOGD("LPAPlayer created, LPA MODE detected mime %s duration %lld", mime, mDurationUs); + bool initCheck = false; + mAudioPlayer = new LPAPlayer(mAudioSink, initCheck, this); + if(!initCheck) { + delete mAudioPlayer; + mAudioPlayer = NULL; + } + } + } + if(mAudioPlayer == NULL) { + ALOGV("AudioPlayer created, Non-LPA mode mime %s duration %lld\n", mime, mDurationUs); +#endif + mAudioPlayer = new AudioPlayer(mAudioSink, allowDeepBuffering, this); +#ifdef QCOM_ENHANCED_AUDIO + } +#endif mAudioPlayer->setSource(mAudioSource); mTimeSource = mAudioPlayer; @@ -915,9 +1008,14 @@ status_t AwesomePlayer::play_l() { if (mVideoSource == NULL) { // We don't want to post an error notification at this point, // the error returned from MediaPlayer::start() will suffice. - - status_t err = startAudioPlayer_l( - false /* sendErrorNotification */); + bool sendErrorNotification = false; +#ifdef QCOM_ENHANCED_AUDIO + if(mIsTunnelAudio) { + // For tunnel Audio error has to be posted to the client + sendErrorNotification = true; + } +#endif + status_t err = startAudioPlayer_l(sendErrorNotification); if (err != OK) { delete mAudioPlayer; @@ -1387,14 +1485,92 @@ status_t AwesomePlayer::initAudioDecoder() { const char *mime; CHECK(meta->findCString(kKeyMIMEType, &mime)); - +#ifdef QCOM_ENHANCED_AUDIO +#ifdef USE_TUNNEL_MODE + char value[PROPERTY_VALUE_MAX]; + char tunnelDecode[128]; + property_get("tunnel.decode",tunnelDecode,"0"); + // Enable tunnel mode for mp3 and aac and if the clip is not aac adif + // and if no other tunnel mode instances aare running. + ALOGD("Tunnel Mime Type: %s, object alive = %d, mTunnelAliveAP = %d",\ + mime, (TunnelPlayer::mTunnelObjectsAlive), mTunnelAliveAP); + if(((strcmp("true",tunnelDecode) == 0)||(atoi(tunnelDecode))) && + (TunnelPlayer::mTunnelObjectsAlive == 0) && + mTunnelAliveAP == 0 && + ((!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) || + (!strcasecmp(mime,MEDIA_MIMETYPE_AUDIO_AAC)))) { + + if(mVideoSource != NULL) { + char tunnelAVDecode[128]; + property_get("tunnel.audiovideo.decode",tunnelAVDecode,"0"); + if(((strncmp("true", tunnelAVDecode, 4) == 0)||(atoi(tunnelAVDecode)))) { + ALOGD("Enable Tunnel Mode for A-V playback"); + mIsTunnelAudio = true; + } + } + else { + ALOGI("Tunnel Mode Audio Enabled"); + mIsTunnelAudio = true; + } + } + else + ALOGD("Normal Audio Playback"); +#endif + if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW) || + (mIsTunnelAudio && (mTunnelAliveAP == 0))) { + ALOGD("Set Audio Track as Audio Source"); + if(mIsTunnelAudio) { + mTunnelAliveAP++; + } +#else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) { +#endif mAudioSource = mAudioTrack; } else { +#ifdef QCOM_ENHANCED_AUDIO + // For LPA Playback use the decoder without OMX layer + char *matchComponentName = NULL; + int64_t durationUs; + uint32_t flags = 0; + char lpaDecode[128]; + property_get("lpa.decode",lpaDecode,"0"); + if (mAudioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { + Mutex::Autolock autoLock(mMiscStateLock); + if (mDurationUs < 0 || durationUs > mDurationUs) { + mDurationUs = durationUs; + } + } + if ( mDurationUs > 60000000 + && (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG) || !strcasecmp(mime,MEDIA_MIMETYPE_AUDIO_AAC)) + && LPAPlayer::objectsAlive == 0 && mVideoSource == NULL && (strcmp("true",lpaDecode) == 0)) { + char nonOMXDecoder[128]; + if(!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) { + ALOGD("matchComponentName is set to MP3Decoder %lld, mime %s",mDurationUs,mime); + property_get("use.non-omx.mp3.decoder",nonOMXDecoder,"0"); + if((strcmp("true",nonOMXDecoder) == 0)) { + matchComponentName = (char *) "MP3Decoder"; + } + } else if((!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC))) { + ALOGD("matchComponentName is set to AACDecoder %lld, mime %s",mDurationUs,mime); + property_get("use.non-omx.aac.decoder",nonOMXDecoder,"0"); + if((strcmp("true",nonOMXDecoder) == 0)) { + matchComponentName = (char *) "AACDecoder"; + } else { + matchComponentName = (char *) "OMX.google.aac.decoder"; + } + } + flags |= OMXCodec::kSoftwareCodecsOnly; + } + mAudioSource = OMXCodec::Create( + mClient.interface(), mAudioTrack->getFormat(), + false, // createEncoder + mAudioTrack, matchComponentName, flags,NULL); +#else mAudioSource = OMXCodec::Create( mClient.interface(), mAudioTrack->getFormat(), false, // createEncoder mAudioTrack); +#endif } if (mAudioSource != NULL) { |