Safeguard against a null pipeline in GstEngine::Play.

This commit is contained in:
David Sansome 2010-09-26 20:59:41 +00:00
parent 940783bc23
commit 0c95f7c234
3 changed files with 10 additions and 1 deletions

View File

@ -78,3 +78,9 @@ void Engine::Base::EmitAboutToEnd() {
int Engine::Base::AddBackgroundStream(const QUrl& url) { int Engine::Base::AddBackgroundStream(const QUrl& url) {
return -1; return -1;
} }
bool Engine::Base::Play(const QUrl& u, TrackChangeType c) {
if (!Load(u, c))
return false;
return Play();
}

View File

@ -61,7 +61,7 @@ class Base : public QObject, boost::noncopyable {
// Helpers // Helpers
virtual bool Load(const QUrl &url, TrackChangeType change); virtual bool Load(const QUrl &url, TrackChangeType change);
bool Play(const QUrl &u, TrackChangeType c) { return Load(u, c) && Play(); } bool Play(const QUrl &u, TrackChangeType c);
void SetVolume( uint value ); void SetVolume( uint value );

View File

@ -496,6 +496,9 @@ void GstEngine::StartFadeout() {
bool GstEngine::Play( uint offset ) { bool GstEngine::Play( uint offset ) {
EnsureInitialised(); EnsureInitialised();
if (!current_pipeline_)
return false;
QFuture<GstStateChangeReturn> future = current_pipeline_->SetState(GST_STATE_PLAYING); QFuture<GstStateChangeReturn> future = current_pipeline_->SetState(GST_STATE_PLAYING);
BoundFutureWatcher<GstStateChangeReturn, uint>* watcher = BoundFutureWatcher<GstStateChangeReturn, uint>* watcher =
new BoundFutureWatcher<GstStateChangeReturn, uint>(offset, this); new BoundFutureWatcher<GstStateChangeReturn, uint>(offset, this);