<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 <<a href="mailto:thomas@apestaart.org">thomas@apestaart.org</a>><br> * Copyright (C) 2005 Ronald S. Bultje <<a href="mailto:rbultje@ronald.bitfreak.net">rbultje@ronald.bitfreak.net</a>><br>
* Copyright (C) 2010 durgesh <<<a href="mailto:user@hostname.org">user@hostname.org</a>>><br> * <br> * Permission is hereby granted, free of charge, to any person obtaining a<br> * copy of this software and associated documentation files (the "Software"),<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 "AS IS", 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 "LGPL"), 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> * <refsect2><br> * <title>Example launch line</title><br> * |[<br>
* gst-launch -v -m fakesrc ! droidaudiosrc ! fakesink silent=TRUE<br> * ]|<br> * </refsect2><br> */<br><br>#ifdef HAVE_CONFIG_H<br># include <config.h><br>#endif<br><br>#include <gst/gst.h><br>#include <gst/gstutils.h><br>
<br>#include "gstdroidaudiosrc.h"<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 ("sink",<br> GST_PAD_SINK,<br> GST_PAD_ALWAYS,<br> GST_STATIC_CAPS ("ANY")<br>
);<br>/*<br>static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",<br> GST_PAD_SRC,<br> GST_PAD_ALWAYS,<br> GST_STATIC_CAPS ("ANY")<br> );*/<br><br>static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",<br>
GST_PAD_SRC,<br> GST_PAD_ALWAYS,<br> //GST_PAD_ALWAYS,<br> GST_STATIC_CAPS ("audio/x-raw-int, "<br> "signed = (boolean) { TRUE, FALSE }, "<br> "width = (int) 16, "<br>
"depth = (int) 16, "<br> "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ];")<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("base_init started");<br>#endif<br> GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);<br>
<br> gst_element_class_set_details_simple(element_class,<br> "droidaudiosrc",<br> "Src/Audio",<br> "Input from android audio record",<br> "durgesh o mishra <a href="mailto:durgesh.mishra@gmail.com">durgesh.mishra@gmail.com</a>");<br>
<br> gst_element_class_add_pad_template (element_class,<br> gst_static_pad_template_get (&src_factory));<br>#ifdef PDB<br> printf("base_init done");<br>#endif<br> /* gst_element_class_add_pad_template (element_class,<br>
gst_static_pad_template_get (&sink_factory));*/<br>}<br><br>/* initialize the droidaudiosrc's class */<br>static void<br>gst_droidaudiosrc_class_init (GstdroidaudiosrcClass * klass)<br>{<br>#ifdef PDB<br> printf("class_init started");<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->dispose = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_dispose);<br> gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_finalise);<br>
gobject_class->set_property = gst_droidaudiosrc_set_property;<br> gobject_class->get_property = gst_droidaudiosrc_get_property;<br><br> gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_droidsrc_getcaps);<br>
gstbasesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_droidaudiosrc_set_caps);<br> // gstaudiosrc_class-><br> gstaudiosrc_class->open = GST_DEBUG_FUNCPTR (gst_droidsrc_open);<br> gstaudiosrc_class->prepare = GST_DEBUG_FUNCPTR (gst_droidsrc_prepare);<br>
gstaudiosrc_class->unprepare = GST_DEBUG_FUNCPTR (gst_droidsrc_unprepare);<br> gstaudiosrc_class->close = GST_DEBUG_FUNCPTR (gst_droidsrc_close);<br> gstaudiosrc_class->read = GST_DEBUG_FUNCPTR (gst_droidsrc_read);<br>
gstaudiosrc_class->delay = GST_DEBUG_FUNCPTR (gst_droidsrc_delay);<br> gstaudiosrc_class->reset = GST_DEBUG_FUNCPTR (gst_droidsrc_reset);<br><br>#ifdef PDB<br> printf("class_init done");<br>#endif<br>
/*<br> g_object_class_install_property (gobject_class, PROP_SILENT,<br> g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",<br> FALSE, G_PARAM_READWRITE));*/<br>
}<br><br>static void<br>gst_droidaudiosrc_dispose (GObject * object)<br>{<br><br>#ifdef PDB<br> printf("droidaudiosrc_dispose started");<br>#endif<br><br> Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (object);<br>
<br> if (asrc->probed_caps) {<br> gst_caps_unref (asrc->probed_caps);<br> asrc->probed_caps = NULL;<br> }<br><br> G_OBJECT_CLASS (parent_class)->dispose (object);<br>#ifdef PDB<br> printf("droidaudiosrc_dispose done");<br>
#endif<br>}<br><br>static guint gst_droidsrc_delay (GstAudioSrc * droidsrc)<br>{<br> //Do nothing<br>#ifdef PDB<br> printf("delay done");<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("finalize started");<br>#endif<br> Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (object);<br><br> gst_droidaudiosrc_reset (asrc);<br><br> G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (object));<br>
#ifdef PDB<br> printf("finalise done");<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("droidaudiosrc_reset started");<br>#endif<br><br> GST_DEBUG_OBJECT (asrc, "enter");<br> if (asrc->audiorecord_device != NULL) {<br>
audiorecord_device_release (asrc->audiorecord_device);<br> asrc->audiorecord_device = NULL;<br> }<br> asrc->audiorecord_device = NULL;<br> asrc->m_init = FALSE;<br> asrc->m_audiosrc = NULL;<br>
#ifdef PDB<br> printf("reset done");<br>#endif<br>}<br><br>static void gst_droidsrc_reset (GstAudioSrc * droidsrc)<br>{<br>#ifdef PDB<br> printf("droidsrc_reset started");<br>#endif<br> Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (droidsrc);<br>
GST_DEBUG_OBJECT(asrc,"enter");<br> gst_droidaudiosrc_reset(asrc);<br>#ifdef PDB<br> printf("droidsrc reset done");<br>#endif<br>}<br><br>static gboolean gst_droidsrc_close (GstAudioSrc * droidsrc)<br>
{<br><br>#ifdef PDB<br> printf("droidsrc_close started");<br>#endif<br><br> Gstdroidaudiosrc *asrc = GST_DROIDAUDIOSRC (droidsrc);<br><br> GST_DEBUG_OBJECT (asrc, "enter");<br><br> if (asrc->audiorecord_device != NULL) {<br>
GST_DEBUG_OBJECT (asrc, "release audio record device");<br> audiorecord_device_stop (asrc->audiorecord_device);<br> audiorecord_device_release (asrc->audiorecord_device);<br> asrc->audiorecord_device = NULL;<br>
}<br>#ifdef PDB<br> printf("droidsrc close done");<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("droidaudiosrc_init started");<br>#endif<br> GST_DEBUG_OBJECT (asrc, "initializing android audio source");<br> //gst_droidaudiosrc_reset(asrc->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 (&src_factory, "src");<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("droid src init done");<br>#endif<br> /* alsasrc->device = g_strdup (DEFAULT_PROP_DEVICE);<br>
alsasrc->cached_caps = NULL;<br>*/<br> // alsasrc->alsa_lock = g_mutex_new ();<br> /* filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");<br> gst_pad_set_setcaps_function (filter->sinkpad,<br>
GST_DEBUG_FUNCPTR(gst_droidaudiosrc_set_caps));<br> gst_pad_set_getcaps_function (filter->sinkpad,<br> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br> gst_pad_set_chain_function (filter->sinkpad,<br>
GST_DEBUG_FUNCPTR(gst_droidaudiosrc_chain));<br><br> filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");<br> gst_pad_set_getcaps_function (filter->srcpad,<br>
GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br><br> gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);<br> gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);<br> filter->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->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("set property done");<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->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("get property done");<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->srcpad) ? filter->sinkpad : filter->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("set caps done");<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("droidaudiosrc_getcaps started");<br>
#endif<br><br> asrc = GST_DROIDAUDIOSRC (bsrc);<br> GST_DEBUG_OBJECT (asrc, "enter,%p", asrc->audiorecord_device);<br> /*if(asrc->audiorecord_device == NULL || asrc->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->probed_caps)<br> caps = gst_caps_copy(asrc->probed_caps);<br> else<br> {<br>
caps = gst_caps_new_simple ("audio/x-raw-int",<br> "signed",G_TYPE_BOOLEAN, FALSE,<br> "width", G_TYPE_INT, 16,<br> "depth", G_TYPE_INT, 16,<br>
"rate", G_TYPE_INT,8000 ,<br> "channels", G_TYPE_INT, 2, NULL);<br><br> if (caps && !gst_caps_is_empty(caps)) {<br> asrc->probed_caps = gst_caps_copy(caps);<br>
}<br> }<br>#ifdef PDB<br> printf("get caps done");<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->silent == FALSE)<br> g_print ("I'm plugged, therefore I'm in.\n");<br>
<br><br> return gst_pad_push (filter->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("droidaudiosrc_init started");<br>#endif<br><br> GST_DEBUG_CATEGORY_INIT (gst_droidaudiosrc_debug, "droidaudiosrc",<br>
0, "Template droidaudiosrc");<br><br>#ifdef PDB<br> printf("audiosrc init done");<br>#endif<br> return gst_element_register (droidaudiosrc, "droidaudiosrc", 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("droidsrc_open started");<br>#endif<br><br> GST_DEBUG_OBJECT (asrc, "enter");<br> g_return_val_if_fail (asrc != NULL, FALSE);<br><br> baseaudiosrc->buffer_time = DEFAULT_BUFFERTIME;<br>
baseaudiosrc->latency_time = DEFAULT_LATENCYTIME;<br><br> if (asrc->audiorecord_device == NULL) {<br> if (asrc->m_audiosrc) {<br> if (!(asrc->audiorecord_device = audiorecord_device_open(asrc->m_audiosrc)))<br>
goto failed_creation;<br> GST_DEBUG_OBJECT (asrc, "open an existed audio record, %p",<br> asrc->audiorecord_device);<br> }<br> else {<br> if (!(asrc->audiorecord_device = audiorecord_device_create ()))<br>
goto failed_creation;<br> GST_DEBUG_OBJECT (asrc, "create a new audio record, %p",<br> asrc->audiorecord_device);<br> }<br> }<br> return TRUE;<br><br> /* ERRORS */<br>
failed_creation:<br> {<br> GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br> ("Failed to create AudioRecord"));<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, "enter");<br><br> if( audiorecord_device_set (asrc->audiorecord_device,<br>
3, spec->channels, spec->rate,<br> spec->segsize) == -1)<br> goto failed_creation;<br><br> asrc->m_init = TRUE;<br> //audioflinger->m_init = TRUE;<br> // gst_audioflinger_sink_set_volume (audioflinger, audioflinger->m_volume);<br>
// gst_audioflinger_sink_set_mute (audioflinger, audioflinger->m_mute);<br> spec->bytes_per_sample = (spec->width / 8) * spec->channels;<br> asrc->bytes_per_sample = spec->bytes_per_sample;<br>
<br> GST_DEBUG_OBJECT (asrc,<br> "channels: %d, rate: %d, width: %d, got segsize: %d, segtotal: %d, "<br> "frame count: %d, frame size: %d",<br> spec->channels, spec->rate, spec->width, spec->segsize, spec->segtotal,<br>
audiorecord_device_frameCount (asrc->audiorecord_device),<br> audiorecord_device_frameSize (asrc->audiorecord_device)<br> );<br><br> /* GST_DEBUG_OBJECT (asrc, "pause device");<br>
audiorecord_device_pause (asrc->audiorecord_device);<br>*/<br> return TRUE;<br><br> /* ERRORS */<br> failed_creation:<br> {<br> GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br> ("Failed to create Audiorecord for format %d", spec->format));<br>
return FALSE;<br> }<br> dodgy_width:<br> {<br> GST_ELEMENT_ERROR (asrc, RESOURCE, SETTINGS, (NULL),<br> ("Unhandled width %d", spec->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, "enter");<br>
//audioflinger = GST_AUDIOFLINGERSINK (asink);<br><br> if (asrc->audiorecord_device != NULL) {<br> GST_DEBUG_OBJECT (asrc, "release flinger device");<br> audiorecord_device_stop(asrc->audiorecord_device);<br>
asrc->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, "read length=%d", length);<br><br> if (asrc->audiorecord_device == NULL ||<br>
asrc->m_init == FALSE)<br> {<br> GST_WARNING_OBJECT (asrc,<br> "Cannot write when device isn't initialized. Consume data");<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->audiorecord_device, data,<br>
length);<br><br> if (ret == 0) {<br> GST_WARNING_OBJECT (asrc, "read failure");<br> ret = length;<br> }<br><br> GST_INFO_OBJECT (asrc, "read=%u", 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't use autotools to<br> * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.<br> */<br>#ifndef PACKAGE<br>#define PACKAGE "myfirstdroidaudiosrc"<br>
#endif<br><br><br>GST_PLUGIN_DEFINE (<br> GST_VERSION_MAJOR,<br> GST_VERSION_MINOR,<br> "droidaudiosrc",<br> "Template droidaudiosrc",<br> droidaudiosrc_init,<br> VERSION,<br> "LGPL",<br>
"GStreamer",<br> "<a href="http://gstreamer.net/">http://gstreamer.net/</a>"<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"><<a href="mailto:msmith@xiph.org">msmith@xiph.org</a>></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"><<a href="mailto:durgesh.mishra@gmail.com">durgesh.mishra@gmail.com</a>> wrote:<br>
> Hi Mike,<br>
><br>
</div><div class="im">> The problem is resolved now. Here is something that I did.<br>
><br>
> I took reference of AlsaSrc plugin for writing this DroidAudioSrc plugin.<br>
><br>
> I did write these statements in droidaudiosrc_init() function.<br>
><br>
> GstPad* src_pad = gst_pad_new_from_static_template (&src_factory, "src");<br>
> gst_pad_set_getcaps_function (src_pad,<br>
><br>
> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br>
> gst_element_add_pad (GST_ELEMENT (asrc), src_pad);<br>
<br>
</div>You should not be adding the src pad yourself - if you're needing<br>
this, then that means there's something else wrong in your plugin -<br>
the base source should be adding the pad for you. If it's not doing<br>
that, then something isn't initialising properly - and you'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&#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>"If you only have a hammer, you tend to see every problem as a nail."<br>
</div>