<div dir="ltr">Hi Mike,<br><br>Here is the complete code of the plugin. Sorry there are lot of commented part in it. I have revisited it several times but not able to find what could be wrong. Please help me on this.<br><br>

/*<br> * GStreamer<br> * Copyright (C) 2005 Thomas Vander Stichele &lt;<a href="mailto:thomas@apestaart.org">thomas@apestaart.org</a>&gt;<br> * Copyright (C) 2005 Ronald S. Bultje &lt;<a href="mailto:rbultje@ronald.bitfreak.net">rbultje@ronald.bitfreak.net</a>&gt;<br>

 * Copyright (C) 2010 durgesh &lt;&lt;<a href="mailto:user@hostname.org">user@hostname.org</a>&gt;&gt;<br> * <br> * Permission is hereby granted, free of charge, to any person obtaining a<br> * copy of this software and associated documentation files (the &quot;Software&quot;),<br>

 * to deal in the Software without restriction, including without limitation<br> * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br> * and/or sell copies of the Software, and to permit persons to whom the<br>

 * Software is furnished to do so, subject to the following conditions:<br> *<br> * The above copyright notice and this permission notice shall be included in<br> * all copies or substantial portions of the Software.<br>
 *<br>
 * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>

 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>

 * DEALINGS IN THE SOFTWARE.<br> *<br> * Alternatively, the contents of this file may be used under the<br> * GNU Lesser General Public License Version 2.1 (the &quot;LGPL&quot;), in<br> * which case the following provisions apply instead of the ones<br>

 * mentioned above:<br> *<br> * This library is free software; you can redistribute it and/or<br> * modify it under the terms of the GNU Library General Public<br> * License as published by the Free Software Foundation; either<br>

 * version 2 of the License, or (at your option) any later version.<br> *<br> * This library is distributed in the hope that it will be useful,<br> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>

 * Library General Public License for more details.<br> *<br> * You should have received a copy of the GNU Library General Public<br> * License along with this library; if not, write to the<br> * Free Software Foundation, Inc., 59 Temple Place - Suite 330,<br>

 * Boston, MA 02111-1307, USA.<br> */<br><br>/**<br> * SECTION:element-droidaudiosrc<br> *<br> * FIXME:Describe droidaudiosrc here.<br> *<br> * &lt;refsect2&gt;<br> * &lt;title&gt;Example launch line&lt;/title&gt;<br> * |[<br>

 * gst-launch -v -m fakesrc ! droidaudiosrc ! fakesink silent=TRUE<br> * ]|<br> * &lt;/refsect2&gt;<br> */<br><br>#ifdef HAVE_CONFIG_H<br>#  include &lt;config.h&gt;<br>#endif<br><br>#include &lt;gst/gst.h&gt;<br>#include &lt;gst/gstutils.h&gt;<br>

<br>#include &quot;gstdroidaudiosrc.h&quot;<br><br>GST_DEBUG_CATEGORY_STATIC (gst_droidaudiosrc_debug);<br>#define GST_CAT_DEFAULT gst_droidaudiosrc_debug<br>#define DEFAULT_BUFFERTIME (500*GST_MSECOND) / (GST_USECOND)<br>

#define DEFAULT_LATENCYTIME (50*GST_MSECOND) / (GST_USECOND)<br>/* Filter signals and args */<br>enum<br>{<br>  /* FILL ME */<br>  LAST_SIGNAL<br>};<br><br>enum<br>{<br>  PROP_0,<br>  PROP_SILENT<br>};<br><br>/* the capabilities of the inputs and outputs.<br>

 *<br> * describe the real formats here.<br> */<br>static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE (&quot;sink&quot;,<br>    GST_PAD_SINK,<br>    GST_PAD_ALWAYS,<br>    GST_STATIC_CAPS (&quot;ANY&quot;)<br>

    );<br>/*<br>static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE (&quot;src&quot;,<br>    GST_PAD_SRC,<br>    GST_PAD_ALWAYS,<br>    GST_STATIC_CAPS (&quot;ANY&quot;)<br>    );*/<br><br>static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE (&quot;src&quot;,<br>

    GST_PAD_SRC,<br>    GST_PAD_ALWAYS,<br>    //GST_PAD_ALWAYS,<br>    GST_STATIC_CAPS (&quot;audio/x-raw-int, &quot;<br>            &quot;signed = (boolean) { TRUE, FALSE }, &quot;<br>            &quot;width = (int) 16, &quot;<br>

            &quot;depth = (int) 16, &quot;<br>            &quot;rate = (int) [ 1, MAX ], &quot; &quot;channels = (int) [ 1, 2 ];&quot;)<br>    );<br>//static GstElementClass *parent_class = NULL;<br>GST_BOILERPLATE (Gstdroidaudiosrc, gst_droidaudiosrc, GstElement,<br>

    GST_TYPE_ELEMENT);<br><br>static void gst_droidaudiosrc_reset (Gstdroidaudiosrc * asrc);<br>static void gst_droidaudiosrc_set_property (GObject * object, guint prop_id,<br>    const GValue * value, GParamSpec * pspec);<br>

