[gst-devel] Sound only once

Andy Wingo wingo at pobox.com
Wed Dec 14 02:09:02 CET 2005


Hi,

On Tue, 2005-12-13 at 18:28 +0100, Bernd Muent wrote:
> My code (linked to gstreamer-0.8):
There is a new release out

> #include <gst/gst.h>
> 
> GstElement *bin,*filesrc,*decoder,*osssink;

you sure these are initialized to NULL?

> 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

>          bin=gst_pipeline_new("pipeline");
> 
>          filesrc=gst_element_factory_make("filesrc",
>                                           "disk_source");
>          if(!filesrc) return;
>          g_object_set(G_OBJECT(filesrc),"location",fileName,NULL);
>          decoder=gst_element_factory_make("mad",
>                                           "decode");
if it's for a game, why mp3? vorbis is better and is free

>          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 ;)

>          printf("Playing %s\n",fileName); # For debugging
> }

Regards,
-- 
Andy Wingo
http://wingolog.org/





More information about the gstreamer-devel mailing list