nathan@0
|
1 |
/*
|
nathan@0
|
2 |
* MP3/MPlayer plugin to VDR (C++)
|
nathan@0
|
3 |
*
|
nathan@0
|
4 |
* (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
|
nathan@0
|
5 |
*
|
nathan@0
|
6 |
* This code is free software; you can redistribute it and/or
|
nathan@0
|
7 |
* modify it under the terms of the GNU General Public License
|
nathan@0
|
8 |
* as published by the Free Software Foundation; either version 2
|
nathan@0
|
9 |
* of the License, or (at your option) any later version.
|
nathan@0
|
10 |
*
|
nathan@0
|
11 |
* This code is distributed in the hope that it will be useful,
|
nathan@0
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nathan@0
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nathan@0
|
14 |
* GNU General Public License for more details.
|
nathan@0
|
15 |
*
|
nathan@0
|
16 |
* You should have received a copy of the GNU General Public License
|
nathan@0
|
17 |
* along with this program; if not, write to the Free Software
|
nathan@0
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
nathan@0
|
19 |
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
|
nathan@0
|
20 |
*/
|
nathan@0
|
21 |
|
nathan@0
|
22 |
#ifndef ___DVB_MP3_H
|
nathan@0
|
23 |
#define ___DVB_MP3_H
|
nathan@0
|
24 |
|
nathan@0
|
25 |
#include <vdr/thread.h>
|
nathan@0
|
26 |
#include <vdr/player.h>
|
nathan@0
|
27 |
|
nathan@0
|
28 |
// -------------------------------------------------------------------
|
nathan@0
|
29 |
|
nathan@0
|
30 |
class cRingBufferFrame;
|
nathan@0
|
31 |
class cFrame;
|
nathan@0
|
32 |
|
nathan@0
|
33 |
class cPlayList;
|
nathan@0
|
34 |
class cSong;
|
nathan@0
|
35 |
class cSongInfo;
|
nathan@0
|
36 |
class cBackgroundScan;
|
nathan@0
|
37 |
class cDecoder;
|
nathan@0
|
38 |
class cOutput;
|
nathan@0
|
39 |
class cOutputDvb;
|
nathan@0
|
40 |
class cShuffle;
|
nathan@0
|
41 |
|
nathan@0
|
42 |
// -------------------------------------------------------------------
|
nathan@0
|
43 |
|
nathan@0
|
44 |
class cMP3PlayInfo {
|
nathan@0
|
45 |
public:
|
nathan@0
|
46 |
char Title[64], Artist[64], Album[64], SMode[32], Filename[256];
|
nathan@0
|
47 |
int Year, SampleFreq, Bitrate, MaxBitrate;
|
nathan@0
|
48 |
int Num, MaxNum;
|
nathan@0
|
49 |
// not in hash
|
nathan@0
|
50 |
bool Loop, Shuffle;
|
nathan@0
|
51 |
int Hash;
|
nathan@0
|
52 |
};
|
nathan@0
|
53 |
|
nathan@0
|
54 |
// -------------------------------------------------------------------
|
nathan@0
|
55 |
|
nathan@0
|
56 |
class cPlayManager : public cThread {
|
nathan@0
|
57 |
private:
|
nathan@0
|
58 |
cMutex listMutex;
|
nathan@0
|
59 |
cCondVar fgCond, bgCond;
|
nathan@0
|
60 |
cList<cSong> list;
|
nathan@0
|
61 |
cSong *curr;
|
nathan@0
|
62 |
int currIndex, maxIndex;
|
nathan@0
|
63 |
//
|
nathan@0
|
64 |
cSong *play;
|
nathan@0
|
65 |
bool playNew, eol;
|
nathan@0
|
66 |
//
|
nathan@0
|
67 |
cShuffle *shuffle;
|
nathan@0
|
68 |
bool shuffleMode, loopMode;
|
nathan@0
|
69 |
//
|
nathan@0
|
70 |
cSong *scan;
|
nathan@0
|
71 |
bool stopscan, throttle, pass2, release;
|
nathan@0
|
72 |
//
|
nathan@0
|
73 |
virtual void Action(void);
|
nathan@0
|
74 |
void NoScan(cSong *nono);
|
nathan@0
|
75 |
void NoPlay(cSong *nono);
|
nathan@0
|
76 |
void ThrottleWait(void);
|
nathan@0
|
77 |
public:
|
nathan@0
|
78 |
cPlayManager(void);
|
nathan@0
|
79 |
~cPlayManager();
|
nathan@0
|
80 |
// Control interface (to be called from frontend thread only!)
|
nathan@0
|
81 |
void Flush(void);
|
nathan@0
|
82 |
void Add(cPlayList *pl);
|
nathan@0
|
83 |
bool Next(void);
|
nathan@0
|
84 |
bool Prev(void);
|
nathan@0
|
85 |
void Goto(int num);
|
nathan@0
|
86 |
void ToggleShuffle(void);
|
nathan@0
|
87 |
void ToggleLoop(void);
|
nathan@0
|
88 |
bool Info(int num, cMP3PlayInfo *info);
|
nathan@0
|
89 |
void Halt(void);
|
nathan@0
|
90 |
// Player interface (to be called from player thread only!)
|
nathan@0
|
91 |
cSong *Current(void);
|
nathan@0
|
92 |
bool NewCurrent(void);
|
nathan@0
|
93 |
bool NextCurrent(void);
|
nathan@0
|
94 |
void Release(void);
|
nathan@0
|
95 |
void Throttle(bool thr);
|
nathan@0
|
96 |
};
|
nathan@0
|
97 |
|
nathan@0
|
98 |
extern cPlayManager *mgr;
|
nathan@0
|
99 |
|
nathan@0
|
100 |
// -------------------------------------------------------------------
|
nathan@0
|
101 |
|
nathan@0
|
102 |
class cMP3Player : public cPlayer, cThread {
|
nathan@0
|
103 |
friend class cOutputDvb;
|
nathan@0
|
104 |
private:
|
nathan@0
|
105 |
bool active, started;
|
nathan@0
|
106 |
cRingBufferFrame *ringBuffer;
|
nathan@0
|
107 |
cMutex playModeMutex;
|
nathan@0
|
108 |
cCondVar playModeCond;
|
nathan@0
|
109 |
//
|
nathan@0
|
110 |
int playindex, total;
|
nathan@0
|
111 |
cDecoder *decoder;
|
nathan@0
|
112 |
cOutput *output;
|
nathan@0
|
113 |
cFrame *rframe, *pframe;
|
nathan@0
|
114 |
enum ePlayMode { pmPlay, pmStopped, pmPaused, pmStartup };
|
nathan@0
|
115 |
ePlayMode playMode;
|
nathan@0
|
116 |
enum eState { msStart, msStop, msDecode, msNormalize, msResample, msOutput, msError, msEof, msWait, msRestart };
|
nathan@0
|
117 |
eState state;
|
nathan@0
|
118 |
bool levelgood, isStream;
|
nathan@0
|
119 |
unsigned int dvbSampleRate;
|
nathan@0
|
120 |
//
|
nathan@0
|
121 |
void Empty(void);
|
nathan@0
|
122 |
void StopPlay(void);
|
nathan@0
|
123 |
void SetPlayMode(ePlayMode mode);
|
nathan@0
|
124 |
void WaitPlayMode(ePlayMode mode, bool inv);
|
nathan@0
|
125 |
protected:
|
nathan@0
|
126 |
virtual void Activate(bool On);
|
nathan@0
|
127 |
virtual void Action(void);
|
nathan@0
|
128 |
public:
|
nathan@0
|
129 |
cMP3Player(void);
|
nathan@0
|
130 |
virtual ~cMP3Player();
|
nathan@0
|
131 |
void Pause(void);
|
nathan@0
|
132 |
void Play(void);
|
nathan@0
|
133 |
bool PrevCheck(void);
|
nathan@0
|
134 |
void SkipSeconds(int secs);
|
nathan@0
|
135 |
virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false);
|
nathan@0
|
136 |
virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed);
|
nathan@0
|
137 |
bool Active(void) { return active; }
|
nathan@0
|
138 |
bool IsStream(void) { return isStream; }
|
nathan@0
|
139 |
};
|
nathan@0
|
140 |
|
nathan@0
|
141 |
#endif //___DVB_MP3_H
|