[gst-devel] Is there any way to play audio files asynchonously

Ganesh Kundapur ganesh.kundapur at gmail.com
Thu Jul 10 13:55:39 CEST 2008


Hi,
  Is it possible to have the callbacks while playing the audio stream by
using "playbin" element with uri propery?

/Ganesh


/Ganesh
On Sun, Jul 6, 2008 at 4:48 PM, Stefan Kost <ensonic at hora-obscura.de> wrote:

> Ganesh Kundapur schrieb:
>
>  Hi,
>>  I'm playing mp3 file and the code snippet for that is as fallows
>>
>> ...
>> loop = g_main_loop_new ( NULL, FALSE );
>>
>> pipeline = gst_pipeline_new ( "mp3-player" );
>> source = gst_element_factory_make ( "filesrc", "file-source" );
>> decoder = gst_element_factory_make ( "mad", "mp3-decoder" );
>> conv = gst_element_factory_make ( "audioconvert", "converter" );
>> sink = gst_element_factory_make ( "alsasink", "sink" );
>>
>> g_object_set ( G_OBJECT(source), "location", "x.mp3", NULL );
>>
>> gst_bin_add_many ( GST_BIN(pipeline), souce, decoder, conv, sink, NULL );
>> gst_element_link_many ( souce, decoder, conv, sink, NULL );
>>
>> gst_element_set_state ( pipeline, GST_STATE_PLAYING );
>> g_main_loop_run ( loop );
>>
>> Here after, it starts playing. Once its playing, control is not coming out
>> till the stream ended.
>> If i want to pause after certain time interval say 10 sec, i cant do it
>> while playing the stream. Even i set alarm signal and signal handler, but
>>  alarm signal is not delivered while playing the stream.
>>
>> Is there any way to play the audio files asynchronously?
>>
>>  They are play'ed async already. You need to register some callback to get
> control back. E.g.:
> g_timeout_add_seconds()
>
> or without a mainloop:
> clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
> clock_id = gst_clock_new_single_shot_id (clock,
>    gst_clock_get_time (clock) + (10 * GST_SECOND));
> gst_clock_id_wait (clock_id, NULL);
>
> Stefan
>
>>
>> /Ganesh
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
>> Studies have shown that voting for your favorite open source project,
>> along with a healthy diet, reduces your potential for chronic lameness
>> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20080710/5a2438b4/attachment.htm>


More information about the gstreamer-devel mailing list