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, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "messagequeue.h"
39 #include "timerreceiver.h"
42 #include "threadwin.h"
53 class AudioPlayer : public Thread_TYPE, public Callback, public TimerReceiver
56 //the instance method to create the
57 //player instance - only call thie for
58 //the first time in the main thread (no lock!)
59 //later you can change the view the player is connect with
60 //a view that "goes" should call getInstance(NULL,false) to detach
61 //the last media view should shutdown the player
62 static AudioPlayer * getInstance(Boxx * frontend, bool create=true);
63 //start the player thread
66 //is the player still running?
67 bool isPlayerRunning();
71 //each of the commands works as a request
72 //only after getSequence returned the same sequence as those commands this is
73 //handled by the player and getError is valid
74 int play(const char * filename);
75 //stop the player without shutting it down
81 int jumpToPercent(double percent);
82 int skipForward(int sec);
83 int skipBackward(int sec);
85 //info functions for frontend
86 //delete provided String afterwards
87 //get the played title from ID3 Tag - or NULL
90 //multi line String containing ID3 infos
93 //wait for a particular sequence to be handled
94 //timeout in s, returnes current sequence, -1 on timeout
95 int waitForSequence(int timeout, int sequence);
100 //get current position in s
101 ULONG getCurrentTimes();
105 int getCurrentBitrate();
108 virtual void call(void * caller);
112 const static UCHAR S_PLAY = 1;
113 const static UCHAR S_PAUSE = 2;
114 const static UCHAR S_POSITION = 3;
115 //player finished a song - no reset, next will follow
116 const static UCHAR S_DONE=5;
117 const static UCHAR S_STOP = 6;
118 const static UCHAR S_ERROR = 8;
119 const static UCHAR S_FF = 9;
120 const static UCHAR S_BACK = 10;
122 //message parameters for frontend messages
123 const static ULONG CONNECTION_LOST=1;
124 const static ULONG STREAM_END=2;
125 const static ULONG STREAM_ERR=3;
126 const static ULONG STATUS_CHANGE=4; //some info has been changed
127 const static ULONG NEW_SONG=5; //some info has been changed
128 const static ULONG SHORT_UPDATE=6; //timer info update
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 ULONG 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
193 void handleVDRerror();
195 void sendFrontendMessage(ULONG para);
197 void waitTimed(int ms);