blob: 9d2dfdd72f9d6485a6a5e221b4d8b8e97d16edca [file] [log] [blame]
The Android Open Source Project2729ea92008-10-21 07:00:00 -07001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef ANDROID_MIDIFILE_H
19#define ANDROID_MIDIFILE_H
20
21#include <media/MediaPlayerInterface.h>
22#include <media/AudioTrack.h>
23#include <libsonivox/eas.h>
24
25namespace android {
26
27class MidiFile : public MediaPlayerInterface {
28public:
29 MidiFile();
30 ~MidiFile();
31
32 virtual status_t initCheck();
33 virtual status_t setSigBusHandlerStructTLSKey(pthread_key_t key);
34 virtual status_t setDataSource(const char* path);
35 virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
36 virtual status_t setVideoSurface(const sp<ISurface>& surface) { return UNKNOWN_ERROR; }
37 virtual status_t prepare();
38 virtual status_t prepareAsync();
39 virtual status_t start();
40 virtual status_t stop();
41 virtual status_t seekTo(int msec);
42 virtual status_t pause();
43 virtual bool isPlaying();
44 virtual status_t getCurrentPosition(int* msec);
45 virtual status_t getDuration(int* msec);
46 virtual status_t release();
47 virtual status_t reset();
48 virtual status_t setLooping(int loop);
49 virtual player_type playerType() { return SONIVOX_PLAYER; }
50
51private:
52 status_t createOutputTrack();
53 status_t reset_nosync();
54 static int renderThread(void*);
55 int render();
56 void updateState(){ EAS_State(mEasData, mEasHandle, &mState); }
57
58 Mutex mMutex;
59 Condition mCondition;
60 int* mMemFailedVar;
61 EAS_DATA_HANDLE mEasData;
62 EAS_HANDLE mEasHandle;
63 EAS_PCM* mAudioBuffer;
64 EAS_I32 mPlayTime;
65 EAS_I32 mDuration;
66 EAS_STATE mState;
67 EAS_FILE mFileLocator;
68 int mStreamType;
69 bool mLoop;
70 volatile bool mExit;
71 bool mPaused;
72 volatile bool mRender;
73 pid_t mTid;
74};
75
76}; // namespace android
77
78#endif // ANDROID_MIDIFILE_H
79