Changeset 154988 in webkit
- Timestamp:
- Sep 3, 2013 9:51:19 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154984 r154988 1 2013-09-03 Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> 2 3 [GStreamer] Don't set state to NULL until element is destroyed 4 https://bugs.webkit.org/show_bug.cgi?id=117354 5 6 Reviewed by Philippe Normand. 7 8 Don't set playbin to NULL until it is going to be destroyed or if we stay 9 for too long on the READY state. Instead only set the state to READY as this 10 allows much faster state changes to PAUSED/PLAYING again. playbin internally 11 caches some state that is destroyed when setting it to NULL. 12 This state is independent of the URI and it is even possible to change the 13 URI in READY state. 14 15 To avoid having resources (e.g. audio devices) open indefinitely, 16 when setting the state to READY we create a timeout and if the timeout 17 is reached we reset the pipeline state to NULL to free resources. 18 19 Also now all state changes use the changePipelineState method instead of setting 20 the playbin state directly with gst_element_set_state, so we have a better control 21 of when we are requesting state changes. 22 23 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 24 (WebCore::mediaPlayerPrivateReadyStateTimeoutCallback): 25 (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer): 26 (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer): 27 (WebCore::MediaPlayerPrivateGStreamer::commitLoad): 28 (WebCore::MediaPlayerPrivateGStreamer::changePipelineState): 29 (WebCore::MediaPlayerPrivateGStreamer::setRate): 30 (WebCore::MediaPlayerPrivateGStreamer::handlePluginInstallerResult): 31 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 32 1 33 2013-09-03 peavo@outlook.com <peavo@outlook.com> 2 34 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r154908 r154988 82 82 static const gint64 gPercentMax = 100; 83 83 #endif 84 // Max interval in seconds to stay in the READY state on manual 85 // state change requests. 86 static const guint gReadyStateTimerInterval = 60; 84 87 85 88 GST_DEBUG_CATEGORY_EXTERN(webkit_media_player_debug); … … 158 161 } 159 162 #endif 163 164 static gboolean mediaPlayerPrivateReadyStateTimeoutCallback(MediaPlayerPrivateGStreamer* player) 165 { 166 // This is the callback of the timeout source created in ::changePipelineState. 167 // Reset pipeline if we are sitting on READY state when timeout is reached 168 player->changePipelineState(GST_STATE_NULL); 169 return FALSE; 170 } 160 171 161 172 static void mediaPlayerPrivatePluginInstallerResultFunction(GstInstallPluginsReturn result, gpointer userData) … … 258 269 , m_textTimerHandler(0) 259 270 , m_videoTimerHandler(0) 271 , m_readyTimerHandler(0) 260 272 , m_webkitAudioSink(0) 261 273 , m_totalBytes(-1) … … 283 295 g_signal_handlers_disconnect_by_func(G_OBJECT(m_autoAudioSink.get()), 284 296 reinterpret_cast<gpointer>(setAudioStreamPropertiesCallback), this); 297 298 if (m_readyTimerHandler) 299 g_source_remove(m_readyTimerHandler); 285 300 286 301 if (m_playBin) { … … 368 383 // GStreamer needs to have the pipeline set to a paused state to 369 384 // start providing anything useful. 370 gst_element_set_state(m_playBin.get(),GST_STATE_PAUSED);385 changePipelineState(GST_STATE_PAUSED); 371 386 372 387 setDownloadBuffering(); … … 409 424 bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState) 410 425 { 411 ASSERT( newState == GST_STATE_PLAYING || newState == GST_STATE_PAUSED);426 ASSERT(m_playBin); 412 427 413 428 GstState currentState; … … 430 445 return false; 431 446 } 447 448 // Create a timer when entering the READY state so that we can free resources 449 // if we stay for too long on READY. 450 // Also lets remove the timer if we request a state change for any state other than READY. 451 // See also https://bugs.webkit.org/show_bug.cgi?id=117354 452 if (newState == GST_STATE_READY && !m_readyTimerHandler) { 453 m_readyTimerHandler = g_timeout_add_seconds(gReadyStateTimerInterval, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateReadyStateTimeoutCallback), this); 454 } else if (newState != GST_STATE_READY && m_readyTimerHandler) { 455 g_source_remove(m_readyTimerHandler); 456 m_readyTimerHandler = 0; 457 } 458 432 459 return true; 433 460 } … … 729 756 730 757 if (!rate) { 731 gst_element_set_state(m_playBin.get(),GST_STATE_PAUSED);758 changePipelineState(GST_STATE_PAUSED); 732 759 return; 733 760 } … … 939 966 m_missingPlugins = false; 940 967 if (result == GST_INSTALL_PLUGINS_SUCCESS) { 941 gst_element_set_state(m_playBin.get(),GST_STATE_READY);942 gst_element_set_state(m_playBin.get(),GST_STATE_PAUSED);968 changePipelineState(GST_STATE_READY); 969 changePipelineState(GST_STATE_PAUSED); 943 970 } 944 971 } … … 1145 1172 1146 1173 if (m_playBin) 1147 gst_element_set_state(m_playBin.get(), GST_STATE_NULL);1174 changePipelineState(GST_STATE_READY); 1148 1175 } 1149 1176 … … 1212 1239 break; 1213 1240 case GST_STATE_READY: 1214 m_readyState = MediaPlayer::HaveMetadata; 1215 m_networkState = MediaPlayer::Empty; 1241 // Do not change network/ready states if on EOS and state changed to READY to avoid 1242 // recreating the player on HTMLMediaElement. 1243 if (!m_isEndReached) { 1244 m_readyState = MediaPlayer::HaveMetadata; 1245 m_networkState = MediaPlayer::Empty; 1246 } 1216 1247 break; 1217 1248 case GST_STATE_PAUSED: … … 1254 1285 if (didBuffering && !m_buffering && !m_paused) { 1255 1286 LOG_MEDIA_MESSAGE("[Buffering] Restarting playback."); 1256 gst_element_set_state(m_playBin.get(),GST_STATE_PLAYING);1287 changePipelineState(GST_STATE_PLAYING); 1257 1288 } 1258 1289 } else if (state == GST_STATE_PLAYING) { … … 1261 1292 if (m_buffering && !isLiveStream()) { 1262 1293 LOG_MEDIA_MESSAGE("[Buffering] Pausing stream for buffering."); 1263 gst_element_set_state(m_playBin.get(),GST_STATE_PAUSED);1294 changePipelineState(GST_STATE_PAUSED); 1264 1295 } 1265 1296 } else … … 1284 1315 // A live stream was paused, reset the pipeline. 1285 1316 if (state == GST_STATE_PAUSED && pending == GST_STATE_PLAYING && isLiveStream()) { 1286 gst_element_set_state(m_playBin.get(), GST_STATE_NULL);1287 gst_element_set_state(m_playBin.get(),GST_STATE_PLAYING);1317 changePipelineState(GST_STATE_READY); 1318 changePipelineState(GST_STATE_PLAYING); 1288 1319 } 1289 1320 … … 1309 1340 1310 1341 if (!m_paused) 1311 gst_element_set_state(m_playBin.get(),GST_STATE_PLAYING);1342 changePipelineState(GST_STATE_PLAYING); 1312 1343 1313 1344 m_networkState = MediaPlayer::Loading; … … 1414 1445 // Reset pipeline state. 1415 1446 m_resetPipeline = true; 1416 gst_element_set_state(m_playBin.get(),GST_STATE_READY);1447 changePipelineState(GST_STATE_READY); 1417 1448 1418 1449 GstState state; … … 1422 1453 g_object_set(m_playBin.get(), "uri", newUrl.string().utf8().data(), NULL); 1423 1454 m_url = newUrl; 1424 gst_element_set_state(m_playBin.get(),GST_STATE_PLAYING);1455 changePipelineState(GST_STATE_PLAYING); 1425 1456 return true; 1426 1457 } … … 1460 1491 if (!m_player->mediaPlayerClient()->mediaPlayerIsLooping()) { 1461 1492 m_paused = true; 1462 gst_element_set_state(m_playBin.get(), GST_STATE_NULL);1493 changePipelineState(GST_STATE_READY); 1463 1494 m_downloadFinished = false; 1464 1495 } … … 1504 1535 m_readyState = MediaPlayer::HaveNothing; 1505 1536 m_player->readyStateChanged(); 1537 } 1538 1539 // Loading failed, force reset pipeline and remove ready timer. 1540 gst_element_set_state(m_playBin.get(), GST_STATE_NULL); 1541 if (m_readyTimerHandler) { 1542 g_source_remove(m_readyTimerHandler); 1543 m_readyTimerHandler = 0; 1506 1544 } 1507 1545 } -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r154908 r154988 108 108 void simulateAudioInterruption(); 109 109 110 bool changePipelineState(GstState); 111 110 112 private: 111 113 MediaPlayerPrivateGStreamer(MediaPlayer*); … … 128 130 129 131 void createGSTPlayBin(); 130 bool changePipelineState(GstState);131 132 132 133 bool loadNextLocation(); … … 177 178 guint m_textTimerHandler; 178 179 guint m_videoTimerHandler; 180 guint m_readyTimerHandler; 179 181 GRefPtr<GstElement> m_webkitAudioSink; 180 182 mutable long m_totalBytes;
Note: See TracChangeset
for help on using the changeset viewer.