X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fschannel.c;h=d2df4892a49d77a3b724d23e89cc116fd2c5914d;hb=993f3a070baa8131ddd159a55d5cde43a91d2154;hp=354bf3c881749e3b93e5a0488060886c2f74c319;hpb=ae15de3b9d5bfa1246c4c11d0ff851ac9a7b5f7c;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/schannel.c b/libchimara/schannel.c index 354bf3c..d2df489 100644 --- a/libchimara/schannel.c +++ b/libchimara/schannel.c @@ -70,9 +70,18 @@ on_pipeline_message(GstBus *bus, GstMessage *message, schanid_t s) g_free(debug_message); } break; - case GST_MESSAGE_EOS: - /* end-of-stream */ - clean_up_after_playing_sound(s); + case GST_MESSAGE_EOS: /* End of stream */ + /* Decrease repeats if not set to forever */ + if(s->repeats != (glui32)-1) + s->repeats--; + if(s->repeats > 0) { + if(!gst_element_seek_simple(s->pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, 0)) { + WARNING(_("Could not execute GStreamer seek")); + clean_up_after_playing_sound(s); + } + } else { + clean_up_after_playing_sound(s); + } break; default: /* unhandled message */ @@ -371,13 +380,20 @@ glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { VALID_SCHANNEL(chan, return 0); -#ifdef GSTREAMER_SOUND + g_printerr("Play sound %d with repeats %d and notify %d\n", snd, repeats, notify); +#ifdef GSTREAMER_SOUND ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); GInputStream *stream; /* Stop the previous sound */ clean_up_after_playing_sound(chan); + /* Don't play if repeats = 0 */ + if(repeats == 0) { + chan->repeats = 0; + return 1; + } + /* Load the sound into a GInputStream, by whatever method */ if(!glk_data->resource_map) { if(!glk_data->resource_load_callback) { @@ -396,6 +412,7 @@ glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) stream = g_memory_input_stream_new_from_data(resource.data.ptr, resource.length, NULL); } + chan->repeats = repeats; g_object_set(chan->source, "stream", stream, NULL); if(!gst_element_set_state(chan->pipeline, GST_STATE_PLAYING)) {