blob: 06e4b7042d83b5ce26a3db6ca2c4e6516e8859f5 [file] [log] [blame]
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -08001/*
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();
Andreas Huber2db84552010-01-28 11:19:57 -080033
34 virtual status_t setDataSource(
35 const char* path, const KeyedVector<String8, String8> *headers);
36
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080037 virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
Andreas Huber5daeb122010-08-16 08:49:37 -070038 virtual status_t setVideoISurface(const sp<ISurface>& surface) { return UNKNOWN_ERROR; }
39 virtual status_t setVideoSurface(const sp<Surface>& surface) { return UNKNOWN_ERROR; }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080040 virtual status_t prepare();
41 virtual status_t prepareAsync();
42 virtual status_t start();
43 virtual status_t stop();
44 virtual status_t seekTo(int msec);
45 virtual status_t pause();
46 virtual bool isPlaying();
47 virtual status_t getCurrentPosition(int* msec);
48 virtual status_t getDuration(int* msec);
49 virtual status_t release();
50 virtual status_t reset();
51 virtual status_t setLooping(int loop);
52 virtual player_type playerType() { return SONIVOX_PLAYER; }
nikod608a812009-07-16 16:39:53 -070053 virtual status_t invoke(const Parcel& request, Parcel *reply) {
54 return INVALID_OPERATION;
55 }
The Android Open Source Project89fa4ad2009-03-03 19:31:44 -080056
57private:
58 status_t createOutputTrack();
59 status_t reset_nosync();
60 static int renderThread(void*);
61 int render();
62 void updateState(){ EAS_State(mEasData, mEasHandle, &mState); }
63
64 Mutex mMutex;
65 Condition mCondition;
66 EAS_DATA_HANDLE mEasData;
67 EAS_HANDLE mEasHandle;
68 EAS_PCM* mAudioBuffer;
69 EAS_I32 mPlayTime;
70 EAS_I32 mDuration;
71 EAS_STATE mState;
72 EAS_FILE mFileLocator;
73 int mStreamType;
74 bool mLoop;
75 volatile bool mExit;
76 bool mPaused;
77 volatile bool mRender;
78 pid_t mTid;
79};
80
81}; // namespace android
82
83#endif // ANDROID_MIDIFILE_H