summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-06-23 17:11:35 -0700
committerGlenn Kasten <gkasten@google.com>2011-11-16 15:43:31 -0800
commit90100b5573f95e8404c6e2917520e090fe8b49fd (patch)
tree7d12fdb072b5eee22499efeff79d246eb3657e5f
parent5c052218128013d630b4d9a84393ebfbff11f3e8 (diff)
downloadframeworks_av-90100b5573f95e8404c6e2917520e090fe8b49fd.zip
frameworks_av-90100b5573f95e8404c6e2917520e090fe8b49fd.tar.gz
frameworks_av-90100b5573f95e8404c6e2917520e090fe8b49fd.tar.bz2
MidiFile uses C++ Thread not createThreadEtc
This permits leveraging future improvements to Thread. Change-Id: I323b709e935c47fa3c6041cb8b82fda994e78b56
-rw-r--r--media/libmediaplayerservice/MidiFile.cpp8
-rw-r--r--media/libmediaplayerservice/MidiFile.h25
2 files changed, 26 insertions, 7 deletions
diff --git a/media/libmediaplayerservice/MidiFile.cpp b/media/libmediaplayerservice/MidiFile.cpp
index 85b1f9d..4946956 100644
--- a/media/libmediaplayerservice/MidiFile.cpp
+++ b/media/libmediaplayerservice/MidiFile.cpp
@@ -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;
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index 3469389..2a0dcf9 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -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