title: error while playing .wav file using gstreamer apis
body: <p>I know this question has been posted several times. But none of the solutions worked for me.</p>
  
  <p>I am trying to play .wav files using gstreamer apis.
  The below command plays .wav files (with or without the audioconvert):</p>
  
  <pre><code>gst-launch-1.0 filesrc location=sound.wav ! wavparse ! audioconvert ! alsasink
  </code></pre>
  
  <p>I have written a simple c++ code for the above command referring <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-helloworld.html#section-helloworld" rel="nofollow noreferrer">the GStreamer Hello world example</a>. But it ends with "Internal data flow error". This is my code:</p>
  
  <pre><code>{
      gst_init(NULL, NULL);
      m_pipeline  = gst_pipeline_new("audio-player");
      m_fileSource = gst_element_factory_make("filesrc", "file-source");
      m_parser = gst_element_factory_make("wavparse", "wav-parser");
      m_sink = gst_element_factory_make("alsasink", "audio-output");
      if (!m_pipeline || !m_fileSource || !m_parser || !m_sink) {
          g_printerr ("One or more elements could not be created !! \n");
          return false;
      }
      /* Set up the pipeline */
      else {
          /* set the input filename to the source element */
          g_object_set (G_OBJECT (m_fileSource), "location", path.toLatin1().data(), NULL);
  
          /* set a message handler on a bus */
          GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (m_pipeline));
          gst_bus_add_watch(bus, bus_call, this);
          gst_object_unref(bus);
  
          /* add all elements into the pipeline */
          gst_bin_add_many (GST_BIN (m_pipeline), m_fileSource, m_parser, m_sink, NULL);
  
          /* link the elements together */
          gst_element_link (m_fileSource, m_parser);
  
          g_signal_connect(m_parser, "pad-added", G_CALLBACK(on_pad_added), m_sink);
      }
      gst_element_set_state(m_pipeline, GST_STATE_READY);
      gst_element_set_state(m_pipeline, GST_STATE_PAUSED);
  }
  
  on_pad_added(GstElement *src_element, GstPad *src_pad, gpointer data)
  {
      GstElement *sink_element = (GstElement *)data;
  
      GstPad *sink_pad = gst_element_get_static_pad(sink_element, "sink");
  gst_pad_link(src_pad, sink_pad);
  
      gst_object_unref(sink_pad);
      src_element = NULL;
  }
  </code></pre>
  
  <p>I even tried the solutions suggested in this <a href="https://stackoverflow.com/questions/3656051/unable-to-play-wav-file-using-gstreamer-apis">link</a>; replaced "oggdemux" with "wavparse" and "vorbisdec" with "identity" from the Gstreamer Hello World example as suggested in this <a href="https://stackoverflow.com/questions/4934074/how-do-you-play-or-record-audio-to-wav-on-linux-in-c">link</a>. Error I received:</p>
  
  <pre><code>    0:00:00.289443936  1624  0x1234e00 WARN                 basesrc gstbasesrc.c:3470:gst_base_src_start_complete:&lt;file-source&gt; pad not activated yet
  0:00:00.290993573  1624  0x1740030 FIXME                default gstutils.c:3643:gst_pad_create_stream_id_internal:&lt;wav-parser:src&gt; Creating random stream-id, consider implementing a deterministic way of creating a stream-id
  0:00:00.291883886  1624  0x1740030 WARN                wavparse gstwavparse.c:1564:gst_wavparse_stream_headers:&lt;wav-parser&gt; Ignoring chunk bext
  0:00:00.292198262  1624  0x1740030 WARN                wavparse gstwavparse.c:1564:gst_wavparse_stream_headers:&lt;wav-parser&gt; Ignoring chunk junk
  0:00:00.305086920  1624  0x1234e00 WARN                 basesrc gstbasesrc.c:3470:gst_base_src_start_complete:&lt;file-source&gt; pad not activated yet
  0:00:00.306444838  1624  0x17400c0 FIXME                default gstutils.c:3643:gst_pad_create_stream_id_internal:&lt;wav-parser:src&gt; Creating random stream-id, consider implementing a deterministic way of creating a stream-id
  0:00:00.307224214  1624  0x17400c0 WARN                wavparse gstwavparse.c:1564:gst_wavparse_stream_headers:&lt;wav-parser&gt; Ignoring chunk bext
  0:00:00.307636819  1624  0x17400c0 WARN                wavparse gstwavparse.c:1564:gst_wavparse_stream_headers:&lt;wav-parser&gt; Ignoring chunk junk
  0:00:00.526277506  1624  0x17400c0 WARN                wavparse gstwavparse.c:2186:gst_wavparse_loop:&lt;wav-parser&gt; error: Internal data flow error.
  0:00:00.526495475  1624  0x17400c0 WARN                wavparse gstwavparse.c:2186:gst_wavparse_loop:&lt;wav-parser&gt; error: streaming task paused, reason not-linked (-1)
  0:00:00.527296570  1624  0x1740030 WARN                wavparse gstwavparse.c:2186:gst_wavparse_loop:&lt;wav-parser&gt; error: Internal data flow error.
  0:00:00.527439278  1624  0x1740030 WARN                wavparse gstwavparse.c:2186:gst_wavparse_loop:&lt;wav-parser&gt; error: streaming task paused, reason not-linked (-1)
  ERROR: Internal data flow error.
  ERROR: Internal data flow error.
  </code></pre>
  
  <p>What am I missing in the code?</p>