OSDN Git Service

Remove dead code
authorGlenn Kasten <gkasten@google.com>
Fri, 16 Sep 2011 22:36:21 +0000 (15:36 -0700)
committerGlenn Kasten <gkasten@google.com>
Wed, 28 Sep 2011 00:25:49 +0000 (17:25 -0700)
AudioPlayback_Parameters fields trackcb and trackcbUser
audioTrack_callBack_uri
android_Player_androidBufferQueue_registerCallback_l
GenericPlayer field mLooperPriority
StreamPlayer::registerQueueCallback
CAudioPlayer::mpLock
AudioSfDecoder::startPrefetch_async
IAndroidBufferQueue does not support AudioRecorder object
android/BufferQueueSource.h #include

Change-Id: I9d7cef243167e10279df452e7c62e66d8f5fe3b6

14 files changed:
wilhelm/src/android/AudioPlayer_to_android.cpp
wilhelm/src/android/BufferQueueSource.h
wilhelm/src/android/MediaPlayer_to_android.cpp
wilhelm/src/android/MediaPlayer_to_android.h
wilhelm/src/android/android_AudioSfDecoder.cpp
wilhelm/src/android/android_AudioSfDecoder.h
wilhelm/src/android/android_GenericPlayer.cpp
wilhelm/src/android/android_GenericPlayer.h
wilhelm/src/android/android_StreamPlayer.cpp
wilhelm/src/android/android_StreamPlayer.h
wilhelm/src/android/android_defs.h
wilhelm/src/classes.h
wilhelm/src/itf/IAndroidBufferQueue.c
wilhelm/src/itf/IEngine.c

