commit
fa43eaa119
1 file changed
+16
-9
@@ -45,6 +45,9 @@ GstreamerAudioStream::~GstreamerAudioStream(void)
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loads a stream but does not wait for it to get initialized,
|
||||||
|
// so querying duration or position directly after initialization might
|
||||||
|
// return strange values! To work around this use the prescan load function!
|
||||||
int GstreamerAudioStream::Load(const wchar_t* Media)
|
int GstreamerAudioStream::Load(const wchar_t* Media)
|
||||||
{
|
{
|
||||||
Element = gst_element_factory_make("playbin", "playbin");
|
Element = gst_element_factory_make("playbin", "playbin");
|
||||||
@@ -71,15 +74,18 @@ int GstreamerAudioStream::Load(const wchar_t* Media)
|
|||||||
g_object_set(Element, "flags", GST_PLAY_FLAG_AUDIO, NULL);
|
g_object_set(Element, "flags", GST_PLAY_FLAG_AUDIO, NULL);
|
||||||
|
|
||||||
gst_element_set_state(Element, GST_STATE_PAUSED);
|
gst_element_set_state(Element, GST_STATE_PAUSED);
|
||||||
gst_bus_timed_pop_filtered(Bus, -1, GST_MESSAGE_ASYNC_DONE);
|
//gst_bus_timed_pop_filtered(Bus, -1, GST_MESSAGE_ASYNC_DONE);
|
||||||
RefreshDuration();
|
RefreshDuration();
|
||||||
|
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Loads a stream and waits for its initialization
|
||||||
int GstreamerAudioStream::Load(const wchar_t* Media, bool Prescan)
|
int GstreamerAudioStream::Load(const wchar_t* Media, bool Prescan)
|
||||||
{
|
{
|
||||||
Load(Media);
|
Load(Media);
|
||||||
|
if(Prescan)
|
||||||
|
gst_bus_timed_pop_filtered(Bus, -1, GST_MESSAGE_ASYNC_DONE);
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,21 +93,22 @@ void GstreamerAudioStream::Close(void)
|
|||||||
{
|
{
|
||||||
if(Element)
|
if(Element)
|
||||||
gst_element_set_state(Element, GST_STATE_NULL);
|
gst_element_set_state(Element, GST_STATE_NULL);
|
||||||
|
|
||||||
if(Bus)
|
if(Bus)
|
||||||
g_object_unref(Bus);
|
gst_object_unref(Bus);
|
||||||
if(Element)
|
if(Element)
|
||||||
g_object_unref(Element);
|
gst_object_unref(Element);
|
||||||
|
if(Message)
|
||||||
|
gst_message_unref(Message);
|
||||||
if(Convert)
|
if(Convert)
|
||||||
g_object_unref(Convert);
|
gst_object_unref(Convert);
|
||||||
if(Audiosink)
|
if(Audiosink)
|
||||||
g_object_unref(Audiosink);
|
gst_object_unref(Audiosink);
|
||||||
if(Pad)
|
if(Pad)
|
||||||
g_object_unref(Pad);
|
gst_object_unref(Pad);
|
||||||
if(GhostPad)
|
if(GhostPad)
|
||||||
g_object_unref(GhostPad);
|
gst_object_unref(GhostPad);
|
||||||
if(SinkBin)
|
if(SinkBin)
|
||||||
g_object_unref(SinkBin);
|
gst_object_unref(SinkBin);
|
||||||
if(FadeTimer)
|
if(FadeTimer)
|
||||||
g_timer_destroy (FadeTimer);
|
g_timer_destroy (FadeTimer);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user