1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/player-mp3.h Sat Dec 29 14:47:40 2007 +0100
1.3 @@ -0,0 +1,141 @@
1.4 +/*
1.5 + * MP3/MPlayer plugin to VDR (C++)
1.6 + *
1.7 + * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
1.8 + *
1.9 + * This code is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License
1.11 + * as published by the Free Software Foundation; either version 2
1.12 + * of the License, or (at your option) any later version.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.22 + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
1.23 + */
1.24 +
1.25 +#ifndef ___DVB_MP3_H
1.26 +#define ___DVB_MP3_H
1.27 +
1.28 +#include <vdr/thread.h>
1.29 +#include <vdr/player.h>
1.30 +
1.31 +// -------------------------------------------------------------------
1.32 +
1.33 +class cRingBufferFrame;
1.34 +class cFrame;
1.35 +
1.36 +class cPlayList;
1.37 +class cSong;
1.38 +class cSongInfo;
1.39 +class cBackgroundScan;
1.40 +class cDecoder;
1.41 +class cOutput;
1.42 +class cOutputDvb;
1.43 +class cShuffle;
1.44 +
1.45 +// -------------------------------------------------------------------
1.46 +
1.47 +class cMP3PlayInfo {
1.48 +public:
1.49 + char Title[64], Artist[64], Album[64], SMode[32], Filename[256];
1.50 + int Year, SampleFreq, Bitrate, MaxBitrate;
1.51 + int Num, MaxNum;
1.52 + // not in hash
1.53 + bool Loop, Shuffle;
1.54 + int Hash;
1.55 + };
1.56 +
1.57 +// -------------------------------------------------------------------
1.58 +
1.59 +class cPlayManager : public cThread {
1.60 +private:
1.61 + cMutex listMutex;
1.62 + cCondVar fgCond, bgCond;
1.63 + cList<cSong> list;
1.64 + cSong *curr;
1.65 + int currIndex, maxIndex;
1.66 + //
1.67 + cSong *play;
1.68 + bool playNew, eol;
1.69 + //
1.70 + cShuffle *shuffle;
1.71 + bool shuffleMode, loopMode;
1.72 + //
1.73 + cSong *scan;
1.74 + bool stopscan, throttle, pass2, release;
1.75 + //
1.76 + virtual void Action(void);
1.77 + void NoScan(cSong *nono);
1.78 + void NoPlay(cSong *nono);
1.79 + void ThrottleWait(void);
1.80 +public:
1.81 + cPlayManager(void);
1.82 + ~cPlayManager();
1.83 + // Control interface (to be called from frontend thread only!)
1.84 + void Flush(void);
1.85 + void Add(cPlayList *pl);
1.86 + bool Next(void);
1.87 + bool Prev(void);
1.88 + void Goto(int num);
1.89 + void ToggleShuffle(void);
1.90 + void ToggleLoop(void);
1.91 + bool Info(int num, cMP3PlayInfo *info);
1.92 + void Halt(void);
1.93 + // Player interface (to be called from player thread only!)
1.94 + cSong *Current(void);
1.95 + bool NewCurrent(void);
1.96 + bool NextCurrent(void);
1.97 + void Release(void);
1.98 + void Throttle(bool thr);
1.99 + };
1.100 +
1.101 +extern cPlayManager *mgr;
1.102 +
1.103 +// -------------------------------------------------------------------
1.104 +
1.105 +class cMP3Player : public cPlayer, cThread {
1.106 +friend class cOutputDvb;
1.107 +private:
1.108 + bool active, started;
1.109 + cRingBufferFrame *ringBuffer;
1.110 + cMutex playModeMutex;
1.111 + cCondVar playModeCond;
1.112 +//
1.113 + int playindex, total;
1.114 + cDecoder *decoder;
1.115 + cOutput *output;
1.116 + cFrame *rframe, *pframe;
1.117 + enum ePlayMode { pmPlay, pmStopped, pmPaused, pmStartup };
1.118 + ePlayMode playMode;
1.119 + enum eState { msStart, msStop, msDecode, msNormalize, msResample, msOutput, msError, msEof, msWait, msRestart };
1.120 + eState state;
1.121 + bool levelgood, isStream;
1.122 + unsigned int dvbSampleRate;
1.123 +//
1.124 + void Empty(void);
1.125 + void StopPlay(void);
1.126 + void SetPlayMode(ePlayMode mode);
1.127 + void WaitPlayMode(ePlayMode mode, bool inv);
1.128 +protected:
1.129 + virtual void Activate(bool On);
1.130 + virtual void Action(void);
1.131 +public:
1.132 + cMP3Player(void);
1.133 + virtual ~cMP3Player();
1.134 + void Pause(void);
1.135 + void Play(void);
1.136 + bool PrevCheck(void);
1.137 + void SkipSeconds(int secs);
1.138 + virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false);
1.139 + virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed);
1.140 + bool Active(void) { return active; }
1.141 + bool IsStream(void) { return isStream; }
1.142 + };
1.143 +
1.144 +#endif //___DVB_MP3_H