index 66dfb1c..1409066 100644 (file)
@@ -582,7 +582,6 @@ void audioPlayer_auxEffectUpdate(CAudioPlayer* ap) {
 //-----------------------------------------------------------------------------
 void audioPlayer_setInvalid(CAudioPlayer* ap) {
     ap->mAndroidObjType = INVALID_TYPE;
-    ap->mpLock = NULL;
 }
 
 
@@ -782,29 +781,7 @@ static void sfplayer_handlePrefetchEvent(int event, int data1, int data2, void*
 
             object_lock_exclusive(&ap->mObject);
 
-            if (AUDIOPLAYER_FROM_URIFD == ap->mAndroidObjType) {
-                //**************************************
-                // FIXME move under GenericMediaPlayer
-#if 0
-                ap->mAudioTrack = ap->mSfPlayer->getAudioTrack();
-                ap->mNumChannels = ap->mSfPlayer->getNumChannels();
-                ap->mSampleRateMilliHz =
-                        android_to_sles_sampleRate(ap->mSfPlayer->getSampleRateHz());
-                ap->mSfPlayer->startPrefetch_async();
-                // update the new track with the current settings
-                audioPlayer_auxEffectUpdate(ap);
-                android_audioPlayer_useEventMask(ap);
-                android_audioPlayer_volumeUpdate(ap);
-                android_audioPlayer_setPlayRate(ap, ap->mPlaybackRate.mRate, false /*lockAP*/);
-#endif
-            } else if (AUDIOPLAYER_FROM_PCM_BUFFERQUEUE == ap->mAndroidObjType) {
-                if (ap->mAPlayer != 0) {
-                    ((android::AudioToCbRenderer*)ap->mAPlayer.get())->startPrefetch_async();
-                }
-            } else if (AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE == ap->mAndroidObjType) {
-                SL_LOGD("Received SfPlayer::kEventPrepared from AVPlayer for CAudioPlayer %p", ap);
-            }
-
+            // Most of successful prepare completion is handled by a subclass.
             ap->mAndroidObjState = ANDROID_READY;
 
             object_unlock_exclusive(&ap->mObject);
@@ -1145,45 +1122,6 @@ SLresult android_audioPlayer_checkSourceSink(CAudioPlayer *pAudioPlayer)
 }
 
 
-
-//-----------------------------------------------------------------------------
-static void audioTrack_callBack_uri(int event, void* user, void *info) {
-    // EVENT_MORE_DATA needs to be handled with priority over the other events
-    // because it will be called the most often during playback
-
-    if (event == android::AudioTrack::EVENT_MORE_DATA) {
-        //SL_LOGV("received event EVENT_MORE_DATA from AudioTrack");
-        // set size to 0 to signal we're not using the callback to write more data
-        android::AudioTrack::Buffer* pBuff = (android::AudioTrack::Buffer*)info;
-        pBuff->size = 0;
-    } else if (NULL != user) {
-        CAudioPlayer *ap = (CAudioPlayer *)user;
-        if (!android::CallbackProtector::enterCbIfOk(ap->mCallbackProtector)) {
-            // it is not safe to enter the callback (the track is about to go away)
-            return;
-        }
-        switch (event) {
-            case android::AudioTrack::EVENT_MARKER :
-                audioTrack_handleMarker_lockPlay(ap);
-                break;
-            case android::AudioTrack::EVENT_NEW_POS :
-                audioTrack_handleNewPos_lockPlay(ap);
-                break;
-            case android::AudioTrack::EVENT_UNDERRUN :
-                audioTrack_handleUnderrun_lockPlay(ap);
-                break;
-            case android::AudioTrack::EVENT_BUFFER_END :
-            case android::AudioTrack::EVENT_LOOP_END :
-                break;
-            default:
-                SL_LOGE("Encountered unknown AudioTrack event %d for CAudioPlayer %p", event,
-                        ap);
-                break;
-        }
-        ap->mCallbackProtector->exitCb();
-    }
-}
-
 //-----------------------------------------------------------------------------
 // Callback associated with an AudioTrack of an SL ES AudioPlayer that gets its data
 // from a buffer queue. This will not be called once the AudioTrack has been destroyed.
@@ -1334,7 +1272,6 @@ SLresult android_audioPlayer_create(CAudioPlayer *pAudioPlayer) {
         // These initializations are in the same order as the field declarations in classes.h
 
         // FIXME Consolidate initializations (many of these already in IEngine_CreateAudioPlayer)
-        pAudioPlayer->mpLock = new android::Mutex();
         // mAndroidObjType: see above comment
         pAudioPlayer->mAndroidObjState = ANDROID_UNINITIALIZED;
         pAudioPlayer->mSessionId = android::AudioSystem::newAudioSessionId();
@@ -1490,8 +1427,6 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async
         AudioPlayback_Parameters app;
         app.sessionId = pAudioPlayer->mSessionId;
         app.streamType = pAudioPlayer->mStreamType;
-        app.trackcb = audioTrack_callBack_uri;
-        app.trackcbUser = (void *) pAudioPlayer;
 
         pAudioPlayer->mAPlayer = new android::LocAVPlayer(&app, false /*hasVideo*/);
         pAudioPlayer->mAPlayer->init(sfplayer_handlePrefetchEvent,
@@ -1557,8 +1492,6 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async
         AudioPlayback_Parameters ap_params;
         ap_params.sessionId = pAudioPlayer->mSessionId;
         ap_params.streamType = pAudioPlayer->mStreamType;
-        ap_params.trackcb = NULL;
-        ap_params.trackcbUser = NULL;
         android::StreamPlayer* splr = new android::StreamPlayer(&ap_params, false /*hasVideo*/,
                 &pAudioPlayer->mAndroidBufferQueue, pAudioPlayer->mCallbackProtector);
         pAudioPlayer->mAPlayer = splr;
@@ -1607,8 +1540,6 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async
         AudioPlayback_Parameters app;
         app.sessionId = pAudioPlayer->mSessionId;
         app.streamType = pAudioPlayer->mStreamType;
-        app.trackcb = NULL;
-        app.trackcbUser = NULL;
         android::AacBqToPcmCbRenderer* bqtobq = new android::AacBqToPcmCbRenderer(&app);
         // configures the callback for the sink buffer queue
         bqtobq->setDataPushListener(adecoder_writeToBufferQueue, pAudioPlayer);
@@ -1740,11 +1671,6 @@ SLresult android_audioPlayer_destroy(CAudioPlayer *pAudioPlayer) {
     pAudioPlayer->mAuxEffect.~sp();
     pAudioPlayer->mAPlayer.~sp();
 
-    if (pAudioPlayer->mpLock != NULL) {
-        delete pAudioPlayer->mpLock;
-        pAudioPlayer->mpLock = NULL;
-    }
-
     return result;
 }
 
@@ -2242,10 +2168,9 @@ SLresult android_audioPlayer_bufferQueue_onClear(CAudioPlayer *ap) {
 SLresult android_audioPlayer_androidBufferQueue_registerCallback_l(CAudioPlayer *ap) {
     SLresult result = SL_RESULT_SUCCESS;
     assert(ap->mAPlayer != 0);
+    // FIXME investigate why these two cases are not handled symmetrically any more
     switch (ap->mAndroidObjType) {
       case AUDIOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: {
-          android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(ap->mAPlayer.get());
-          splr->registerQueueCallback(&ap->mAndroidBufferQueue);
         } break;
       case AUDIOPLAYER_FROM_ADTS_ABQ_TO_PCM_BUFFERQUEUE: {
           android::AacBqToPcmCbRenderer* dec =
index 1937265..c91b7b1 100644 (file)
 #ifndef BUFFERQUEUE_SOURCE_H_
 #define BUFFERQUEUE_SOURCE_H_
 
-#include <stdio.h>
-
 #include <media/stagefright/DataSource.h>
-#include <media/stagefright/MediaErrors.h>
-#include <utils/threads.h>
-#include <drm/DrmManagerClient.h>
-#include "include/AacAdtsExtractor.h"
 
 // number of SLuint32 fields to store a buffer event message in an item, by mapping each
 //   to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
index 058c606..ad4a319 100644 (file)
@@ -363,8 +363,6 @@ XAresult android_Player_realize(CMediaPlayer *mp, SLboolean async) {
     AudioPlayback_Parameters ap_params;
     ap_params.sessionId = mp->mSessionId;
     ap_params.streamType = mp->mStreamType;
-    ap_params.trackcb = NULL;
-    ap_params.trackcbUser = NULL;
 
     switch(mp->mAndroidObjType) {
     case AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE: {
@@ -638,16 +636,6 @@ XAresult android_Player_loop(CMediaPlayer *mp, SLboolean loopEnable) {
 
 
 //-----------------------------------------------------------------------------
-void android_Player_androidBufferQueue_registerCallback_l(CMediaPlayer *mp) {
-    if ((mp->mAndroidObjType == AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE)
-            && (mp->mAVPlayer != 0)) {
-        SL_LOGD("android_Player_androidBufferQueue_registerCallback_l");
-        android::StreamPlayer* splr = static_cast<android::StreamPlayer*>(mp->mAVPlayer.get());
-        splr->registerQueueCallback(&mp->mAndroidBufferQueue);
-    }
-}
-
-
 void android_Player_androidBufferQueue_clear_l(CMediaPlayer *mp) {
     if ((mp->mAndroidObjType == AUDIOVIDEOPLAYER_FROM_TS_ANDROIDBUFFERQUEUE)
             && (mp->mAVPlayer != 0)) {
index cea4c3a..e83439d 100644 (file)
@@ -87,8 +87,6 @@ extern XAresult android_Player_loop(CMediaPlayer *mp, SLboolean loopEnable);
  ****************************/
 
 /* must be called with a lock on mp->mThis */
-extern void android_Player_androidBufferQueue_registerCallback_l(CMediaPlayer *mp);
-/* must be called with a lock on mp->mThis */
 extern void android_Player_androidBufferQueue_clear_l(CMediaPlayer *mp);
 /* must be called with a lock on mp->mThis */
 extern void android_Player_androidBufferQueue_onRefilled_l(CMediaPlayer *mp);
index 8c4361b..ab6eb95 100644 (file)
@@ -88,19 +88,6 @@ void AudioSfDecoder::getPositionMsec(int* msec) {
 }
 
 
-void AudioSfDecoder::startPrefetch_async() {
-    SL_LOGV("AudioSfDecoder::startPrefetch_async()");
-
-    if (wantPrefetch()) {
-        SL_LOGV("AudioSfDecoder::startPrefetch_async(): sending check cache msg");
-
-        mStateFlags |= kFlagPreparing | kFlagBuffering;
-
-        (new AMessage(kWhatCheckCache, id()))->post();
-    }
-}
-
-
 //--------------------------------------------------
 uint32_t AudioSfDecoder::getPcmFormatKeyCount() const {
     return NB_PCMMETADATA_KEYS;
index cbf5a12..b029b34 100644 (file)
@@ -62,8 +62,6 @@ public:
     virtual void play();
     virtual void getPositionMsec(int* msec); //msec != NULL, ANDROID_UNKNOWN_TIME if unknown
 
-    void startPrefetch_async();
-
     uint32_t getPcmFormatKeyCount() const;
     bool     getPcmFormatKeySize(uint32_t index, uint32_t* pKeySize);
     bool     getPcmFormatKeyName(uint32_t index, uint32_t keySize, char* keyName);
index 81fe416..676be8d 100644 (file)
@@ -29,7 +29,6 @@ GenericPlayer::GenericPlayer(const AudioPlayback_Parameters* params) :
         mNotifyClient(NULL),
         mNotifyUser(NULL),
         mStateFlags(0),
-        mLooperPriority(PRIORITY_DEFAULT),
         mPlaybackParams(*params),
         mChannelCount(UNKNOWN_NUMCHANNELS),
         mDurationMsec(ANDROID_UNKNOWN_TIME),
@@ -71,7 +70,7 @@ void GenericPlayer::init(const notif_cbf_t cbf, void* notifUser) {
     }
 
     mLooper->registerHandler(this);
-    mLooper->start(false /*runOnCallingThread*/, false /*canCallJava*/, mLooperPriority);
+    mLooper->start(false /*runOnCallingThread*/, false /*canCallJava*/, PRIORITY_DEFAULT);
 }
 
 
index 534c85f..5a7fc22 100644 (file)
@@ -171,7 +171,6 @@ protected:
     uint32_t mStateFlags;
 
     sp<ALooper> mLooper;
-    int32_t mLooperPriority;
 
     AudioPlayback_Parameters mPlaybackParams;
 
index a39671e..7fad498 100644 (file)
@@ -299,11 +299,6 @@ void StreamPlayer::onStopForDestroy() {
 }
 
 
-void StreamPlayer::registerQueueCallback(IAndroidBufferQueue *androidBufferQueue) {
-    SL_LOGD("StreamPlayer::registerQueueCallback");
-}
-
-
 /**
  * Asynchronously notify the player that the queue is ready to be pulled from.
  */
index ca7558c..51cad7d 100644 (file)
@@ -81,7 +81,6 @@ public:
     virtual void onMessageReceived(const sp<AMessage> &msg);
     virtual void preDestroy();
 
-    void registerQueueCallback(IAndroidBufferQueue *androidBufferQueue);
     void queueRefilled();
     void appClear_l();
 
index 4cbf951..6f8ecc8 100644 (file)
@@ -64,12 +64,9 @@ enum AndroidObjectState {
 
 #define MPEG2_TS_BLOCK_SIZE 188
 
-// FIXME separate the cases where we don't need an AudioTrack callback
 typedef struct AudioPlayback_Parameters_struct {
     int streamType;
     int sessionId;
-    android::AudioTrack::callback_t trackcb;
-    void* trackcbUser;
 } AudioPlayback_Parameters;
 
 /**
index 4a64e01..6bbadd1 100644 (file)
@@ -90,7 +90,6 @@
     struct SndFile mSndFile;
 #endif // USE_SNDFILE
 #ifdef ANDROID
-    android::Mutex          *mpLock;
     enum AndroidObjectType mAndroidObjType;
     /** identifies the initialization and preparation state */
     enum AndroidObjectState mAndroidObjState;
index 6749215..278b7fd 100644 (file)
@@ -37,9 +37,6 @@ static SLuint32 getAssociatedState(IAndroidBufferQueue *thiz)
       case SL_OBJECTID_AUDIOPLAYER:
         state = ((CAudioPlayer *) thiz->mThis)->mPlay.mState;
         break;
-      case SL_OBJECTID_AUDIORECORDER:
-        state = ((CAudioRecorder *) thiz->mThis)->mRecord.mState;
-        break;
       default:
         // unreachable, but just in case we will assume it is stopped
         assert(SL_BOOLEAN_FALSE);
@@ -218,16 +215,14 @@ static SLresult IAndroidBufferQueue_RegisterCallback(SLAndroidBufferQueueItf sel
         thiz->mCallback = callback;
         thiz->mContext = pContext;
 
+        // FIXME investigate why these two cases are not handled symmetrically any more
         switch (InterfaceToObjectID(thiz)) {
           case SL_OBJECTID_AUDIOPLAYER:
             result = android_audioPlayer_androidBufferQueue_registerCallback_l(
                     (CAudioPlayer*) thiz->mThis);
             break;
           case XA_OBJECTID_MEDIAPLAYER:
-            SL_LOGV("IAndroidBufferQueue_RegisterCallback()");
             result = SL_RESULT_SUCCESS;
-            //FIXME return error code
-            android_Player_androidBufferQueue_registerCallback_l((CMediaPlayer*) thiz->mThis);
             break;
           default:
             result = SL_RESULT_PARAMETER_INVALID;
index 687727e..3efe777 100644 (file)
@@ -249,8 +249,6 @@ static SLresult IEngine_CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer
                     memset(thiz->mSndFile.mBuffer, 0, sizeof(thiz->mSndFile.mBuffer));
 #endif
 #ifdef ANDROID
-                    // extra safe initializations of pointers, in case of incomplete construction
-                    thiz->mpLock = NULL;
                     // placement new (explicit constructor)
                     // FIXME unnecessary once those fields are encapsulated in one class, rather
                     //   than a structure