Fix playlist detection when playlist size is < 512 bytes.

Fixes issue #2319
This commit is contained in:
John Maguire 2011-11-10 21:42:06 +01:00
parent ed0e6ba898
commit 8e4ec35c61
2 changed files with 16 additions and 2 deletions

View File

@ -487,7 +487,8 @@ void SongLoader::DataReady(GstPad *, GstBuffer *buf, void *self) {
qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes";
if (instance->state_ == WaitingForMagic &&
instance->buffer_.size() >= PlaylistParser::kMagicSize) {
(instance->buffer_.size() >= PlaylistParser::kMagicSize ||
!instance->IsPipelinePlaying())) {
// Got enough that we can test the magic
instance->MagicReady();
}
@ -553,6 +554,7 @@ void SongLoader::ErrorMessageReceived(GstMessage* msg) {
}
void SongLoader::EndOfStreamReached() {
qLog(Debug) << Q_FUNC_INFO << state_;
switch (state_) {
case Finished:
break;
@ -577,6 +579,7 @@ void SongLoader::EndOfStreamReached() {
}
void SongLoader::MagicReady() {
qLog(Debug) << Q_FUNC_INFO;
parser_ = playlist_parser_->ParserForMagic(buffer_, mime_type_);
if (!parser_) {
@ -597,6 +600,16 @@ void SongLoader::MagicReady() {
StopTypefindAsync(true);
}
state_ = WaitingForData;
if (!IsPipelinePlaying()) {
EndOfStreamReached();
}
}
bool SongLoader::IsPipelinePlaying() {
GstState pipeline_state;
gst_element_get_state(pipeline_.get(), &pipeline_state, NULL, GST_MSECOND);
return pipeline_state == GST_STATE_PLAYING;
}
void SongLoader::StopTypefindAsync(bool success) {

View File

@ -103,6 +103,7 @@ private:
void ErrorMessageReceived(GstMessage* msg);
void EndOfStreamReached();
void MagicReady();
bool IsPipelinePlaying();
private:
static QSet<QString> sRawUriSchemes;