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

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

View File

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