summaryrefslogtreecommitdiffstats
path: root/ext/mikmod/gstmikmod.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2004-03-09 21:09:11 +0000
committerBenjamin Otte <otte@gnome.org>2004-03-09 21:09:11 +0000
commit3faf623b27da04bfdfe343d9dadb5c12d305787c (patch)
tree1678133bac830d17ea171edb156ccaaa02e7182e /ext/mikmod/gstmikmod.c
parent1e292a5bd31b54ac68932dbe72ad772bd8661c4a (diff)
ext/mikmod/gstmikmod.*: make mikmod's loop function not loop infinitely and call gst_element_yield anymore
Original commit message from CVS: * ext/mikmod/gstmikmod.c: (gst_mikmod_init), (gst_mikmod_loop), (gst_mikmod_change_state): * ext/mikmod/gstmikmod.h: make mikmod's loop function not loop infinitely and call gst_element_yield anymore * gst/modplug/gstmodplug.cc: fix pad negotiation
Diffstat (limited to 'ext/mikmod/gstmikmod.c')
-rw-r--r--ext/mikmod/gstmikmod.c89
1 files changed, 43 insertions, 46 deletions
diff --git a/ext/mikmod/gstmikmod.c b/ext/mikmod/gstmikmod.c
index cec788d5..f8a6a4e8 100644
--- a/ext/mikmod/gstmikmod.c
+++ b/ext/mikmod/gstmikmod.c
@@ -230,6 +230,8 @@ gst_mikmod_init (GstMikMod *filter)
filter->sndfxvolume = 128;
filter->songname = NULL;
filter->modtype = NULL;
+
+ filter->initialized = FALSE;
}
static GstCaps *
@@ -288,60 +290,55 @@ gst_mikmod_loop (GstElement *element)
srcpad = mikmod->srcpad;
mikmod->Buffer = NULL;
- while ((buffer_in = GST_BUFFER (gst_pad_pull( mikmod->sinkpad )))) {
- if ( GST_IS_EVENT (buffer_in) ) {
- GstEvent *event = GST_EVENT (buffer_in);
+ if (!mikmod->initialized) {
+ while ((buffer_in = GST_BUFFER (gst_pad_pull( mikmod->sinkpad )))) {
+ if ( GST_IS_EVENT (buffer_in) ) {
+ GstEvent *event = GST_EVENT (buffer_in);
- if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
- break;
- }
- else
- {
- if ( mikmod->Buffer ) {
- GstBuffer *merge;
- merge = gst_buffer_merge( mikmod->Buffer, buffer_in );
- gst_buffer_unref( buffer_in );
- gst_buffer_unref( mikmod->Buffer );
- mikmod->Buffer = merge;
+ if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
+ break;
+ } else {
+ if ( mikmod->Buffer ) {
+ GstBuffer *merge;
+ merge = gst_buffer_merge( mikmod->Buffer, buffer_in );
+ gst_buffer_unref( buffer_in );
+ gst_buffer_unref( mikmod->Buffer );
+ mikmod->Buffer = merge;
+ } else {
+ mikmod->Buffer = buffer_in;
+ }
}
- else
- mikmod->Buffer = buffer_in;
- }
- }
+ }
- if (!GST_PAD_CAPS (mikmod->srcpad)) {
- if (GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (mikmod->srcpad))) {
- GST_ELEMENT_ERROR (mikmod, CORE, NEGOTIATION, (NULL), (NULL));
- return;
+ if (!GST_PAD_CAPS (mikmod->srcpad)) {
+ if (GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (mikmod->srcpad))) {
+ GST_ELEMENT_ERROR (mikmod, CORE, NEGOTIATION, (NULL), (NULL));
+ return;
+ }
}
- }
- MikMod_RegisterDriver(&drv_gst);
- MikMod_RegisterAllLoaders();
+ MikMod_RegisterDriver(&drv_gst);
+ MikMod_RegisterAllLoaders();
- MikMod_Init("");
- reader = GST_READER_new( mikmod );
- module = Player_LoadGeneric ( reader, 64, 0 );
+ MikMod_Init("");
+ reader = GST_READER_new( mikmod );
+ module = Player_LoadGeneric ( reader, 64, 0 );
- gst_buffer_unref (mikmod->Buffer);
+ gst_buffer_unref (mikmod->Buffer);
- if ( ! Player_Active() )
- Player_Start(module);
-
- do {
- if ( Player_Active() ) {
-
- timestamp = ( module->sngtime / 1024.0 ) * GST_SECOND;
- drv_gst.Update();
- gst_element_yield (element);
- }
- else {
- gst_element_set_eos (GST_ELEMENT (mikmod));
- gst_pad_push (mikmod->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- }
+ if ( ! Player_Active() )
+ Player_Start(module);
+
+ mikmod->initialized = TRUE;
+ }
- }
- while ( 1 );
+ if ( Player_Active() ) {
+ timestamp = ( module->sngtime / 1024.0 ) * GST_SECOND;
+ drv_gst.Update();
+ } else {
+ gst_element_set_eos (GST_ELEMENT (mikmod));
+ gst_pad_push (mikmod->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ }
}
@@ -405,7 +402,7 @@ GstMikMod *mikmod;
Player_TogglePause();
Player_SetPosition( 0 );
}
-
+ mikmod->initialized = FALSE;
}
if (GST_STATE_PENDING (element) == GST_STATE_PLAYING)