Fixed warnings and memmory leaks

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14607 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-12-16 17:37:03 +00:00
parent e4e22bb1af
commit e7ea085912

View File

@ -59,11 +59,11 @@ bool GStreamerImageStream::open(const std::string& filename)
bool has_audio_stream = false; bool has_audio_stream = false;
GstDiscoverer *item = gst_discoverer_new(1*GST_SECOND, &error);
gchar *uri = g_filename_to_uri(filename.c_str(), NULL, NULL); gchar *uri = g_filename_to_uri(filename.c_str(), NULL, NULL);
if( gst_uri_is_valid(uri) ) if( uri!=0 && gst_uri_is_valid(uri) )
{ {
GstDiscoverer *item = gst_discoverer_new(1*GST_SECOND, &error);
GstDiscovererInfo *info = gst_discoverer_discover_uri(item, uri, &error); GstDiscovererInfo *info = gst_discoverer_discover_uri(item, uri, &error);
GList *audio_list = gst_discoverer_info_get_audio_streams(info); GList *audio_list = gst_discoverer_info_get_audio_streams(info);
@ -75,11 +75,11 @@ bool GStreamerImageStream::open(const std::string& filename)
} }
// build pipeline // build pipeline
const gchar *audio_pipe = ""; const gchar *audio_pipe = "";
if( has_audio_stream ) if( has_audio_stream )
{
audio_pipe = "deco. ! queue ! audioconvert ! autoaudiosink"; audio_pipe = "deco. ! queue ! audioconvert ! autoaudiosink";
}
gchar *string = g_strdup_printf("filesrc location=%s ! \ gchar *string = g_strdup_printf("filesrc location=%s ! \
decodebin name=deco \ decodebin name=deco \
@ -88,17 +88,21 @@ bool GStreamerImageStream::open(const std::string& filename)
_pipeline = gst_parse_launch(string, &error); _pipeline = gst_parse_launch(string, &error);
if( _pipeline == NULL ) g_free(string);
if (error)
{ {
g_printerr("Error: %s\n", error->message); g_printerr("Error: %s\n", error->message);
g_error_free(error);
}
if( _pipeline == NULL )
{
return false; return false;
} }
g_free(string);
g_error_free(error);
// bus // bus
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(_pipeline)); GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(_pipeline));
gst_bus_add_watch(bus, (GstBusFunc)on_message, this); gst_bus_add_watch(bus, (GstBusFunc)on_message, this);