mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-10 10:04:23 +00:00
sys/osxaudio/gstosxaudiosink.c: Register osxaudiosrc to the plugin.
Original commit message from CVS: 2006-04-28 Zaheer Abbas Merali <zaheerabbas at merali dot org> * sys/osxaudio/gstosxaudiosink.c: (plugin_init): Register osxaudiosrc to the plugin. * sys/osxaudio/gstosxaudiosrc.c: (gst_osx_audio_src_osxelement_do_init), (gst_osx_audio_src_base_init), (gst_osx_audio_src_class_init), (gst_osx_audio_src_init), (gst_osx_audio_src_set_property), (gst_osx_audio_src_get_property), (gst_osx_audio_src_create_ringbuffer), (gst_osx_audio_src_io_proc), (gst_osx_audio_src_osxelement_init): * sys/osxaudio/gstosxaudiosrc.h: Port of osxaudiosrc to 0.10. * sys/osxaudio/Makefile.am: Add osxaudiosrc
This commit is contained in:
parent
4c49dc04f2
commit
9f12811bb2
5 changed files with 282 additions and 193 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2006-04-28 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
* sys/osxaudio/gstosxaudiosink.c:
|
||||
(plugin_init):
|
||||
Register osxaudiosrc to the plugin.
|
||||
* sys/osxaudio/gstosxaudiosrc.c:
|
||||
(gst_osx_audio_src_osxelement_do_init),
|
||||
(gst_osx_audio_src_base_init), (gst_osx_audio_src_class_init),
|
||||
(gst_osx_audio_src_init), (gst_osx_audio_src_set_property),
|
||||
(gst_osx_audio_src_get_property),
|
||||
(gst_osx_audio_src_create_ringbuffer), (gst_osx_audio_src_io_proc),
|
||||
(gst_osx_audio_src_osxelement_init):
|
||||
* sys/osxaudio/gstosxaudiosrc.h:
|
||||
Port of osxaudiosrc to 0.10.
|
||||
* sys/osxaudio/Makefile.am:
|
||||
Add osxaudiosrc
|
||||
|
||||
2006-04-26 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
* sys/osxaudio/gstosxringbuffer.c:
|
||||
|
|
|
@ -2,7 +2,8 @@ plugin_LTLIBRARIES = libgstosxaudio.la
|
|||
|
||||
libgstosxaudio_la_SOURCES = gstosxringbuffer.c \
|
||||
gstosxaudioelement.c \
|
||||
gstosxaudiosink.c
|
||||
gstosxaudiosink.c \
|
||||
gstosxaudiosrc.c
|
||||
|
||||
libgstosxaudio_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GSTPB_BASE_FLAGS)
|
||||
libgstosxaudio_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GSTPB_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@
|
||||
|
@ -10,7 +11,8 @@ libgstosxaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -Wl,-framework -Wl,CoreAudio
|
|||
|
||||
noinst_HEADERS = gstosxaudiosink.h \
|
||||
gstosxaudioelement.h \
|
||||
gstosxringbuffer.h
|
||||
gstosxringbuffer.h \
|
||||
gstosxaudiosrc.h
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
#include <gst/gst.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
#include "gstosxaudiosink.h"
|
||||
#include "gstosxaudiosrc.h"
|
||||
|
||||
#include "gstosxaudioelement.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (osx_audiosink_debug);
|
||||
|
@ -91,7 +93,8 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
||||
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
|
||||
"signed = (boolean) { TRUE }, "
|
||||
"width = (int) 32, " "rate = (int) 44100, " "channels = (int) 2")
|
||||
"width = (int) 32, "
|
||||
"depth = (int) 32, " "rate = (int) 44100, " "channels = (int) 2")
|
||||
);
|
||||
|
||||
static void gst_osx_audio_sink_set_property (GObject * object, guint prop_id,
|
||||
|
@ -321,8 +324,12 @@ gst_osx_audio_sink_osxelement_init (gpointer g_iface, gpointer iface_data)
|
|||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
return gst_element_register (plugin, "osxaudiosink",
|
||||
gboolean ret;
|
||||
|
||||
ret = gst_element_register (plugin, "osxaudiosink",
|
||||
GST_RANK_NONE, GST_TYPE_OSX_AUDIO_SINK);
|
||||
return ret && gst_element_register (plugin, "osxaudiosrc",
|
||||
GST_RANK_NONE, GST_TYPE_OSX_AUDIO_SRC);
|
||||
}
|
||||
|
||||
/* this is the structure that gstreamer looks for to register plugins
|
||||
|
|
|
@ -1,8 +1,29 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wtay@chello.be>
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright 2005,2006 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* gstosxaudiosrc.c:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -20,201 +41,238 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:element-plugin
|
||||
*
|
||||
* <refsect2>
|
||||
* <title>Example launch line</title>
|
||||
* <para>
|
||||
* <programlisting>
|
||||
* gst-launch -v -m osxaudiosrc ! fakesink
|
||||
* </programlisting>
|
||||
* </para>
|
||||
* </refsect2>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
#include "gstosxaudiosrc.h"
|
||||
#include "gstosxaudioelement.h"
|
||||
|
||||
#include <gstosxaudiosrc.h>
|
||||
#include <gstosxaudioelement.h>
|
||||
GST_DEBUG_CATEGORY_STATIC (osx_audiosrc_debug);
|
||||
#define GST_CAT_DEFAULT osx_audiosrc_debug
|
||||
|
||||
/* elementfactory information */
|
||||
static const GstElementDetails gst_osxaudiosrc_details =
|
||||
GST_ELEMENT_DETAILS ("Audio Source (Mac OS X)",
|
||||
static GstElementDetails gst_osx_audio_src_details =
|
||||
GST_ELEMENT_DETAILS ("Audio Source (OSX)",
|
||||
"Source/Audio",
|
||||
"Read from the sound card",
|
||||
"Input from a sound card in OS X",
|
||||
"Zaheer Abbas Merali <zaheerabbas at merali dot org>");
|
||||
|
||||
|
||||
/* Osxaudiosrc signals and args */
|
||||
/* Filter signals and args */
|
||||
enum
|
||||
{
|
||||
/* FILL ME */
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GstStaticPadTemplate osxaudiosrc_src_factory =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_DEVICE
|
||||
};
|
||||
|
||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-raw-float, "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"signed = (boolean) TRUE , "
|
||||
"width = (int) 32, " "rate = (int) 44100, " "channels = (int) 2")
|
||||
"endianness = (int) {" G_STRINGIFY (G_BYTE_ORDER) " }, "
|
||||
"signed = (boolean) { TRUE }, "
|
||||
"width = (int) 32, "
|
||||
"depth = (int) 32, " "rate = (int) 44100, " "channels = (int) 2")
|
||||
);
|
||||
|
||||
static void gst_osxaudiosrc_base_init (gpointer g_class);
|
||||
static void gst_osxaudiosrc_class_init (GstOsxAudioSrcClass * klass);
|
||||
static void gst_osxaudiosrc_init (GstOsxAudioSrc * osxaudiosrc);
|
||||
static void gst_osxaudiosrc_dispose (GObject * object);
|
||||
static void gst_osx_audio_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_osx_audio_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstStateChangeReturn gst_osxaudiosrc_change_state (GstElement * element);
|
||||
|
||||
static GstData *gst_osxaudiosrc_get (GstPad * pad);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/*static guint gst_osxaudiosrc_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
gst_osxaudiosrc_get_type (void)
|
||||
{
|
||||
static GType osxaudiosrc_type = 0;
|
||||
|
||||
if (!osxaudiosrc_type) {
|
||||
static const GTypeInfo osxaudiosrc_info = {
|
||||
sizeof (GstOsxAudioSrcClass),
|
||||
gst_osxaudiosrc_base_init,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_osxaudiosrc_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstOsxAudioSrc),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_osxaudiosrc_init,
|
||||
};
|
||||
|
||||
osxaudiosrc_type =
|
||||
g_type_register_static (GST_TYPE_OSXAUDIOELEMENT, "GstOsxAudioSrc",
|
||||
&osxaudiosrc_info, 0);
|
||||
}
|
||||
return osxaudiosrc_type;
|
||||
}
|
||||
static GstRingBuffer *gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc *
|
||||
src);
|
||||
/*static GstCaps* gst_osx_audio_sink_getcaps (GstBaseSink * bsrc);*/
|
||||
static void gst_osx_audio_src_osxelement_init (gpointer g_iface,
|
||||
gpointer iface_data);
|
||||
OSStatus gst_osx_audio_src_io_proc (AudioDeviceID inDevice,
|
||||
const AudioTimeStamp * inNow, const AudioBufferList * inInputData,
|
||||
const AudioTimeStamp * inInputTime, AudioBufferList * outOutputData,
|
||||
const AudioTimeStamp * inOutputTime, void *inClientData);
|
||||
|
||||
static void
|
||||
gst_osxaudiosrc_base_init (gpointer g_class)
|
||||
gst_osx_audio_src_osxelement_do_init (GType type)
|
||||
{
|
||||
static const GInterfaceInfo osxelement_info = {
|
||||
gst_osx_audio_src_osxelement_init,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (osx_audiosrc_debug, "osxaudiosrc", 0,
|
||||
"OSX Audio Src");
|
||||
GST_DEBUG ("Adding static interface\n");
|
||||
g_type_add_interface_static (type, GST_OSX_AUDIO_ELEMENT_TYPE,
|
||||
&osxelement_info);
|
||||
}
|
||||
|
||||
GST_BOILERPLATE_FULL (GstOsxAudioSrc, gst_osx_audio_src, GstBaseAudioSrc,
|
||||
GST_TYPE_BASE_AUDIO_SRC, gst_osx_audio_src_osxelement_do_init)
|
||||
|
||||
|
||||
static void gst_osx_audio_src_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_set_details (element_class, &gst_osxaudiosrc_details);
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&osxaudiosrc_src_factory));
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
|
||||
gst_element_class_set_details (element_class, &gst_osx_audio_src_details);
|
||||
}
|
||||
|
||||
/* initialize the plugin's class */
|
||||
static void
|
||||
gst_osxaudiosrc_class_init (GstOsxAudioSrcClass * klass)
|
||||
gst_osx_audio_src_class_init (GstOsxAudioSrcClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseAudioSrcClass *gstbaseaudiosrc_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gobject_class->dispose = gst_osxaudiosrc_dispose;
|
||||
gobject_class->set_property =
|
||||
GST_DEBUG_FUNCPTR (gst_osx_audio_src_set_property);
|
||||
gobject_class->get_property =
|
||||
GST_DEBUG_FUNCPTR (gst_osx_audio_src_get_property);
|
||||
|
||||
gstelement_class->change_state = gst_osxaudiosrc_change_state;
|
||||
g_object_class_install_property (gobject_class, ARG_DEVICE,
|
||||
g_param_spec_int ("device", "Device ID", "Device ID of output device",
|
||||
0, G_MAXINT, 0, G_PARAM_READWRITE));
|
||||
|
||||
gstbaseaudiosrc_class->create_ringbuffer =
|
||||
GST_DEBUG_FUNCPTR (gst_osx_audio_src_create_ringbuffer);
|
||||
|
||||
}
|
||||
|
||||
/* initialize the new element
|
||||
* instantiate pads and add them to element
|
||||
* set functions
|
||||
* initialize structure
|
||||
*/
|
||||
static void
|
||||
gst_osx_audio_src_init (GstOsxAudioSrc * src, GstOsxAudioSrcClass * gclass)
|
||||
{
|
||||
/* GstElementClass *klass = GST_ELEMENT_GET_CLASS (sink); */
|
||||
gst_base_src_set_live (GST_BASE_SRC (src), TRUE);
|
||||
src->ringbuffer = NULL;
|
||||
GST_DEBUG ("Initialising object\n");
|
||||
gst_osx_audio_src_create_ringbuffer (GST_BASE_AUDIO_SRC (src));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_osxaudiosrc_init (GstOsxAudioSrc * osxaudiosrc)
|
||||
gst_osx_audio_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
osxaudiosrc->srcpad =
|
||||
gst_pad_new_from_template (gst_static_pad_template_get
|
||||
(&osxaudiosrc_src_factory), "src");
|
||||
gst_pad_set_get_function (osxaudiosrc->srcpad, gst_osxaudiosrc_get);
|
||||
GstOsxAudioSrc *src = GST_OSX_AUDIO_SRC (object);
|
||||
|
||||
gst_element_add_pad (GST_ELEMENT (osxaudiosrc), osxaudiosrc->srcpad);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_osxaudiosrc_dispose (GObject * object)
|
||||
{
|
||||
/* GstOsxAudioSrc *osxaudiosrc = (GstOsxAudioSrc *) object; */
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static GstData *
|
||||
gst_osxaudiosrc_get (GstPad * pad)
|
||||
{
|
||||
GstOsxAudioSrc *src;
|
||||
GstBuffer *buf;
|
||||
glong readbytes;
|
||||
|
||||
src = GST_OSXAUDIOSRC (gst_pad_get_parent (pad));
|
||||
|
||||
buf = gst_buffer_new_and_alloc ((GST_OSXAUDIOELEMENT (src))->buffer_len);
|
||||
|
||||
readbytes =
|
||||
read_buffer (GST_OSXAUDIOELEMENT (src), (char *) GST_BUFFER_DATA (buf));
|
||||
|
||||
if (readbytes < 0) {
|
||||
gst_buffer_unref (buf);
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
|
||||
gst_object_unref (src);
|
||||
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
|
||||
}
|
||||
|
||||
if (readbytes == 0) {
|
||||
gst_buffer_unref (buf);
|
||||
gst_object_unref (src);
|
||||
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
|
||||
}
|
||||
|
||||
GST_BUFFER_SIZE (buf) = readbytes;
|
||||
GST_BUFFER_OFFSET (buf) = src->curoffset;
|
||||
|
||||
src->curoffset += readbytes;
|
||||
|
||||
GST_DEBUG ("pushed buffer from soundcard of %ld bytes", readbytes);
|
||||
|
||||
gst_object_unref (src);
|
||||
|
||||
return GST_DATA (buf);
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_osxaudiosrc_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstOsxAudioSrc *osxaudiosrc = GST_OSXAUDIOSRC (element);
|
||||
OSErr status;
|
||||
|
||||
GST_DEBUG ("osxaudiosrc: state change");
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
osxaudiosrc->curoffset = 0;
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
status =
|
||||
AudioDeviceStart (GST_OSXAUDIOELEMENT (osxaudiosrc)->device_id,
|
||||
inputAudioDeviceIOProc);
|
||||
if (status)
|
||||
GST_DEBUG ("AudioDeviceStart returned %d\n", (int) status);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
status =
|
||||
AudioDeviceStop (GST_OSXAUDIOELEMENT (osxaudiosrc)->device_id,
|
||||
inputAudioDeviceIOProc);
|
||||
if (status)
|
||||
GST_DEBUG ("AudioDeviceStop returned %d\n", (int) status);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
switch (prop_id) {
|
||||
case ARG_DEVICE:
|
||||
if (src->ringbuffer)
|
||||
src->ringbuffer->device_id = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_osx_audio_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstOsxAudioSrc *src = GST_OSX_AUDIO_SRC (object);
|
||||
int val = 0;
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_DEVICE:
|
||||
if (src->ringbuffer)
|
||||
val = src->ringbuffer->device_id;
|
||||
|
||||
g_value_set_int (value, val);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* GstElement vmethod implementations */
|
||||
|
||||
|
||||
/* GstBaseAudioSink vmethod implementations */
|
||||
static GstRingBuffer *
|
||||
gst_osx_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
|
||||
{
|
||||
GstOsxAudioSrc *osxsrc;
|
||||
|
||||
osxsrc = GST_OSX_AUDIO_SRC (src);
|
||||
if (!osxsrc->ringbuffer) {
|
||||
GST_DEBUG ("Creating ringbuffer\n");
|
||||
osxsrc->ringbuffer = g_object_new (GST_TYPE_OSX_RING_BUFFER, NULL);
|
||||
GST_DEBUG ("osx src 0x%x element 0x%x ioproc 0x%x\n", osxsrc,
|
||||
GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc),
|
||||
(void *) gst_osx_audio_src_io_proc);
|
||||
osxsrc->ringbuffer->element = GST_OSX_AUDIO_ELEMENT_GET_INTERFACE (osxsrc);
|
||||
}
|
||||
|
||||
return GST_RING_BUFFER (osxsrc->ringbuffer);
|
||||
}
|
||||
|
||||
OSStatus
|
||||
gst_osx_audio_src_io_proc (AudioDeviceID inDevice, const AudioTimeStamp * inNow,
|
||||
const AudioBufferList * inInputData, const AudioTimeStamp * inInputTime,
|
||||
AudioBufferList * outOutputData, const AudioTimeStamp * inOutputTime,
|
||||
void *inClientData)
|
||||
{
|
||||
GstOsxRingBuffer *buf = GST_OSX_RING_BUFFER (inClientData);
|
||||
|
||||
guint8 *writeptr;
|
||||
gint writeseg;
|
||||
gint len;
|
||||
|
||||
if (gst_ring_buffer_prepare_read (GST_RING_BUFFER (buf), &writeseg, &writeptr,
|
||||
&len)) {
|
||||
|
||||
memcpy (writeptr, (char *) inInputData->mBuffers[0].mData, len);
|
||||
|
||||
/* clear written samples */
|
||||
/*gst_ring_buffer_clear (GST_RING_BUFFER(buf), writeseg); */
|
||||
|
||||
/* we wrote one segment */
|
||||
gst_ring_buffer_advance (GST_RING_BUFFER (buf), 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_osx_audio_src_osxelement_init (gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GstOsxAudioElementInterface *iface = (GstOsxAudioElementInterface *) g_iface;
|
||||
|
||||
iface->io_proc = gst_osx_audio_src_io_proc;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,29 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wtay@chello.be>
|
||||
/*
|
||||
* GStreamer
|
||||
* Copyright 2005-2006 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* gstosxaudiosrc.h:
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -20,55 +41,39 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GST_OSXAUDIOSRC_H__
|
||||
#define __GST_OSXAUDIOSRC_H__
|
||||
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstosxaudioelement.h"
|
||||
#include <gst/audio/gstbaseaudiosrc.h>
|
||||
#include "gstosxringbuffer.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_OSXAUDIOSRC \
|
||||
(gst_osxaudiosrc_get_type())
|
||||
#define GST_OSXAUDIOSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSXAUDIOSRC,GstOsxAudioSrc))
|
||||
#define GST_OSXAUDIOSRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSXAUDIOSRC,GstOsxAudioSrcClass))
|
||||
#define GST_IS_OSXAUDIOSRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSXAUDIOSRC))
|
||||
#define GST_IS_OSXAUDIOSRC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSXAUDIOSRC))
|
||||
/* #defines don't like whitespacey bits */
|
||||
#define GST_TYPE_OSX_AUDIO_SRC \
|
||||
(gst_osx_audio_src_get_type())
|
||||
#define GST_OSX_AUDIO_SRC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSX_AUDIO_SRC,GstOsxAudioSrc))
|
||||
#define GST_OSX_AUDIO_SRC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSX_AUDIO_SRC,GstOsxAudioSrcClass))
|
||||
|
||||
typedef enum {
|
||||
GST_OSXAUDIOSRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
|
||||
|
||||
GST_OSXAUDIOSRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
|
||||
} GstOsxAudioSrcFlags;
|
||||
|
||||
typedef struct _GstOsxAudioSrc GstOsxAudioSrc;
|
||||
typedef struct _GstOsxAudioSrc GstOsxAudioSrc;
|
||||
typedef struct _GstOsxAudioSrcClass GstOsxAudioSrcClass;
|
||||
|
||||
struct _GstOsxAudioSrc {
|
||||
GstOsxAudioElement element;
|
||||
|
||||
/* pads */
|
||||
GstPad *srcpad;
|
||||
|
||||
gboolean need_eos; /* Do we need to emit an EOS? */
|
||||
|
||||
/* blocking */
|
||||
gulong curoffset;
|
||||
gulong buffersize;
|
||||
struct _GstOsxAudioSrc
|
||||
{
|
||||
GstBaseAudioSrc src;
|
||||
|
||||
GstOsxRingBuffer *ringbuffer;
|
||||
};
|
||||
|
||||
struct _GstOsxAudioSrcClass {
|
||||
GstOsxAudioElementClass parent_class;
|
||||
struct _GstOsxAudioSrcClass
|
||||
{
|
||||
GstBaseAudioSrcClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_osxaudiosrc_get_type(void);
|
||||
GType gst_osx_audio_src_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue