aboutsummaryrefslogtreecommitdiff
path: root/lib/soundcore.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-09-18 17:43:25 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2007-09-18 17:43:25 +0000
commitd80498e562ae70cfe5f0d2400046e6e4db6af260 (patch)
treef45e3480c94b6cf1c756b4f35a5c42eead8fabc4 /lib/soundcore.cpp
parent41c154d03342aa03cc3932ca032eba387c7a2bff (diff)
downloadqmmp-d80498e562ae70cfe5f0d2400046e6e4db6af260.tar.gz
qmmp-d80498e562ae70cfe5f0d2400046e6e4db6af260.tar.bz2
qmmp-d80498e562ae70cfe5f0d2400046e6e4db6af260.zip
improved stream support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@157 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'lib/soundcore.cpp')
-rw-r--r--lib/soundcore.cpp85
1 files changed, 46 insertions, 39 deletions
diff --git a/lib/soundcore.cpp b/lib/soundcore.cpp
index 8c59d015b..4b4d9a6fb 100644
--- a/lib/soundcore.cpp
+++ b/lib/soundcore.cpp
@@ -78,6 +78,7 @@ bool SoundCore::play(const QString &source)
m_input = new StreamReader(source, this);
connect(m_input, SIGNAL(titleChanged(const QString&)),
SIGNAL(titleChanged(const QString&)));
+ connect(m_input, SIGNAL(readyRead()),SLOT(decode()));
}
else
m_input = new QFile(source);
@@ -93,6 +94,7 @@ bool SoundCore::play(const QString &source)
}
connect(m_output, SIGNAL(stateChanged(const OutputState&)),
SIGNAL(outputStateChanged(const OutputState&)));
+ connect(m_input, SIGNAL(readyRead()),SLOT(read()));
}
if (! m_output->initialize())
return FALSE;
@@ -104,41 +106,13 @@ bool SoundCore::play(const QString &source)
m_vis->setOutput(m_output);
m_output->addVisual(m_vis);
}
+ m_source = source;
+ if (source.left(4) != "http")
+ return decode();
+ else
+ qobject_cast<StreamReader *>(m_input)->downloadFile();
+ return TRUE;
- if (! m_decoder)
- {
- m_block = TRUE;
- qDebug ("SoundCore: creating decoder");
- m_decoder = Decoder::create(this, source, m_input, m_output);
-
- if (! m_decoder)
- {
- qWarning("SoundCore: unsupported fileformat");
- m_block = FALSE;
- stop();
- emit decoderStateChanged(DecoderState(DecoderState::Error));
- return FALSE;
- }
- qDebug ("ok");
- m_decoder->setBlockSize(globalBlockSize);
- connect(m_decoder, SIGNAL(stateChanged(const DecoderState&)),
- SIGNAL(decoderStateChanged(const DecoderState&)));
- setEQ(m_bands, m_preamp);
- setEQEnabled(m_useEQ);
- }
- qDebug("SoundCore: decoder was created successfully");
-
- if (m_decoder->initialize())
- {
- m_output->start();
- m_decoder->start();
- m_error = NoError;
- m_block = FALSE;
- return TRUE;
- }
- stop();
- m_block = FALSE;
- return FALSE;
}
uint SoundCore::error()
@@ -157,7 +131,6 @@ void SoundCore::stop()
m_decoder->stop();
m_decoder->mutex()->unlock();
}
-
if (m_output)
{
m_output->mutex()->lock ();
@@ -172,20 +145,16 @@ void SoundCore::stop()
m_decoder->cond()->wakeAll();
m_decoder->mutex()->unlock();
}
-
if (m_output)
{
m_output->recycler()->mutex()->lock ();
m_output->recycler()->cond()->wakeAll();
m_output->recycler()->mutex()->unlock();
}
-
if (m_decoder)
m_decoder->wait();
-
if (m_output)
m_output->wait();
-
if (m_output && m_output->isInitialized())
{
m_output->uninitialize();
@@ -324,3 +293,41 @@ void SoundCore::addVisualization(Visualization *visual)
{
m_vis = visual;
}
+
+bool SoundCore::decode()
+{
+ if (! m_decoder)
+ {
+ m_block = TRUE;
+ qDebug ("SoundCore: creating decoder");
+ m_decoder = Decoder::create(this, m_source, m_input, m_output);
+
+ if (! m_decoder)
+ {
+ qWarning("SoundCore: unsupported fileformat");
+ m_block = FALSE;
+ stop();
+ emit decoderStateChanged(DecoderState(DecoderState::Error));
+ return FALSE;
+ }
+ qDebug ("ok");
+ m_decoder->setBlockSize(globalBlockSize);
+ connect(m_decoder, SIGNAL(stateChanged(const DecoderState&)),
+ SIGNAL(decoderStateChanged(const DecoderState&)));
+ setEQ(m_bands, m_preamp);
+ setEQEnabled(m_useEQ);
+ }
+ qDebug("SoundCore: decoder was created successfully");
+
+ if (m_decoder->initialize())
+ {
+ m_output->start();
+ m_decoder->start();
+ m_error = NoError;
+ m_block = FALSE;
+ return TRUE;
+ }
+ stop();
+ m_block = FALSE;
+ return FALSE;
+}