Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7418e385 authored by Glenn Kasten's avatar Glenn Kasten Committed by Android (Google) Code Review
Browse files

Merge "MidiFile uses C++ Thread not createThreadEtc"

parents b447e9ce 376c3930
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ MidiFile::MidiFile() :
    // create playback thread
    {
        Mutex::Autolock l(mMutex);
        createThreadEtc(renderThread, this, "midithread", ANDROID_PRIORITY_AUDIO);
        mThread = new MidiFileThread(this);
        mThread->run("midithread", ANDROID_PRIORITY_AUDIO);
        mCondition.wait(mMutex);
        ALOGV("thread started");
    }
@@ -427,11 +428,6 @@ status_t MidiFile::createOutputTrack() {
    return NO_ERROR;
}

int MidiFile::renderThread(void* p) {

    return ((MidiFile*)p)->render();
}

int MidiFile::render() {
    EAS_RESULT result = EAS_FAILURE;
    EAS_I32 count;
+24 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

namespace android {

// Note that the name MidiFile is misleading; this actually represents a MIDI file player
class MidiFile : public MediaPlayerInterface {
public:
                        MidiFile();
@@ -65,7 +66,6 @@ public:
private:
            status_t    createOutputTrack();
            status_t    reset_nosync();
    static  int         renderThread(void*);
            int         render();
            void        updateState(){ EAS_State(mEasData, mEasHandle, &mState); }

@@ -84,6 +84,29 @@ private:
    bool                mPaused;
    volatile bool       mRender;
    pid_t               mTid;

    class MidiFileThread : public Thread {
    public:
        MidiFileThread(MidiFile *midiPlayer) : mMidiFile(midiPlayer) {
        }

    protected:
        virtual ~MidiFileThread() {}

    private:
        MidiFile *mMidiFile;

        bool threadLoop() {
            int result;
            result = mMidiFile->render();
            return false;
        }

        MidiFileThread(const MidiFileThread &);
        MidiFileThread &operator=(const MidiFileThread &);
    };

    sp<MidiFileThread> mThread;
};

}; // namespace android