static void gst_droidaudiosrc_get_property (GObject * object, guint prop_id,<br>    GValue * value, GParamSpec * pspec);<br><br>static gboolean gst_droidaudiosrc_set_caps (GstPad * pad, GstCaps * caps);<br>static GstFlowReturn gst_droidaudiosrc_chain (GstPad * pad, GstBuffer * buf);<br>

<br>static GstCaps *gst_droidsrc_getcaps (GstBaseSrc * bsrc);<br><br>static gboolean gst_droidsrc_open (GstAudioSrc * droidsrc);<br>static gboolean gst_droidsrc_prepare (GstAudioSrc * droidsrc,<br>    GstRingBufferSpec * spec);<br>

static gboolean gst_droidsrc_unprepare (GstAudioSrc * droidsrc);<br>static gboolean gst_droidsrc_close (GstAudioSrc * droidsrc);<br>static guint gst_droidsrc_read (GstAudioSrc * droidsrc, gpointer data, guint length);<br>

static guint gst_droidsrc_delay (GstAudioSrc * droidsrc);<br>static void gst_droidsrc_reset (GstAudioSrc * droidsrc);<br>static void gst_droidaudiosrc_finalise(GObject* object);<br>static void gst_droidaudiosrc_dispose (GObject * object);<br>

/* GObject vmethod implementations */<br>#define PDB<br>static void<br>gst_droidaudiosrc_base_init (gpointer gclass)<br>{<br>#ifdef PDB<br>    printf(&quot;base_init started&quot;);<br>#endif<br>    GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);<br>

<br>  gst_element_class_set_details_simple(element_class,<br>    &quot;droidaudiosrc&quot;,<br>    &quot;Src/Audio&quot;,<br>    &quot;Input from android audio record&quot;,<br>    &quot;durgesh o mishra <a href="mailto:durgesh.mishra@gmail.com">durgesh.mishra@gmail.com</a>&quot;);<br>

<br>  gst_element_class_add_pad_template (element_class,<br>      gst_static_pad_template_get (&amp;src_factory));<br>#ifdef PDB<br>    printf(&quot;base_init done&quot;);<br>#endif<br> /* gst_element_class_add_pad_template (element_class,<br>

      gst_static_pad_template_get (&amp;sink_factory));*/<br>}<br><br>/* initialize the droidaudiosrc&#39;s class */<br>static void<br>gst_droidaudiosrc_class_init (GstdroidaudiosrcClass * klass)<br>{<br>#ifdef PDB<br>    printf(&quot;class_init started&quot;);<br>

#endif<br><br>  GObjectClass *gobject_class;<br>  GstElementClass *gstelement_class;<br><br>  //Durgesh<br>  GstBaseSrcClass *gstbasesrc_class;<br>  GstBaseAudioSrcClass *gstbaseaudiosrc_class;<br>  GstAudioSrcClass *gstaudiosrc_class;<br>

<br>  gobject_class = (GObjectClass *) klass;<br>  gstelement_class = (GstElementClass *) klass;<br><br>  gstbasesrc_class = (GstBaseSrcClass *) klass;<br>  gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;<br>  gstaudiosrc_class = (GstAudioSrcClass *) klass;<br>

<br><br>  parent_class = g_type_class_peek_parent (klass);<br><br>  gobject_class-&gt;dispose = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_dispose);<br>  gobject_class-&gt;finalize = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_finalise);<br>

  gobject_class-&gt;set_property = gst_droidaudiosrc_set_property;<br>  gobject_class-&gt;get_property = gst_droidaudiosrc_get_property;<br><br>  gstbasesrc_class-&gt;get_caps = GST_DEBUG_FUNCPTR (gst_droidsrc_getcaps);<br>

  gstbasesrc_class-&gt;set_caps = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_set_caps);<br> // gstaudiosrc_class-&gt;<br>  gstaudiosrc_class-&gt;open = GST_DEBUG_FUNCPTR (gst_droidsrc_open);<br>  gstaudiosrc_class-&gt;prepare = GST_DEBUG_FUNCPTR (gst_droidsrc_prepare);<br>

  gstaudiosrc_class-&gt;unprepare = GST_DEBUG_FUNCPTR (gst_droidsrc_unprepare);<br>  gstaudiosrc_class-&gt;close = GST_DEBUG_FUNCPTR (gst_droidsrc_close);<br>  gstaudiosrc_class-&gt;read = GST_DEBUG_FUNCPTR (gst_droidsrc_read);<br>

  gstaudiosrc_class-&gt;delay = GST_DEBUG_FUNCPTR (gst_droidsrc_delay);<br>  gstaudiosrc_class-&gt;reset = GST_DEBUG_FUNCPTR (gst_droidsrc_reset);<br><br>#ifdef PDB<br>    printf(&quot;class_init done&quot;);<br>#endif<br>

