189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project/*
289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Copyright 2008, The Android Open Source Project
489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License");
689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** you may not use this file except in compliance with the License.
789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** You may obtain a copy of the License at
889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**     http://www.apache.org/licenses/LICENSE-2.0
1089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project**
1189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** Unless required by applicable law or agreed to in writing, software
1289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** distributed under the License is distributed on an "AS IS" BASIS,
1389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** See the License for the specific language governing permissions and
1589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project** limitations under the License.
1689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project*/
1789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
1889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#ifndef ANDROID_MEDIAPLAYERSERVICE_H
1989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#define ANDROID_MEDIAPLAYERSERVICE_H
2089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
21c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman#include <arpa/inet.h>
22c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman
23273d098cc72a88c797d01c7dff0c1350f315f05fMathias Agopian#include <utils/Log.h>
24273d098cc72a88c797d01c7dff0c1350f315f05fMathias Agopian#include <utils/threads.h>
25273d098cc72a88c797d01c7dff0c1350f315f05fMathias Agopian#include <utils/List.h>
26273d098cc72a88c797d01c7dff0c1350f315f05fMathias Agopian#include <utils/Errors.h>
2789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <utils/KeyedVector.h>
282db8455d8f4468a637109d31f319ce02d9d743ecAndreas Huber#include <utils/String8.h>
29a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania#include <utils/Vector.h>
3089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/IMediaPlayerService.h>
3289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#include <media/MediaPlayerInterface.h>
33a64c8c79af1a15911c55306d83a797fa50969f77niko#include <media/Metadata.h>
346b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen#include <media/stagefright/foundation/ABase.h>
3589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
3664760240f931714858a59c1579f07264d7182ba2Dima Zavin#include <system/audio.h>
37fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin
3889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectnamespace android {
3989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
40a3f1fa308728976fc9ca1b4f37d26e633b32b9acGlenn Kastenclass AudioTrack;
4189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass IMediaRecorder;
4289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass IMediaMetadataRetriever;
4320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberclass IOMX;
44e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownclass IRemoteDisplay;
45e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownclass IRemoteDisplayClient;
46dac6a31a33ba53fb93850670cdddd1e6515dadceGloria Wangclass MediaRecorderClient;
4789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
4889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#define CALLBACK_ANTAGONIZER 0
4989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#if CALLBACK_ANTAGONIZER
5089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass Antagonizer {
5189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic:
5289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    Antagonizer(notify_callback_f cb, void* client);
5389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    void start() { mActive = true; }
5489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    void stop() { mActive = false; }
5589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    void kill();
5689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectprivate:
5789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static const int interval;
5889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    Antagonizer();
5989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static int callbackThread(void* cookie);
6089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    Mutex               mLock;
6189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    Condition           mCondition;
6289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    bool                mExit;
6389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    bool                mActive;
6489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    void*               mClient;
6589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    notify_callback_f   mCb;
6689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project};
6789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project#endif
6889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
6989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectclass MediaPlayerService : public BnMediaPlayerService
7089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project{
7189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class Client;
7289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
7389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class AudioOutput : public MediaPlayerBase::AudioSink
7489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
756b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        class CallbackData;
766b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen
776b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen     public:
78a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent                                AudioOutput(int sessionId);
7989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual                 ~AudioOutput();
8089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
8189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual bool            ready() const { return mTrack != NULL; }
8289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual bool            realtime() const { return true; }
8389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         bufferSize() const;
8489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         frameCount() const;
8589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         channelCount() const;
8689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         frameSize() const;
8789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual uint32_t        latency() const;
8889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual float           msecsPerFrame() const;
894110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual status_t        getPosition(uint32_t *position) const;
904110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual status_t        getFramesWritten(uint32_t *frameswritten) const;
914110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual int             getSessionId() const;
9220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
9320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber        virtual status_t        open(
94786618ffe881aceb64d65a6a2e2d76ede6e01ec0Jean-Michel Trivi                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
95e1c3962e268ffc12bfd1bd9ea84da1f135f36960Glenn Kasten                audio_format_t format, int bufferCount,
961948eb3ea6eee336e8cdab9b0c693f93f5f19993Eric Laurent                AudioCallback cb, void *cookie,
971948eb3ea6eee336e8cdab9b0c693f93f5f19993Eric Laurent                audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE);
9820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
9989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            start();
10089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         write(const void* buffer, size_t size);
10189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            stop();
10289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            flush();
10389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            pause();
10489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            close();
105fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten                void            setAudioStreamType(audio_stream_type_t streamType) { mStreamType = streamType; }
10689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                void            setVolume(float left, float right);
1077a8b0ed6419e57dd8b41d3806893d63d3df91aabJean-Michel Trivi        virtual status_t        setPlaybackRatePermille(int32_t ratePermille);
1082beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent                status_t        setAuxEffectSendLevel(float level);
1092beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent                status_t        attachAuxEffect(int effectId);
11089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        dump(int fd, const Vector<String16>& args) const;
11189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
11289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        static bool             isOnEmulator();
11389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        static int              getMinBufferCount();
1146b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                void            setNextOutput(const sp<AudioOutput>& nextOutput);
1156b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                void            switchToNextOutput();
1166b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        virtual bool            needsTrailingPadding() { return mNextOutput == NULL; }
1176b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen
11889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    private:
11989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        static void             setMinBufferCount();
12020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber        static void             CallbackWrapper(
121d217a8c4632b3e3065f8c2a26b9ce4dc4c97171fGlenn Kasten                int event, void *me, void *info);
12289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
12389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        AudioTrack*             mTrack;
1246b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        AudioTrack*             mRecycledTrack;
1256b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        sp<AudioOutput>         mNextOutput;
12620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber        AudioCallback           mCallback;
12720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber        void *                  mCallbackCookie;
1286b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        CallbackData *          mCallbackData;
1294110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        uint64_t                mBytesWritten;
130fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        audio_stream_type_t     mStreamType;
13189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        float                   mLeftVolume;
13289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        float                   mRightVolume;
1337a8b0ed6419e57dd8b41d3806893d63d3df91aabJean-Michel Trivi        int32_t                 mPlaybackRatePermille;
1347a8b0ed6419e57dd8b41d3806893d63d3df91aabJean-Michel Trivi        uint32_t                mSampleRateHz; // sample rate of the content, as set in open()
13589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        float                   mMsecsPerFrame;
136a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent        int                     mSessionId;
1372beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent        float                   mSendLevel;
1382beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent        int                     mAuxEffectId;
13989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        static bool             mIsOnEmulator;
14089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        static int              mMinBufferCount;  // 12 for emulator; otherwise 4
1411948eb3ea6eee336e8cdab9b0c693f93f5f19993Eric Laurent        audio_output_flags_t    mFlags;
14289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
1436b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        // CallbackData is what is passed to the AudioTrack as the "user" data.
1446b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        // We need to be able to target this to a different Output on the fly,
1456b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        // so we can't use the Output itself for this.
1466b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        class CallbackData {
1476b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        public:
1486b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            CallbackData(AudioOutput *cookie) {
1496b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                mData = cookie;
1506b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                mSwitching = false;
1516b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            }
1526b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            AudioOutput *   getOutput() { return mData;}
1536b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            void            setOutput(AudioOutput* newcookie) { mData = newcookie; }
1546b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            // lock/unlock are used by the callback before accessing the payload of this object
1556b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            void            lock() { mLock.lock(); }
1566b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            void            unlock() { mLock.unlock(); }
1576b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            // beginTrackSwitch/endTrackSwitch are used when this object is being handed over
1586b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            // to the next sink.
1596b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            void            beginTrackSwitch() { mLock.lock(); mSwitching = true; }
1606b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            void            endTrackSwitch() {
1616b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                if (mSwitching) {
1626b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                    mLock.unlock();
1636b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                }
1646b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen                mSwitching = false;
1656b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            }
1666b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        private:
1676b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            AudioOutput *   mData;
1686b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            mutable Mutex   mLock;
1696b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            bool            mSwitching;
1706b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen            DISALLOW_EVIL_CONSTRUCTORS(CallbackData);
1716b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        };
1726b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen
1736b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen    }; // AudioOutput
1746b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen
17589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
17689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class AudioCache : public MediaPlayerBase::AudioSink
17789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    {
17889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    public:
17989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                AudioCache(const char* name);
18089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual                 ~AudioCache() {}
18189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
18289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual bool            ready() const { return (mChannelCount > 0) && (mHeap->getHeapID() > 0); }
18389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual bool            realtime() const { return false; }
18489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         bufferSize() const { return frameSize() * mFrameCount; }
18589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         frameCount() const { return mFrameCount; }
18689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         channelCount() const { return (ssize_t)mChannelCount; }
187fce7a473248381cc83a01855f92581077d3c9ee2Dima Zavin        virtual ssize_t         frameSize() const { return ssize_t(mChannelCount * ((mFormat == AUDIO_FORMAT_PCM_16_BIT)?sizeof(int16_t):sizeof(u_int8_t))); }
18889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual uint32_t        latency() const;
18989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual float           msecsPerFrame() const;
1904110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual status_t        getPosition(uint32_t *position) const;
1914110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual status_t        getFramesWritten(uint32_t *frameswritten) const;
1924110c101c3d0dd8dbc44c8d2d0edd3e2e7d6652fMarco Nelissen        virtual int             getSessionId() const;
19320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
19420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber        virtual status_t        open(
195786618ffe881aceb64d65a6a2e2d76ede6e01ec0Jean-Michel Trivi                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
196786618ffe881aceb64d65a6a2e2d76ede6e01ec0Jean-Michel Trivi                audio_format_t format, int bufferCount = 1,
1971948eb3ea6eee336e8cdab9b0c693f93f5f19993Eric Laurent                AudioCallback cb = NULL, void *cookie = NULL,
1981948eb3ea6eee336e8cdab9b0c693f93f5f19993Eric Laurent                audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE);
19920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
2007d5b8a70c28c0d5746a600467b2887822dbff88eAndreas Huber        virtual void            start();
20189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual ssize_t         write(const void* buffer, size_t size);
2027d5b8a70c28c0d5746a600467b2887822dbff88eAndreas Huber        virtual void            stop();
20389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            flush() {}
20489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            pause() {}
20589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            close() {}
206fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten                void            setAudioStreamType(audio_stream_type_t streamType) {}
20789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                void            setVolume(float left, float right) {}
2087a8b0ed6419e57dd8b41d3806893d63d3df91aabJean-Michel Trivi        virtual status_t        setPlaybackRatePermille(int32_t ratePermille) { return INVALID_OPERATION; }
20989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                uint32_t        sampleRate() const { return mSampleRate; }
210e1c3962e268ffc12bfd1bd9ea84da1f135f36960Glenn Kasten                audio_format_t  format() const { return mFormat; }
21189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                size_t          size() const { return mSize; }
21289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                status_t        wait();
21389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
21489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                sp<IMemoryHeap> getHeap() const { return mHeap; }
21589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
216b483c4724846c0b8d4e82afcbb7c17f671bae81cGloria Wang        static  void            notify(void* cookie, int msg,
217b483c4724846c0b8d4e82afcbb7c17f671bae81cGloria Wang                                       int ext1, int ext2, const Parcel *obj);
21889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        dump(int fd, const Vector<String16>& args) const;
21989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
22089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    private:
22189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                AudioCache();
22289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
22389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Mutex               mLock;
22489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        Condition           mSignal;
22589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        sp<MemoryHeapBase>  mHeap;
22689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        float               mMsecsPerFrame;
22789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        uint16_t            mChannelCount;
228e1c3962e268ffc12bfd1bd9ea84da1f135f36960Glenn Kasten        audio_format_t      mFormat;
22989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        ssize_t             mFrameCount;
23089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        uint32_t            mSampleRate;
23189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        uint32_t            mSize;
23289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        int                 mError;
23389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        bool                mCommandComplete;
2347d5b8a70c28c0d5746a600467b2887822dbff88eAndreas Huber
2357d5b8a70c28c0d5746a600467b2887822dbff88eAndreas Huber        sp<Thread>          mCallbackThread;
2366b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen    }; // AudioCache
23789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
23889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectpublic:
23989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    static  void                instantiate();
24089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
24189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    // IMediaPlayerService interface
24289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual sp<IMediaRecorder>  createMediaRecorder(pid_t pid);
243dac6a31a33ba53fb93850670cdddd1e6515dadceGloria Wang    void    removeMediaRecorderClient(wp<MediaRecorderClient> client);
24489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual sp<IMediaMetadataRetriever> createMetadataRetriever(pid_t pid);
24589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
246d681bbb1767bed09415e050ba78975df214bcd68Dave Burke    virtual sp<IMediaPlayer>    create(pid_t pid, const sp<IMediaPlayerClient>& client, int audioSessionId);
247e2b1028852120bcfded33b8f06f66b780437fe92Andreas Huber
248e1c3962e268ffc12bfd1bd9ea84da1f135f36960Glenn Kasten    virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
249e1c3962e268ffc12bfd1bd9ea84da1f135f36960Glenn Kasten    virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
250318ad9c1d9d6515026dfc2c021359d27decaa7a1Andreas Huber    virtual sp<IOMX>            getOMX();
251ed3e3e046840d5bf1ca84a8c0cc097425e89d6d6Andreas Huber    virtual sp<ICrypto>         makeCrypto();
252efbb781c15abf8e085f5ab8d39710bd58ea0b6e4Andreas Huber    virtual sp<IHDCP>           makeHDCP();
253e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
254e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
255e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown            const String8& iface);
25689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    virtual status_t            dump(int fd, const Vector<String16>& args);
25789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
25889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project            void                removeClient(wp<Client> client);
25989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
2607cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    // For battery usage tracking purpose
2617cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    struct BatteryUsageInfo {
2627cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // how many streams are being played by one UID
2637cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        int     refCount;
2647cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // a temp variable to store the duration(ms) of audio codecs
2657cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // when we start a audio codec, we minus the system time from audioLastTime
2667cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // when we pause it, we add the system time back to the audioLastTime
2677cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // so after the pause, audioLastTime = pause time - start time
2687cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // if multiple audio streams are played (or recorded), then audioLastTime
2697cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // = the total playing time of all the streams
2707cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        int32_t audioLastTime;
2717cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // when all the audio streams are being paused, we assign audioLastTime to
2727cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // this variable, so this value could be provided to the battery app
2737cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        // in the next pullBatteryData call
2747cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        int32_t audioTotalTime;
2757cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang
2767cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        int32_t videoLastTime;
2777cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang        int32_t videoTotalTime;
2787cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    };
2797cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    KeyedVector<int, BatteryUsageInfo>    mBatteryData;
280a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania
2819ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    enum {
2829ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        SPEAKER,
2839ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        OTHER_AUDIO_DEVICE,
2849ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        SPEAKER_AND_OTHER,
2859ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        NUM_AUDIO_DEVICES
2869ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    };
2879ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang
2889ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    struct BatteryAudioFlingerUsageInfo {
2899ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        int refCount; // how many audio streams are being played
2909ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        int deviceOn[NUM_AUDIO_DEVICES]; // whether the device is currently used
2919ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        int32_t lastTime[NUM_AUDIO_DEVICES]; // in ms
2929ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        // totalTime[]: total time of audio output devices usage
2939ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang        int32_t totalTime[NUM_AUDIO_DEVICES]; // in ms
2949ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    };
2959ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang
2969ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    // This varialble is used to record the usage of audio output device
2979ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    // for battery app
2989ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang    BatteryAudioFlingerUsageInfo mBatteryAudio;
2999ee159b79022b2e1a050acb3890ce948e99e9ccbGloria Wang
3007cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    // Collect info of the codec usage from media player and media recorder
3017cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    virtual void                addBatteryData(uint32_t params);
3027cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    // API for the Battery app to pull the data of codecs usage
3037cf180c9bff69e5cc4a2f4e53b432db45ebbebabGloria Wang    virtual status_t            pullBatteryData(Parcel* reply);
30489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Projectprivate:
30589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
30689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    class Client : public BnMediaPlayer {
30789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        // IMediaPlayer interface
30889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual void            disconnect();
3091173118eace0e9e347cb007f0da817cee87579edGlenn Kasten        virtual status_t        setVideoSurfaceTexture(
3101173118eace0e9e347cb007f0da817cee87579edGlenn Kasten                                        const sp<ISurfaceTexture>& surfaceTexture);
31189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        prepareAsync();
31289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        start();
31389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        stop();
31489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        pause();
31589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        isPlaying(bool* state);
31689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        seekTo(int msec);
31789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        getCurrentPosition(int* msec);
31889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        getDuration(int* msec);
31989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        reset();
320fff6d715a8db0daf08a50634f242c40268de3d49Glenn Kasten        virtual status_t        setAudioStreamType(audio_stream_type_t type);
32189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        setLooping(int loop);
32289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        setVolume(float leftVolume, float rightVolume);
3231d187f1a86855f5f0694d7ec30efc9833bf7c589Nicolas Catania        virtual status_t        invoke(const Parcel& request, Parcel *reply);
324a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania        virtual status_t        setMetadataFilter(const Parcel& filter);
3254829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        virtual status_t        getMetadata(bool update_only,
3264829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania                                            bool apply_filter,
3274829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania                                            Parcel *reply);
3282beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent        virtual status_t        setAuxEffectSendLevel(float level);
3292beeb50b1bba9e92f6cacfeca37fe9fa9d36ead1Eric Laurent        virtual status_t        attachAuxEffect(int effectId);
3304f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang        virtual status_t        setParameter(int key, const Parcel &request);
3314f9e47f2c03ce36261c4717cd7e131d7940bb068Gloria Wang        virtual status_t        getParameter(int key, Parcel *reply);
332c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman        virtual status_t        setRetransmitEndpoint(const struct sockaddr_in* endpoint);
33344a7e42f0310831e6a846d1b6bb40bf3a399bf6dJohn Grossman        virtual status_t        getRetransmitEndpoint(struct sockaddr_in* endpoint);
3346b74d671a1321a6ecc4a40b6c87beedfecc1ec44Marco Nelissen        virtual status_t        setNextPlayer(const sp<IMediaPlayer>& player);
33589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
33689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        sp<MediaPlayerBase>     createPlayer(player_type playerType);
3372db8455d8f4468a637109d31f319ce02d9d743ecAndreas Huber
338d681bbb1767bed09415e050ba78975df214bcd68Dave Burke        virtual status_t        setDataSource(
3392db8455d8f4468a637109d31f319ce02d9d743ecAndreas Huber                        const char *url,
3402db8455d8f4468a637109d31f319ce02d9d743ecAndreas Huber                        const KeyedVector<String8, String8> *headers);
3412db8455d8f4468a637109d31f319ce02d9d743ecAndreas Huber
342d681bbb1767bed09415e050ba78975df214bcd68Dave Burke        virtual status_t        setDataSource(int fd, int64_t offset, int64_t length);
343e2b1028852120bcfded33b8f06f66b780437fe92Andreas Huber
344d681bbb1767bed09415e050ba78975df214bcd68Dave Burke        virtual status_t        setDataSource(const sp<IStreamSource> &source);
345e2b1028852120bcfded33b8f06f66b780437fe92Andreas Huber
346c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman        sp<MediaPlayerBase>     setDataSource_pre(player_type playerType);
347c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman        void                    setDataSource_post(const sp<MediaPlayerBase>& p,
348c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman                                                   status_t status);
349c795b64060c3af9d7961fc1371e4ccfa8ee3e450John Grossman
350b483c4724846c0b8d4e82afcbb7c17f671bae81cGloria Wang        static  void            notify(void* cookie, int msg,
351b483c4724846c0b8d4e82afcbb7c17f671bae81cGloria Wang                                       int ext1, int ext2, const Parcel *obj);
35289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
35389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                pid_t           pid() const { return mPid; }
35489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual status_t        dump(int fd, const Vector<String16>& args) const;
35589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
356a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent                int             getAudioSessionId() { return mAudioSessionId; }
357a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent
35889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project    private:
35989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        friend class MediaPlayerService;
36089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                Client( const sp<MediaPlayerService>& service,
36189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                        pid_t pid,
36289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                        int32_t connId,
363a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent                                        const sp<IMediaPlayerClient>& client,
3649b80c2bdb205bc143104f54d0743b6eedd67b14eAndreas Huber                                        int audioSessionId,
3659b80c2bdb205bc143104f54d0743b6eedd67b14eAndreas Huber                                        uid_t uid);
36689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                                Client();
36789fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        virtual                 ~Client();
36889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
36989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                void            deletePlayer();
37089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
37189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        sp<MediaPlayerBase>     getPlayer() const { Mutex::Autolock lock(mLock); return mPlayer; }
37289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project
373a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania
3744829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania
3754829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        // @param type Of the metadata to be tested.
3764829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        // @return true if the metadata should be dropped according to
3774829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        //              the filters.
378a64c8c79af1a15911c55306d83a797fa50969f77niko        bool shouldDropMetadata(media::Metadata::Type type) const;
3794829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania
3804829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        // Add a new element to the set of metadata updated. Noop if
3814829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        // the element exists already.
3824829038419910aa6e75ce8992d45a223452d5c67Nicolas Catania        // @param type Of the metadata to be recorded.
383a64c8c79af1a15911c55306d83a797fa50969f77niko        void addNewMetadataUpdate(media::Metadata::Type type);
384a7e0e8b4c429fc68eb1bd5b5a30f5b91352288f9Nicolas Catania
3857dae00baa6e8957be15523c46bb948bd1dde64c3Jamie Gennis        // Disconnect from the currently connected ANativeWindow.
3867dae00baa6e8957be15523c46bb948bd1dde64c3Jamie Gennis        void disconnectNativeWindow();
3877dae00baa6e8957be15523c46bb948bd1dde64c3Jamie Gennis
38889fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project        mutable     Mutex                       mLock;
38989fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    sp<MediaPlayerBase>         mPlayer;
39089fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    sp<MediaPlayerService>      mService;
39189fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    sp<IMediaPlayerClient>      mClient;
39289fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    sp<AudioOutput>             mAudioOutput;
39389fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    pid_t                       mPid;
39489fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    status_t                    mStatus;
39589fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    bool                        mLoop;
39689fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5The Android Open Source Project                    int32_t                     mConnId;
397a514bdb58b5de4986679f72b7204b4764f7a2778Eric Laurent                    int                         mAudioSessionId;
398