From 5e2100bdce2111b91b865f5101909eed21596466 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Mon, 2 Sep 2013 11:16:42 +0300 Subject: [PATCH] Add deferred state and pipeline ready flag. Since both ASM and Murphy policy integration might cause asynchronous behavior make sure that play or pause are not forced on incomplete pipeline by media element autostart or similar mechanism. Change-Id: I1dae86ed3eea325928ae70e06987ad8c70d637d5 --- .../gstreamer/MediaPlayerPrivateGStreamer.cpp | 28 ++++++++++++++++++++++ .../gstreamer/MediaPlayerPrivateGStreamer.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index d26c4d1..eb0db52 100755 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -600,6 +600,14 @@ void MediaPlayerPrivateGStreamer::play() if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PLAYING)) return; #endif + + if (m_playBinReady == false) { + m_playerDeferredState = 1; // play + return; + } + + m_playerDeferredState = -1; // ignore + if (changePipelineState(GST_STATE_PLAYING)) { m_isEndReached = false; LOG_MEDIA_MESSAGE("Play"); @@ -612,6 +620,14 @@ void MediaPlayerPrivateGStreamer::pause() if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PAUSE)) return; #endif + + if (m_playBinReady == false) { + m_playerDeferredState = 0; // pause + return; + } + + m_playerDeferredState = -1; // ignore + if (m_isEndReached) return; @@ -2246,6 +2262,9 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() { ASSERT(!m_playBin); + m_playerDeferredState = -1; // ignore + m_playBinReady = false; + // gst_element_factory_make() returns a floating reference so // we should not adopt. m_playBin = gst_element_factory_make(gPlaybinName, "play"); @@ -2330,6 +2349,15 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() #else createAudioSink(); #endif + + m_playBinReady = true; + + if (m_playerDeferredState == 1) + play(); + else if (m_playerDeferredState == 0) + pause(); + + m_playerDeferredState = -1; } #if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER) diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index cca7d22..61a7897 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -263,6 +263,9 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface #if ENABLE(TIZEN_GSTREAMER_VIDEO) float m_suspendTime; #endif + + bool m_playBinReady; + guint m_playerDeferredState; }; } -- 2.7.4