/*<br>  g_object_class_install_property (gobject_class, PROP_SILENT,<br>      g_param_spec_boolean (&quot;silent&quot;, &quot;Silent&quot;, &quot;Produce verbose output ?&quot;,<br>          FALSE, G_PARAM_READWRITE));*/<br>

}<br><br>static void<br>gst_droidaudiosrc_dispose (GObject * object)<br>{<br><br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_dispose started&quot;);<br>#endif<br><br>    Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (object);<br>

<br>  if (asrc-&gt;probed_caps) {<br>    gst_caps_unref (asrc-&gt;probed_caps);<br>    asrc-&gt;probed_caps = NULL;<br>  }<br><br>  G_OBJECT_CLASS (parent_class)-&gt;dispose (object);<br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_dispose done&quot;);<br>

#endif<br>}<br><br>static guint gst_droidsrc_delay (GstAudioSrc * droidsrc)<br>{<br>    //Do nothing<br>#ifdef PDB<br>    printf(&quot;delay done&quot;);<br>#endif<br>    return 0;<br>}<br><br><br><br>static void<br>gst_droidaudiosrc_finalise (GObject * object)<br>

{<br><br>#ifdef PDB<br>    printf(&quot;finalize started&quot;);<br>#endif<br>    Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (object);<br><br>    gst_droidaudiosrc_reset (asrc);<br><br>    G_OBJECT_CLASS (parent_class)-&gt;finalize ((GObject *) (object));<br>

#ifdef PDB<br>    printf(&quot;finalise done&quot;);<br>#endif<br>}<br><br><br>/* initialize the new element<br> * instantiate pads and add them to element<br> * set pad calback functions<br> * initialize instance structure<br>

 */<br>static void<br>gst_droidaudiosrc_reset (Gstdroidaudiosrc * asrc)<br>{<br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_reset started&quot;);<br>#endif<br><br>  GST_DEBUG_OBJECT (asrc, &quot;enter&quot;);<br>  if (asrc-&gt;audiorecord_device != NULL) {<br>

      audiorecord_device_release (asrc-&gt;audiorecord_device);<br>    asrc-&gt;audiorecord_device = NULL;<br>  }<br>  asrc-&gt;audiorecord_device = NULL;<br>  asrc-&gt;m_init = FALSE;<br>  asrc-&gt;m_audiosrc = NULL;<br>

#ifdef PDB<br>    printf(&quot;reset done&quot;);<br>#endif<br>}<br><br>static void gst_droidsrc_reset (GstAudioSrc * droidsrc)<br>{<br>#ifdef PDB<br>    printf(&quot;droidsrc_reset started&quot;);<br>#endif<br>    Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (droidsrc);<br>

    GST_DEBUG_OBJECT(asrc,&quot;enter&quot;);<br>    gst_droidaudiosrc_reset(asrc);<br>#ifdef PDB<br>    printf(&quot;droidsrc reset done&quot;);<br>#endif<br>}<br><br>static gboolean gst_droidsrc_close (GstAudioSrc * droidsrc)<br>

