problem with playing wav file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with playing wav file

Ganesh Kundapur
Hi,
  I'm able to play the wav file by using gst-launch as fallows

gst-launch-0.10  filesrc location=~/songs/4voice.wav ! wavparse ! audioconvert ! alsasink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSinkClock
Caught interrupt -- handling interrupt.
Interrupt: Setting pipeline to PAUSED ...
Execution ended after 1914601000 ns.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
FREEING pipeline ...


I modified the helloworld code to play the wav as
1. I created "waveparse" in place of oggdemux and vorbis  parser elements
2. Added filesrc, waveparse and alsasink to the pipeline and linked.

--
int
main ( int argc, char *argv[] )
{
        GMainLoop *loop;
        GstBus *bus;

        gst_init ( &argc, &argv );
        loop = g_main_loop_new ( NULL, FALSE );

         pipeline = gst_pipeline_new ( "audio-player" );
        source = gst_element_factory_make ( "filesrc", "file-source" );
        //parser = gst_element_factory_make ( "oggdemux", "ogg-parser" );
        parser = gst_element_factory_make ( "wavparse", "wave-parser" );
        //decoder = gst_element_factory_make ( "vorbisdec", "vorbis-decoder" );
        conv = gst_element_factory_make ( "audioconvert", "converter" );
        sink = gst_element_factory_make ( "alsasink", "alsa-output" );

        if ( !pipeline || !source || !parser || !conv || !sink ) {
                g_print ( "One element could not be created\n" );
                return -1;
        }

        g_object_set (G_OBJECT (source), "location", argv[1], NULL );

        bus = gst_pipeline_get_bus ( GST_PIPELINE ( pipeline ) );
        gst_bus_add_watch ( bus, bus_call, loop );
        gst_object_unref ( bus );

        gst_bin_add_many ( GST_BIN ( pipeline), source, parser,
                           conv, sink, NULL );

        //gst_element_link ( source, parser );
        gst_element_link_many ( source, parser, conv, sink, NULL );
        g_signal_connect ( parser, "pad-added", G_CALLBACK ( new_pad ), NULL );

        g_print ( "Setting to Playing\n" );
        gst_element_set_state ( pipeline, GST_STATE_PLAYING );
        g_print ( "Running\n" );
        g_main_loop_run ( loop );

        g_print ( "Returned, stopping playback\n" );
        gst_element_set_state ( pipeline, GST_STATE_NULL );
        g_print ( "Deleting pipeline\n" );

        gst_object_unref ( GST_OBJECT ( pipeline ) );

        return 0;
}
--


When i tried to run the fallowing code, i'm getting fallowing errors
--
./a.out ~/songs/4voice.wav
Setting to Playing
Running
Dynamic pad created, linking parser/decoder

(a.out:20136): GStreamer-CRITICAL **: gst_element_get_static_pad: assertion `GST_IS_ELEMENT (element)' failed

(a.out:20136): GStreamer-CRITICAL **: gst_pad_link_prepare: assertion `GST_IS_PAD (sinkpad)' failed

(a.out:20136): GStreamer-CRITICAL **: gst_object_unref: assertion `object != NULL' failed
Error: Internal data flow error.
Returned, stopping playback
Deleting pipeline
--

If i do without the dynamic pads, as
--
int
main (int argc, char *argv[])
{
  GstElement *bin, *filesrc, *decoder, *audiosink;
  GstElement *conv, *resample;

  gst_init (&argc, &argv);

  if (argc != 2) {
    g_print ("usage: %s <mp3 file>\n", argv[0]);
    exit (-1);
  }

  /* create a new bin to hold the elements */
  bin = gst_pipeline_new ("pipeline");
  g_assert (bin);

  /* create a disk reader */
  filesrc = gst_element_factory_make ("filesrc", "disk_source");
  g_assert (filesrc);
  g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);

  /* now it's time to get the decoder */
  decoder = gst_element_factory_make ("wavparse", "decode");
  if (!decoder) {
    g_print ("could not find plugin \"mad\"");
    return -1;
  }

  /* also, we need to add some converters to make sure the audio stream
   * from the decoder is converted into a format the audio sink can
   * understand (if necessary) */
  conv = gst_element_factory_make ("audioconvert", "audioconvert");
  if (!conv) {
    g_print ("could not create \"audioconvert\" element!");
    return -1;
  }
  resample = gst_element_factory_make ("audioresample", "audioresample");
  if (!conv) {
    g_print ("could not create \"audioresample\" element!");
    return -1;
  }

  /* and an audio sink */
  audiosink = gst_element_factory_make ("alsasink", "play_audio");
  g_assert (audiosink);

  /* add objects to the main pipeline */
  gst_bin_add_many (GST_BIN (bin), filesrc, decoder, conv,
      resample, audiosink, NULL);

  /* link the elements */
  gst_element_link_many (filesrc, decoder, conv, resample, audiosink, NULL);
  g_signal_connect ( decoder, "pad-added", G_CALLBACK (new_pad), NULL );

  /* start playing */
  gst_element_set_state (bin, GST_STATE_PLAYING);

  /* Run event loop listening for bus messages until EOS or ERROR */
  event_loop (bin);

  /* stop the bin */
  gst_element_set_state (bin, GST_STATE_NULL);

  exit (0);
}

I'm getting
--
./a.out ~/songs/4voice.wav
Dynamic pad created, linking parser/decoder
ERROR: from element /pipeline/decode: Internal data flow error.
Additional debug info:
gstwavparse.c(1719): gst_wavparse_loop (): /pipeline/decode:
streaming task paused, reason not-linked (-1)
--

It would be of great help if somebody look into this.


/Ganesh
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: problem with playing wav file

Thijs Vermeir-2
Hi,

On Tue, Jun 24, 2008 at 1:47 PM, Ganesh Kundapur
<[hidden email]> wrote:

> Hi,
>   I'm able to play the wav file by using gst-launch as fallows
> ...
> --
> int
> main ( int argc, char *argv[] )
> {
> ...
>         //gst_element_link ( source, parser );
>         gst_element_link_many ( source, parser, conv, sink, NULL );

Here you already try to link the parser with the converter and the pad
is not created, It's a sometimes pad check "gst-inspect wavparse". So
here you just need to do.
  gst_element_link ( source, parser);
  gst_element_link (conv, sink);

>         g_signal_connect ( parser, "pad-added", G_CALLBACK ( new_pad ), NULL
> );

In the new_pad function (if you didn't change it) will the new pad be
connected to the decoder element. In this context there is no decoder
element anymore so change this to the conv element.

Should be working with this changes...

> If i do without the dynamic pads, as
That does not make sense because there is a sometimes pad in wavparse.

Gr,
Thijs

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel