/**
 * audio_player.h: The audio player
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2007
 */
/*
 * audio_player.h: The audio player and control interface
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id: audio_player.h,v 1.1.1.1 2005/12/20 14:11:45 cm Exp $
 */

#ifndef AUDIO_PLAYER_H_
#define AUDIO_PLAYER_H_

#include <stdint.h>
#include <vdr/player.h>
#include "config.h"
#include "audio_decoder_mp3_http.h"


class cAudioPlayer : public cPlayer, public cThread
{
private:
	SocketHandler h;
	cHttpMp3Decoder *httpmp3decoder;	
private:
	bool m_indexTrack;
	int m_curFrame;
	int m_maxFrames;
	enum ePlayMode
	{	pmPlay=0, pmPaused, pmStopped, pmBuffered, pmNone};
	ePlayMode m_playMode;
	cFrame *mpo_readFrame, *mpo_playFrame;
	cRingBufferFrame *mpo_ringBufferFrame;
	cCondVar mo_playerCond;
	cMutex mo_playerMutex;
	void Clear( void );
	void Reset( void );
	void SetPlayMode( ePlayMode mode );
	void WaitPlayMode( ePlayMode test, bool negate, ePlayMode wait );
protected:
	virtual void Action( void );
public:
	cAudioPlayer( void );
	virtual ~cAudioPlayer( void );
	void Play( void );
	void Pause( void );
	void Stop( void );
	void Next( void );
	virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false);
};


#endif /*AUDIO_PLAYER_H_*/