{<br><br>#ifdef PDB<br>    printf(&quot;droidsrc_close started&quot;);<br>#endif<br><br>    Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (droidsrc);<br><br>    GST_DEBUG_OBJECT (asrc, &quot;enter&quot;);<br><br>    if (asrc-&gt;audiorecord_device != NULL) {<br>

        GST_DEBUG_OBJECT (asrc, &quot;release audio record device&quot;);<br>        audiorecord_device_stop (asrc-&gt;audiorecord_device);<br>        audiorecord_device_release (asrc-&gt;audiorecord_device);<br>        asrc-&gt;audiorecord_device = NULL;<br>

    }<br>#ifdef PDB<br>    printf(&quot;droidsrc close done&quot;);<br>#endif<br>    return TRUE;<br>}<br><br>static void<br>gst_droidaudiosrc_init (Gstdroidaudiosrc * asrc,<br>    GstdroidaudiosrcClass * gclass)<br>{<br>

<br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_init started&quot;);<br>#endif<br>    GST_DEBUG_OBJECT (asrc, &quot;initializing android audio source&quot;);<br>    //gst_droidaudiosrc_reset(asrc-&gt;audiorecord_device);<br>

    gst_droidaudiosrc_reset(asrc);<br>    //This code may require to be deleted.<br>    GstPad* src_pad = gst_pad_new_from_static_template (&amp;src_factory, &quot;src&quot;);<br>    gst_pad_set_getcaps_function (src_pad,<br>

                                    GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br>    gst_element_add_pad (GST_ELEMENT (asrc), src_pad);<br><br>#ifdef PDB<br>    printf(&quot;droid src init done&quot;);<br>#endif<br>    /*  alsasrc-&gt;device = g_strdup (DEFAULT_PROP_DEVICE);<br>

      alsasrc-&gt;cached_caps = NULL;<br>*/<br>     // alsasrc-&gt;alsa_lock = g_mutex_new ();<br> /* filter-&gt;sinkpad = gst_pad_new_from_static_template (&amp;sink_factory, &quot;sink&quot;);<br>  gst_pad_set_setcaps_function (filter-&gt;sinkpad,<br>

                                GST_DEBUG_FUNCPTR(gst_droidaudiosrc_set_caps));<br>  gst_pad_set_getcaps_function (filter-&gt;sinkpad,<br>                                GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br>  gst_pad_set_chain_function (filter-&gt;sinkpad,<br>

                              GST_DEBUG_FUNCPTR(gst_droidaudiosrc_chain));<br><br>  filter-&gt;srcpad = gst_pad_new_from_static_template (&amp;src_factory, &quot;src&quot;);<br>  gst_pad_set_getcaps_function (filter-&gt;srcpad,<br>

                                GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br><br>  gst_element_add_pad (GST_ELEMENT (filter), filter-&gt;sinkpad);<br>  gst_element_add_pad (GST_ELEMENT (filter), filter-&gt;srcpad);<br>  filter-&gt;silent = FALSE;*/<br>

}<br><br>static void<br>gst_droidaudiosrc_set_property (GObject * object, guint prop_id,<br>    const GValue * value, GParamSpec * pspec)<br>{<br>  /*Gstdroidaudiosrc *filter = GST_DROIDAUDIOSRC (object);<br><br>  switch (prop_id) {<br>

    case PROP_SILENT:<br>      filter-&gt;silent = g_value_get_boolean (value);<br>      break;<br>    default:<br>      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);<br>      break;<br>  }*/<br>#ifdef PDB<br>

    printf(&quot;set property done&quot;);<br>#endif<br>  // Do Nothing<br>}<br><br>static void<br>gst_droidaudiosrc_get_property (GObject * object, guint prop_id,<br>    GValue * value, GParamSpec * pspec)<br>{<br>  /*Gstdroidaudiosrc *filter = GST_DROIDAUDIOSRC (object);<br>

<br>  switch (prop_id) {<br>    case PROP_SILENT:<br>      g_value_set_boolean (value, filter-&gt;silent);<br>      break;<br>    default:<br>      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);<br>      break;<br>

  }*/<br>    //Do Nothing<br>#ifdef PDB<br>    printf(&quot;get property done&quot;);<br>#endif<br>}<br><br>/* GstElement vmethod implementations */<br><br>/* this function handles the link with other elements */<br>static gboolean<br>

gst_droidaudiosrc_set_caps (GstPad * pad, GstCaps * caps)<br>{<br> /* Gstdroidaudiosrc *filter;<br>  GstPad *otherpad;<br><br>  filter = GST_DROIDAUDIOSRC (gst_pad_get_parent (pad));<br><br><br>  otherpad = (pad == filter-&gt;srcpad) ? filter-&gt;sinkpad : filter-&gt;srcpad;<br>

  gst_object_unref (filter);<br><br><br><br>  return gst_pad_set_caps (otherpad, caps);*/<br>    //do nothing<br>#ifdef PDB<br>    printf(&quot;set caps done&quot;);<br>#endif<br>    return FALSE;<br>}<br><br>static GstCaps *<br>

gst_droidsrc_getcaps (GstBaseSrc * bsrc)<br>{<br>  GstElementClass *element_class;<br>  GstPadTemplate *pad_template;<br>  Gstdroidaudiosrc *asrc;<br>  GstCaps *caps;<br><br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_getcaps started&quot;);<br>

#endif<br><br>    asrc = GST_DROIDAUDIOSRC (bsrc);<br>    GST_DEBUG_OBJECT (asrc, &quot;enter,%p&quot;, asrc-&gt;audiorecord_device);<br>    /*if(asrc-&gt;audiorecord_device == NULL || asrc-&gt;m_init == FALSE)<br>    {<br>

        caps = gst_caps_copy(gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD(bsrc)));<br>    }<br>    else*/<br>    if (asrc-&gt;probed_caps)<br>        caps = gst_caps_copy(asrc-&gt;probed_caps);<br>    else<br>    {<br>

        caps = gst_caps_new_simple (&quot;audio/x-raw-int&quot;,<br>               &quot;signed&quot;,G_TYPE_BOOLEAN, FALSE,<br>                &quot;width&quot;, G_TYPE_INT, 16,<br>                &quot;depth&quot;, G_TYPE_INT, 16,<br>

               &quot;rate&quot;, G_TYPE_INT,8000 ,<br>              &quot;channels&quot;, G_TYPE_INT, 2, NULL);<br><br>        if (caps &amp;&amp; !gst_caps_is_empty(caps)) {<br>            asrc-&gt;probed_caps = gst_caps_copy(caps);<br>

        }<br>    }<br>#ifdef PDB<br>    printf(&quot;get caps done&quot;);<br>#endif<br>    return caps;<br>}<br><br>/* chain function<br> * this function does the actual processing<br> */<br>/*<br>static GstFlowReturn<br>

gst_droidaudiosrc_chain (GstPad * pad, GstBuffer * buf)<br>{<br>  Gstdroidaudiosrc *filter;<br><br>  filter = GST_DROIDAUDIOSRC (GST_OBJECT_PARENT (pad));<br><br>  if (filter-&gt;silent == FALSE)<br>    g_print (&quot;I&#39;m plugged, therefore I&#39;m in.\n&quot;);<br>

<br><br>  return gst_pad_push (filter-&gt;srcpad, buf);<br>}*/<br><br><br>/* entry point to initialize the plug-in<br> * initialize the plug-in itself<br> * register the element factories and other features<br> */<br>static gboolean<br>

droidaudiosrc_init (GstPlugin * droidaudiosrc)<br>{<br><br><br>#ifdef PDB<br>    printf(&quot;droidaudiosrc_init started&quot;);<br>#endif<br><br>  GST_DEBUG_CATEGORY_INIT (gst_droidaudiosrc_debug, &quot;droidaudiosrc&quot;,<br>

      0, &quot;Template droidaudiosrc&quot;);<br><br>#ifdef PDB<br>    printf(&quot;audiosrc init done&quot;);<br>#endif<br>  return gst_element_register (droidaudiosrc, &quot;droidaudiosrc&quot;, GST_RANK_NONE,<br>      GST_TYPE_DROIDAUDIOSRC);<br>

}<br><br><br>static gboolean gst_droidsrc_open (GstAudioSrc * droidsrc)<br>{<br>      Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (droidsrc);<br>      GstBaseAudioSrc *baseaudiosrc = (GstBaseAudioSrc *) asrc;<br><br>#ifdef PDB<br>

    printf(&quot;droidsrc_open started&quot;);<br>#endif<br><br>      GST_DEBUG_OBJECT (asrc, &quot;enter&quot;);<br>      g_return_val_if_fail (asrc != NULL, FALSE);<br><br>      baseaudiosrc-&gt;buffer_time = DEFAULT_BUFFERTIME;<br>

      baseaudiosrc-&gt;latency_time = DEFAULT_LATENCYTIME;<br><br>      if (asrc-&gt;audiorecord_device == NULL) {<br>        if (asrc-&gt;m_audiosrc)  {<br>          if (!(asrc-&gt;audiorecord_device = audiorecord_device_open(asrc-&gt;m_audiosrc)))<br>

            goto failed_creation;<br>          GST_DEBUG_OBJECT (asrc, &quot;open an existed audio record, %p&quot;,<br>                asrc-&gt;audiorecord_device);<br>        }<br>        else {<br>          if (!(asrc-&gt;audiorecord_device = audiorecord_device_create ()))<br>

            goto failed_creation;<br>          GST_DEBUG_OBJECT (asrc, &quot;create a new audio record, %p&quot;,<br>                asrc-&gt;audiorecord_device);<br>        }<br>      }<br>      return TRUE;<br><br>      /* ERRORS */<br>

    failed_creation:<br>      {<br>        GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br>            (&quot;Failed to create AudioRecord&quot;));<br>        return FALSE;<br>      }<br>}<br><br><br>static gboolean gst_droidsrc_prepare (GstAudioSrc * droidsrc,<br>

    GstRingBufferSpec * spec)<br>{<br><br>      Gstdroidaudiosrc *asrc;<br><br>      asrc = GST_DROIDAUDIOSRC (droidsrc);<br><br>      GST_DEBUG_OBJECT (asrc, &quot;enter&quot;);<br><br>      if( audiorecord_device_set (asrc-&gt;audiorecord_device,<br>

            3, spec-&gt;channels, spec-&gt;rate,<br>            spec-&gt;segsize) == -1)<br>          goto failed_creation;<br><br>      asrc-&gt;m_init = TRUE;<br>      //audioflinger-&gt;m_init = TRUE;<br>     // gst_audioflinger_sink_set_volume (audioflinger, audioflinger-&gt;m_volume);<br>

     // gst_audioflinger_sink_set_mute (audioflinger, audioflinger-&gt;m_mute);<br>      spec-&gt;bytes_per_sample = (spec-&gt;width / 8) * spec-&gt;channels;<br>      asrc-&gt;bytes_per_sample = spec-&gt;bytes_per_sample;<br>

<br>      GST_DEBUG_OBJECT (asrc,<br>          &quot;channels: %d, rate: %d, width: %d, got segsize: %d, segtotal: %d, &quot;<br>          &quot;frame count: %d, frame size: %d&quot;,<br>          spec-&gt;channels, spec-&gt;rate, spec-&gt;width, spec-&gt;segsize, spec-&gt;segtotal,<br>

          audiorecord_device_frameCount (asrc-&gt;audiorecord_device),<br>          audiorecord_device_frameSize (asrc-&gt;audiorecord_device)<br>          );<br><br>     /* GST_DEBUG_OBJECT (asrc, &quot;pause device&quot;);<br>

      audiorecord_device_pause (asrc-&gt;audiorecord_device);<br>*/<br>      return TRUE;<br><br>      /* ERRORS */<br>    failed_creation:<br>      {<br>        GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br>            (&quot;Failed to create Audiorecord for format %d&quot;, spec-&gt;format));<br>

        return FALSE;<br>      }<br>    dodgy_width:<br>      {<br>        GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br>            (&quot;Unhandled width %d&quot;, spec-&gt;width));<br>        return FALSE;<br>

      }<br><br><br><br>}<br>static gboolean gst_droidsrc_unprepare (GstAudioSrc * droidsrc)<br>{<br>     Gstdroidaudiosrc *asrc;<br><br>     asrc = GST_DROIDAUDIOSRC (droidsrc);<br><br>     GST_DEBUG_OBJECT (asrc, &quot;enter&quot;);<br>

      //audioflinger = GST_AUDIOFLINGERSINK (asink);<br><br>      if (asrc-&gt;audiorecord_device != NULL) {<br>        GST_DEBUG_OBJECT (asrc, &quot;release flinger device&quot;);<br>        audiorecord_device_stop(asrc-&gt;audiorecord_device);<br>

        asrc-&gt;m_init = FALSE;<br>      }<br><br>      return TRUE;<br>}<br><br>static guint gst_droidsrc_read (GstAudioSrc * droidsrc, gpointer data, guint length)<br>{<br><br>    Gstdroidaudiosrc *asrc;<br><br>    asrc = GST_DROIDAUDIOSRC (droidsrc);<br>

<br>    //GstAudioFlingerSink *audioflinger;<br>      guint ret = 0;<br><br>    //  audioflinger = GST_AUDIOFLINGERSINK (asink);<br><br>      GST_INFO_OBJECT (asrc, &quot;read length=%d&quot;, length);<br><br>      if (asrc-&gt;audiorecord_device == NULL ||<br>

              asrc-&gt;m_init == FALSE)<br>      {<br>        GST_WARNING_OBJECT (asrc,<br>                &quot;Cannot write when device isn&#39;t initialized. Consume data&quot;);<br>        return length;<br>      }<br>

<br>      /* FIXME : Instead of using write, we should be using obtainBuffer/releaseBuffer<br>       * which gives us a more granular feedback. */<br>      ret =<br>          audiorecord_device_read (asrc-&gt;audiorecord_device, data,<br>

          length);<br><br>      if (ret == 0) {<br>        GST_WARNING_OBJECT (asrc, &quot;read failure&quot;);<br>        ret = length;<br>      }<br><br>      GST_INFO_OBJECT (asrc, &quot;read=%u&quot;, ret);<br><br>      return ret;<br>

<br><br>}<br>/*static guint gst_droidsrc_delay (GstAudioSrc * asrc);<br>static void gst_droidsrc_reset (GstAudioSrc * asrc);*/<br><br>/* PACKAGE: this is usually set by autotools depending on some _INIT macro<br> * in <a href="http://configure.ac">configure.ac</a> and then written into and defined in config.h, but we can<br>

 * just set it ourselves here in case someone doesn&#39;t use autotools to<br> * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.<br> */<br>#ifndef PACKAGE<br>#define PACKAGE &quot;myfirstdroidaudiosrc&quot;<br>

#endif<br><br><br>GST_PLUGIN_DEFINE (<br>    GST_VERSION_MAJOR,<br>    GST_VERSION_MINOR,<br>    &quot;droidaudiosrc&quot;,<br>    &quot;Template droidaudiosrc&quot;,<br>    droidaudiosrc_init,<br>    VERSION,<br>    &quot;LGPL&quot;,<br>

    &quot;GStreamer&quot;,<br>    &quot;<a href="http://gstreamer.net/">http://gstreamer.net/</a>&quot;<br>)<br><br>Kind Regards<br>-Durgesh O Mishra<br><br><br><div class="gmail_quote">On 18 February 2010 23:41, Michael Smith <span dir="ltr">&lt;<a href="mailto:msmith@xiph.org">msmith@xiph.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Thu, Feb 18, 2010 at 9:55 AM, Durgesh Mishra<br>
<div class="im">&lt;<a href="mailto:durgesh.mishra@gmail.com">durgesh.mishra@gmail.com</a>&gt; wrote:<br>
&gt; Hi Mike,<br>
&gt;<br>
</div><div class="im">&gt; The problem is resolved now. Here is something that I did.<br>
&gt;<br>
&gt; I took reference of AlsaSrc plugin for writing this DroidAudioSrc plugin.<br>
&gt;<br>
&gt; I did write these statements in droidaudiosrc_init() function.<br>
&gt;<br>
&gt; GstPad* src_pad = gst_pad_new_from_static_template (&amp;src_factory, &quot;src&quot;);<br>
&gt;     gst_pad_set_getcaps_function (src_pad,<br>
&gt;<br>
&gt; GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br>
&gt;     gst_element_add_pad (GST_ELEMENT (asrc), src_pad);<br>
<br>
</div>You should not be adding the src pad yourself - if you&#39;re needing<br>
this, then that means there&#39;s something else wrong in your plugin -<br>
the base source should be adding the pad for you. If it&#39;s not doing<br>
that, then something isn&#39;t initialising properly - and you&#39;ll probably<br>
have many more problems. So you should revert that change, and figure<br>
out the real cause of your bug.<br>
<br>
Mike<br>
<br>
------------------------------------------------------------------------------<br>
Download Intel&amp;#174; Parallel Studio Eval<br>
Try the new software tools for yourself. Speed compiling, find bugs<br>
proactively, and fine-tune applications for parallel performance.<br>
See why Intel Parallel Studio got high marks during beta.<br>
<a href="http://p.sf.net/sfu/intel-sw-dev" target="_blank">http://p.sf.net/sfu/intel-sw-dev</a><br>
<div><div></div><div class="h5">_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>&quot;If you only have a hammer, you tend to see every problem as a nail.&quot;<br>
</div>