[gst-devel] Sound only once
Bernd Muent
Bernd.Muent at euroscript.de
Wed Dec 14 04:49:03 CET 2005
Andy Wingo schrieb:
>>My code (linked to gstreamer-0.8):
>
> There is a new release out
I know. But I think that a pkgconfig-check against 0.8 is absolutely
enough to play a simple sound. I don't want to force the users to
install a newer version.
>>#include <gst/gst.h>
>>
>>GstElement *bin,*filesrc,*decoder,*osssink;
>
>
> you sure these are initialized to NULL?
All right. I added this.
>>void playSound(char *fileName) {
>> if (bin!=NULL)
>> gst_element_set_state(GST_ELEMENT(bin),GST_STATE_NULL);
>
> you should unref the old pipeline, if any, here
Something like that?
gst_object_unref(GST_OBJECT(bin));
> if it's for a game, why mp3? vorbis is better and is free
OK, but this is not the problem. The sound is played once.
>
>> if (!decoder) return;
>> osssink = gst_element_factory_make("osssink",
>> "play_audio");
>> if (!osssink) return;
>> gst_bin_add_many(GST_BIN(bin),filesrc,decoder,osssink,NULL);
>> gst_element_link_many(filesrc,decoder,osssink,NULL);
>> gst_element_set_state(bin,GST_STATE_PLAYING);
>
> you're not iterating the pipeline, dunno how it plays the first time ;)
I hear it one time.
The sound is only approx. 0.2 sec. and I like to play it asnycronous in
thebackground without stopping the game.
I found out another thing. When my prog is running (and has played the
sound), a test with gstreamer-properties fails for oss-sound-system. The
error message is in German "Weiterleitung nicht möglich" (something like
"not able to forward message".
When I terminate my program, the test runs well.
So my conclusion: Something is blocked after first playing the sound but
I don't know what.
I added code like:
gst_bin_remove_many(GST_BIN(bin),filesrc,decoder,osssink,NULL);
gst_object_unref(GST_OBJECT(filesrc));
gst_object_unref(GST_OBJECT(decoder));
gst_object_unref(GST_OBJECT(osssink));
but it's still the same problem.
Is there anybody who can post a simple working(!) example for playing a
sound file more than once?
Greetings from Berlin, Bernd
--
Bernd Münt Durchwahl: 030/69032-509
euroscript Deutschland GmbH Zentrale: 030/69032-300
Abteilung IT-Management Fax: 030/69032-505
Alt-Moabit 91 Mail: Bernd.Muent at euroscript.de
10559 Berlin Web: http://www.euroscript.de
More information about the gstreamer-devel
mailing list