21#include "audio_phonon.h"
26#include <phonon/audiooutput.h>
27#include <phonon/audiopath.h>
28#include <phonon/mediaobject.h>
30LibWMPcmPlayer::LibWMPcmPlayer() : AbstractMediaStream(NULL),
32 m_cmd(WM_CDM_UNKNOWN),
36 Phonon::AudioPath* m_path =
new Phonon::AudioPath(
this);
37 m_path->addOutput(m_output);
39 m_media->addAudioPath(m_path);
40 m_media->setCurrentSource(
this);
41 setStreamSeekable(
false);
42 setStreamSize(0xffffffff);
44 connect(
this, SIGNAL(cmdChanged(
int)),
this, SLOT(executeCmd(
int)));
45 connect(
this, SIGNAL(nextBuffer(cdda_block*)),
this, SLOT(playBuffer(cdda_block*)));
46 connect(m_media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
47 this, SLOT(stateChanged(Phonon::State,Phonon::State)));
49 DEBUGLOG(
"writeHeader\n");
50 writeData( wavHeader() );
51 DEBUGLOG(
"writeHeader end\n");
54LibWMPcmPlayer::~LibWMPcmPlayer()
66 <<
static_cast<quint32
>( 0x7FFFFFFF )
69 <<
static_cast<quint32
>( 16 )
70 <<
static_cast<quint16
>( 1 )
71 <<
static_cast<quint16
>( 2 )
72 <<
static_cast<quint32
>( 44100 )
73 <<
static_cast<quint32
>( 2*2*44100 )
74 <<
static_cast<quint16
>( 2*2 )
75 <<
static_cast<quint16
>( 16 )
77 <<
static_cast<quint32
>( 0x7FFFFFFF-36 )
83void LibWMPcmPlayer::reset()
87 DEBUGLOG(
"writeHeader\n");
89 DEBUGLOG(
"writeHeader end\n");
92void LibWMPcmPlayer::needData()
94 DEBUGLOG(
"needData\n");
101void LibWMPcmPlayer::setNextBuffer(
struct cdda_block *blk)
105 m_readyToPlay.
wait(&m_mutex);
109void LibWMPcmPlayer::playBuffer(
struct cdda_block *blk)
111 if(m_cmd != WM_CDM_PLAYING) {
112 Q_EMIT cmdChanged(WM_CDM_PLAYING);
113 m_cmd = WM_CDM_PLAYING;
119void LibWMPcmPlayer::pause(
void)
121 if(m_cmd != WM_CDM_PAUSED) {
122 Q_EMIT cmdChanged(WM_CDM_PAUSED);
123 m_cmd = WM_CDM_PAUSED;
129void LibWMPcmPlayer::stop(
void)
131 if(m_cmd != WM_CDM_STOPPED) {
132 Q_EMIT cmdChanged(WM_CDM_STOPPED);
133 m_cmd = WM_CDM_STOPPED;
139void LibWMPcmPlayer::executeCmd(
int cmd)
143DEBUGLOG(
"set play\n");
147DEBUGLOG(
"set pause\n");
151DEBUGLOG(
"set stop\n");
155 cmd = WM_CDM_STOPPED;
160void LibWMPcmPlayer::stateChanged( Phonon::State newstate, Phonon::State oldstate )
162 DEBUGLOG(
"stateChanged from %i to %i\n", oldstate, newstate);
165static LibWMPcmPlayer *PhononObject = NULL;
169 DEBUGLOG(
"phonon_open\n");
172 ERRORLOG(
"Already initialized!\n");
176 PhononObject =
new LibWMPcmPlayer();
181int phonon_close(
void)
183 DEBUGLOG(
"phonon_close\n");
186 ERRORLOG(
"Unable to close\n");
202phonon_play(
struct cdda_block *blk)
204 DEBUGLOG(
"phonon_play %ld samples, frame %i\n",
205 blk->buflen / (2 * 2), blk->frame);
208 ERRORLOG(
"Unable to play\n");
209 blk->status = WM_CDM_CDDAERROR;
213 PhononObject->setNextBuffer(blk);
224 DEBUGLOG(
"phonon_pause\n");
227 ERRORLOG(
"Unable to pause\n");
231 PhononObject->pause();
242 DEBUGLOG(
"phonon_stop\n");
245 ERRORLOG(
"Unable to stop\n");
249 PhononObject->stop();
258phonon_state(
struct cdda_block *blk)
260 DEBUGLOG(
"phonon_state\n");
265static struct audio_oops phonon_oops = {
276extern "C" struct audio_oops*
277setup_phonon(
const char *dev,
const char *ctl)
279 DEBUGLOG(
"setup_phonon\n");
286#include "audio_phonon.moc"
287#include "moc_audio_phonon.cpp"
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool wait(QMutex *lockedMutex, QDeadlineTimer deadline)