2 Copyright 2004-2006 Chris Tallon, Andreas Vogel
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
35 #include "messagequeue.h"
41 #include "threadwin.h"
52 class AudioPlayer : public Thread_TYPE, public Callback, public TimerReceiver
55 //the instance method to create the
56 //player instance - only call thie for
57 //the first time in the main thread (no lock!)
58 //later you can change the view the player is connect with
59 //a view that "goes" should call getInstance(NULL,false) to detach
60 //the last media view should shutdown the player
61 static AudioPlayer * getInstance(Boxx * frontend, bool create=true);
62 //start the player thread
65 //is the player still running?
66 bool isPlayerRunning();
70 //each of the commands works as a request
71 //only after getSequence returned the same sequence as those commands this is
72 //handled by the player and getError is valid
73 int play(const MediaURI *uri);
74 //stop the player without shutting it down
80 int jumpToPercent(double percent);
81 int skipForward(int sec);
82 int skipBackward(int sec);
84 //info functions for frontend
85 //delete provided String afterwards
86 //get the played title from ID3 Tag - or NULL
89 //multi line String containing ID3 infos
92 //wait for a particular sequence to be handled
93 //timeout in s, returnes current sequence, -1 on timeout
94 int waitForSequence(int timeout, int sequence);
99 //get current position in s
100 ULONG getCurrentTimes();
104 int getCurrentBitrate();
107 virtual void call(void * caller);
111 const static UCHAR S_PLAY = 1;
112 const static UCHAR S_PAUSE = 2;
113 const static UCHAR S_POSITION = 3;
114 //player finished a song - no reset, next will follow
115 const static UCHAR S_DONE=5;
116 const static UCHAR S_STOP = 6;
117 const static UCHAR S_ERROR = 8;
118 const static UCHAR S_FF = 9;
119 const static UCHAR S_BACK = 10;
121 //message parameters for frontend messages
122 const static ULONG CONNECTION_LOST=1;
123 const static ULONG STREAM_END=2;
124 const static ULONG STREAM_ERR=3;
125 const static ULONG STATUS_CHANGE=4; //some info has been changed
126 const static ULONG NEW_SONG=5; //some info has been changed
127 const static ULONG SHORT_UPDATE=6; //timer info update
128 const static ULONG EXTERN1=7; //for other users as parameter to player event
130 virtual void timercall(int reference);
134 void threadPostStopCleanup();
137 //to guess lengthes if the demux does not know
138 const static ULONG DEFAULT_BITRATE=128000;
139 AudioPlayer(Boxx *frontend);
140 virtual ~AudioPlayer();
141 static AudioPlayer * instance;
147 DemuxerAudio *demuxer;
151 const static int FEEDER_START=1;
152 const static int FEEDER_STOP=2;
153 const static int FEEDER_PAUSE=3;
154 const static int FEEDER_UNPAUSE=4;
155 void controlFeeder(int action) ;
158 //synchronized get/set methods for states
159 int setRequestedState(UCHAR st);
160 void setState(UCHAR st);
162 //to be called from within the thread
165 //variables used by the thread
176 ULLONG requestedStreampos;
179 //the buffer len in bytes
180 const static int BUFLEN=50*1024;
183 int requestedSequence;
187 int currentPlaySequence;
188 //sequence that is changed for each new filename
197 void sendFrontendMessage(ULONG para);
199 void waitTimed(int ms);