[gst-devel] I tried to replace audio sink at runtime, but failed
Zhao, Halley
halley.zhao at intel.com
Tue Mar 3 10:16:44 CET 2009
1. alsa audio sink --> pulse audio sink will have the following error:
" <pulse_play_audio> warning: Internal data flow problem."
"<pulse_play_audio> warning: Received buffer without a new-segment.Assuming timestamps start from 0."
2. pulse audio --> alsa audio will have the following error:
"alsa pcm_hw.c:1099:snd_pcm_hw_open: alsalib error: open /dev/snd/pcmC0D0p failed: Device or resource busy
alsa pcm_dmix.c:874:snd_pcm_dmix_open: alsalib error: unable to open slave
alsa gstalsasink.c:692:gst_alsasink_open:<alsa_play_audio> error: Could not open audio device for playback. Device is being used by another application.
alsa gstalsasink.c:692:gst_alsasink_open:<alsa_play_audio> error: Device 'default' is busy"
3. pulse-->pulse or alsa-->alsa seems work but with some noise, try a pause/play will remove the noise
" baseaudiosink gstbaseaudiosink.c:895:gst_base_audio_sink_skew_slaving:<pulse_play_audio> correct clock skew 465298808 > 10657500"
>-----Original Message-----
>From: Zhao, Halley [mailto:halley.zhao at intel.com]
>Sent: 2009年3月3日 16:13
>To: Discussion of the development of GStreamer
>Subject: Re: [gst-devel] I tried to replace audio sink at runtime, but failed
>
> After I added block for the src pad of previous element (mp3 decoder),
>I still got some warning of the new audio sink.
> " <pulse_play_audio> warning: Internal data flow problem."
> "<pulse_play_audio> warning: Received buffer without a
>new-segment.Assuming timestamps start from 0."
>
>
> >-----Original Message-----
> >From: Antonio Marqués [mailto:amm at tid.es]
> >Sent: 2009年3月2日 18:43
> >To: Discussion of the development of GStreamer
> >Subject: Re: [gst-devel] I tried to replace audio sink at runtime, but
>failed
> >
> >I think you should first block the src pad of the previous element,
>and
> >then unlink the element.
> >It's explained in:
>
>>http://www.sfr-fresh.com/unix/privat/gstreamer-0.10.22.tar.gz:a/gstrea
>m
> >er-0.10.22/docs/design/part-block.txt
> >Regards
> >On Mon, 2009-03-02 at 10:13 +0100, Zhao, Halley wrote:
> >> Hi all:
> >>
> >> I try to replace audio sink as following, but failed, could you give
> >> me some advice
> >>
> >>
> >>
> >> /* pause */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PAUSED);
> >>
> >> /* unlink and remove former alsa sink */
> >>
> >> gst_element_unlink(decoder, alsaaudiosink);
> >>
> >> gst_bin_remove (GST_BIN (pipeline), alsaaudiosink);
> >>
> >> /* link to pulse audio sink */
> >>
> >> pulseaudiosink = gst_element_factory_make ("pulsesink",
> >> "pulse_play_audio");
> >>
> >> gst_bin_add (GST_BIN (pipeline), pulseaudiosink);
> >>
> >> gst_element_link(decoder, pulseaudiosink);
> >>
> >> /* start playing */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> ====complete source code====
> >>
> >> /* example-begin helloworld.c */
> >>
> >> #include <gst/gst.h>
> >>
> >>
> >>
> >> int
> >>
> >> main (int argc, char *argv[])
> >>
> >> {
> >>
> >> GstElement *pipeline, *filesrc, *decoder, *alsaaudiosink = NULL,
> >> *pulseaudiosink = NULL;
> >>
> >>
> >>
> >> gst_init(&argc, &argv);
> >>
> >>
> >>
> >> if (argc != 2) {
> >>
> >> g_print ("usage: %s <mp3 filename>\n", argv[0]);
> >>
> >> exit (-1);
> >>
> >> }
> >>
> >>
> >>
> >> /* create a new pipeline to hold the elements */
> >>
> >> pipeline = gst_pipeline_new ("pipeline");
> >>
> >>
> >>
> >> /* create a disk reader */
> >>
> >> filesrc = gst_element_factory_make ("filesrc", "disk_source");
> >>
> >> g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
> >>
> >>
> >>
> >> /* now it's time to get the decoder */
> >>
> >> decoder = gst_element_factory_make ("mad", "decoder");
> >>
> >>
> >>
> >>
> >>
> >> /* and an audio sink */
> >>
> >> alsaaudiosink = gst_element_factory_make ("alsasink",
> >> "alsa_play_audio");
> >>
> >>
> >>
> >> /* add objects to the main pipeline */
> >>
> >> gst_bin_add_many (GST_BIN (pipeline), filesrc, decoder,
> >> alsaaudiosink, NULL);
> >>
> >>
> >>
> >> /* link src to sink */
> >>
> >> gst_element_link(filesrc, decoder);
> >>
> >> gst_element_link(decoder,alsaaudiosink);
> >>
> >>
> >>
> >> /* start playing */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> >>
> >>
> >>
> >> static int is_playing = 1;
> >>
> >> static int is_quiting = 0;
> >>
> >> static int is_alsasink = 1;
> >>
> >>
> >>
> >> while (1) {
> >>
> >> if(!(gst_bin_iterate_elements (GST_BIN (pipeline)))) break;
> >>
> >>
> >>
> >> printf(" q:Quit, p:Pause/Play, t:Test: ");
> >>
> >> char ch =0 ;
> >>
> >> ch=getchar();
> >>
> >>
> >>
> >> switch (ch) {
> >>
> >> case 'p':
> >>
> >> if(is_playing) {
> >>
> >> /* pause */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PAUSED);
> >>
> >>
> >>
> >> }
> >>
> >> else {
> >>
> >> /* start playing */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> >>
> >>
> >>
> >> }
> >>
> >> is_playing = !is_playing;
> >>
> >> break;
> >>
> >> case 't':
> >>
> >>
> >>
>
>>printf("==============================================================
>=
> >=\n");
> >>
> >> if(is_alsasink) {
> >>
> >> /* pause */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PAUSED);
> >>
> >> // gst_element_set_state (pipeline, GST_STATE_NULL);
> >>
> >> sleep(1);
> >>
> >>
> >>
> >> gst_element_unlink(decoder, alsaaudiosink);
> >>
> >> gst_bin_remove (GST_BIN (pipeline), alsaaudiosink);
> >>
> >> gst_element_set_state (alsaaudiosink, GST_STATE_NULL);
> >>
> >> gst_object_unref (GST_OBJECT (alsaaudiosink));
> >>
> >>
> >>
> >> pulseaudiosink = gst_element_factory_make ("pulsesink",
> >> "pulse_play_audio");
> >>
> >> gst_bin_add (GST_BIN (pipeline), pulseaudiosink);
> >>
> >> gst_element_link(decoder, pulseaudiosink);
> >>
> >> sleep(1);
> >>
> >>
> >>
> >> /* start playing */
> >>
> >> printf("pulse sink prepare to play:\n");
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> >>
> >> }
> >>
> >> else {
> >>
> >> /* pause */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PAUSED);
> >>
> >> // gst_element_set_state (pipeline, GST_STATE_NULL);
> >>
> >> sleep(1);
> >>
> >>
> >>
> >> gst_element_unlink(decoder, pulseaudiosink);
> >>
> >> gst_bin_remove (GST_BIN (pipeline), pulseaudiosink);
> >>
> >> gst_element_set_state (pulseaudiosink, GST_STATE_NULL);
> >>
> >> gst_object_unref (GST_OBJECT (pulseaudiosink));
> >>
> >>
> >>
> >> alsaaudiosink = gst_element_factory_make ("alsasink",
> >> "alsa_play_audio");
> >>
> >> gst_bin_add (GST_BIN (pipeline), alsaaudiosink);
> >>
> >> gst_element_link(decoder, alsaaudiosink);
> >>
> >> sleep(1);
> >>
> >>
> >>
> >> /* start playing */
> >>
> >> printf("alsa sink prepare to play:\n");
> >>
> >> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> >>
> >> }
> >>
> >>
> >>
> >> is_alsasink = !is_alsasink;
> >>
> >>
> >>
> >> break;
> >>
> >> case 'q':
> >>
> >> is_quiting = 1;
> >>
> >> break;
> >>
> >> default:
> >>
> >> break;
> >>
> >> }
> >>
> >>
> >>
> >> if(is_quiting) break;
> >>
> >>
> >>
> >>
> >>
> >> GstFormat fmt = GST_FORMAT_TIME;
> >>
> >> gint64 pos, len;
> >>
> >>
> >>
> >> if (gst_element_query_position (pipeline, &fmt, &pos)
> >>
> >> && gst_element_query_duration (pipeline, &fmt, &len)) {
> >>
> >> g_print ("Time: %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT
> >> "\n",
> >>
> >> GST_TIME_ARGS (pos), GST_TIME_ARGS (len));
> >>
> >> }
> >>
> >>
> >>
> >> sleep(2);
> >>
> >> }
> >>
> >>
> >>
> >>
> >>
> >> /* stop the pipeline */
> >>
> >> gst_element_set_state (pipeline, GST_STATE_NULL);
> >>
> >>
> >>
> >> /* we don't need a reference to these objects anymore */
> >>
> >> gst_object_unref (GST_OBJECT (pipeline));
> >>
> >> /* unreffing the pipeline unrefs the contained elements as well
>*/
> >>
> >>
> >>
> >> exit (0);
> >>
> >> }
> >>
> >> /* example-end helloworld.c */
> >>
> >> ZHAO, Halley (Aihua)
> >>
> >> Email: halley.zhao at intel.com
> >>
> >> Tel: +86(21)61166476
> >>
> >> iNet: 8821-6476
> >>
> >> SSG/OTC/UMD 3W033
> >>
> >>
> >>
> >>
> >>
> >--
> >Toni Marqués Marqués
> >Telefónica I+D
> >División de Tecnologías de Video
> >amm at tid.es
> >933653188
> >
> >
> >
> >
> >
>
>>----------------------------------------------------------------------
>-
> >-------
> >Open Source Business Conference (OSBC), March 24-25, 2009, San
>Francisco,
> >CA
> >-OSBC tackles the biggest issue in open source: Open Sourcing the
>Enterprise
> >-Strategies to boost innovation and cut costs with open source
>participation
> >-Receive a $600 discount off the registration fee with the source code:
>SFAD
> >http://p.sf.net/sfu/XcvMzF8H
> >_______________________________________________
> >gstreamer-devel mailing list
> >gstreamer-devel at lists.sourceforge.net
> >https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list