aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-02-18 04:07:28 -0700
committerMcCabe Maxsted2009-02-18 04:07:28 -0700
commitd3415294494f0f640f41560e035add0befb25259 (patch)
tree722f3ad2631eb35a7296efa39ba4b3d969fcf42c
parentFixed some bad comment formatting (diff)
downloadmeta-impy-d3415294494f0f640f41560e035add0befb25259.zip
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.gz
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.bz2
meta-impy-d3415294494f0f640f41560e035add0befb25259.tar.xz
Added error checking to play/stop/pause to prevent bad looping
Diffstat (limited to '')
-rw-r--r--ChangeLog.txt5
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp64
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc2
3 files changed, 46 insertions, 25 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index f6cbfab..39a6b4d 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -3,6 +3,11 @@
3 * linden/indra/llaudio/audioengine.cpp: 3 * linden/indra/llaudio/audioengine.cpp:
4 Fixed some bad comment formatting. 4 Fixed some bad comment formatting.
5 5
6 * linden/indra/llmedia/llmediaimplgstreamer.cpp:
7 Added error checking to play/stop/pause to prevent bad looping.
8 * linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc:
9 Ditto.
10
6 11
72009-02-14 McCabe Maxsted <hakushakukun@gmail.com> 122009-02-14 McCabe Maxsted <hakushakukun@gmail.com>
8 13
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index bae8ad9..d821bcd 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -36,6 +36,7 @@
36 36
37extern "C" { 37extern "C" {
38#include <gst/gst.h> 38#include <gst/gst.h>
39#include <gst/gstelement.h>
39} 40}
40 41
41#include "llmediamanager.h" 42#include "llmediamanager.h"
@@ -93,22 +94,6 @@ LLMediaImplGStreamer () :
93 // todo: cleanup pump 94 // todo: cleanup pump
94 return; // error 95 return; // error
95 } 96 }
96
97 if (NULL == getenv("LL_GSTREAMER_EXTERNAL"))
98 {
99 // instantiate and connect a custom video sink
100 LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL;
101 mVideoSink =
102 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
103 if (!mVideoSink)
104 {
105 LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL;
106 // todo: cleanup.
107 return; // error
108 }
109
110 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
111 }
112} 97}
113 98
114// virtual 99// virtual
@@ -394,7 +379,6 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
394 379
395 // set URI 380 // set URI
396 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 381 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
397 //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);
398 382
399 // get playbin's bus - perhaps this can/should be done in ctor 383 // get playbin's bus - perhaps this can/should be done in ctor
400 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 384 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
@@ -567,10 +551,19 @@ bool LLMediaImplGStreamer::updateMedia()
567// 551//
568bool LLMediaImplGStreamer::stop() 552bool LLMediaImplGStreamer::stop()
569{ 553{
570 LL_DEBUGS("MediaImpl") << "stopping media..." << LL_ENDL; 554 LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL;
571 // todo: error-check this? 555
572 llgst_element_set_state(mPlaybin, GST_STATE_READY); 556 if (!mPlaybin) return true;
557
558 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
559 llgst_object_unref(pipeline);
560
561 llgst_element_set_state(pipeline, GST_STATE_READY);
573 mState = GST_STATE_READY; 562 mState = GST_STATE_READY;
563
564 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
565 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
566
574 return true; 567 return true;
575} 568}
576 569
@@ -578,10 +571,25 @@ bool LLMediaImplGStreamer::stop()
578// 571//
579bool LLMediaImplGStreamer::play() 572bool LLMediaImplGStreamer::play()
580{ 573{
581 LL_DEBUGS("MediaImpl") << "playing media..." << LL_ENDL; 574 LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL;
582 // todo: error-check this? 575
583 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 576 if (!mPlaybin) return true;
577
578 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
579 llgst_object_unref(pipeline);
580
581 llgst_element_set_state(pipeline, GST_STATE_PLAYING);
584 mState = GST_STATE_PLAYING; 582 mState = GST_STATE_PLAYING;
583 /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
584 mState = GST_STATE_PLAYING;*/
585
586 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
587 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
588
589 // Check to make sure playing was successful. If not, stop.
590 if (state_change == GST_STATE_CHANGE_FAILURE)
591 stop();
592
585 return true; 593 return true;
586} 594}
587 595
@@ -589,10 +597,16 @@ bool LLMediaImplGStreamer::play()
589// 597//
590bool LLMediaImplGStreamer::pause() 598bool LLMediaImplGStreamer::pause()
591{ 599{
592 LL_DEBUGS("MediaImpl") <<"pausing media..." << LL_ENDL; 600 LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL;
593 // todo: error-check this? 601
602 if (!mPlaybin) return true;
603
594 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 604 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
595 mState = GST_STATE_PAUSED; 605 mState = GST_STATE_PAUSED;
606
607 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
608 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
609
596 return true; 610 return true;
597}; 611};
598 612
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
index e17a7a0..9996ba4 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc
@@ -7,7 +7,9 @@ LL_GST_SYM(true, gst_message_parse_error, void, GstMessage *message, GError **ge
7LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug); 7LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug);
8LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending); 8LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending);
9LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state); 9LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state);
10LL_GST_SYM(true, gst_element_get_state, GstStateChangeReturn, GstElement *element, GstState *state, GstState *pending, GstClockTime timeout);
10LL_GST_SYM(true, gst_object_unref, void, gpointer object); 11LL_GST_SYM(true, gst_object_unref, void, gpointer object);
12LL_GST_SYM(true, gst_object_ref, gpointer, gpointer object);
11LL_GST_SYM(true, gst_object_get_type, GType, void); 13LL_GST_SYM(true, gst_object_get_type, GType, void);
12LL_GST_SYM(true, gst_pipeline_get_type, GType, void); 14LL_GST_SYM(true, gst_pipeline_get_type, GType, void);
13LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline); 15LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline);