Commit b34bd142 authored by Tristan Matthews's avatar Tristan Matthews Committed by Tim-Philipp Müller

ext/jack/: Add a jackaudiosrc. Refactor sink slightly for better code reuse.

Original commit message from CVS:
patch by: Tristan Matthews <tristan@sat.qc.ca>
* ext/jack/Makefile.am:
* ext/jack/gstjack.c:
* ext/jack/gstjackaudioclient.c:
* ext/jack/gstjackaudiosink.c:
* ext/jack/gstjackaudiosink.h:
* ext/jack/gstjackaudiosrc.c:
* ext/jack/gstjackaudiosrc.h:
* ext/jack/gstjackringbuffer.h:
Add a jackaudiosrc. Refactor sink slightly for better code reuse.
Fixes #545197.
parent d32bf241
plugin_LTLIBRARIES = libgstjack.la
libgstjack_la_SOURCES = gstjack.c gstjackaudiosink.c gstjackaudioclient.c
libgstjack_la_SOURCES = gstjack.c gstjackaudiosrc.c gstjackaudiosink.c gstjackaudioclient.c
libgstjack_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(JACK_CFLAGS)
libgstjack_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(JACK_LIBS)
libgstjack_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstjackaudiosink.h gstjackaudioclient.h
noinst_HEADERS = gstjackaudiosrc.h gstjackaudiosink.h gstjackaudioclient.h gstjack.h gstjackringbuffer.h
EXTRA_DIST = README
......@@ -21,11 +21,34 @@
#include "config.h"
#endif
#include "gstjackaudiosrc.h"
#include "gstjackaudiosink.h"
GType
gst_jack_connect_get_type (void)
{
static GType jack_connect_type = 0;
static const GEnumValue jack_connect[] = {
{GST_JACK_CONNECT_NONE,
"Don't automatically connect ports to physical ports", "none"},
{GST_JACK_CONNECT_AUTO,
"Automatically connect ports to physical ports", "auto"},
{0, NULL, NULL},
};
if (!jack_connect_type) {
jack_connect_type = g_enum_register_static ("GstJackConnect", jack_connect);
}
return jack_connect_type;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "jackaudiosrc", GST_RANK_PRIMARY,
GST_TYPE_JACK_AUDIO_SRC))
return FALSE;
if (!gst_element_register (plugin, "jackaudiosink", GST_RANK_PRIMARY,
GST_TYPE_JACK_AUDIO_SINK))
return FALSE;
......
......@@ -127,6 +127,9 @@ jack_shutdown_cb (void *arg)
GstJackAudioConnection *conn = (GstJackAudioConnection *) arg;
GList *walk;
GST_DEBUG ("disconnect client %s from server %s", conn->id,
GST_STR_NULL (conn->server));
g_mutex_lock (conn->lock);
for (walk = conn->src_clients; walk; walk = g_list_next (walk)) {
GstJackAudioClient *client = (GstJackAudioClient *) walk->data;
......
......@@ -59,62 +59,11 @@
#include <string.h>
#include "gstjackaudiosink.h"
#include "gstjackringbuffer.h"
GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_sink_debug);
#define GST_CAT_DEFAULT gst_jack_audio_sink_debug
typedef jack_default_audio_sample_t sample_t;
#define GST_TYPE_JACK_RING_BUFFER \
(gst_jack_ring_buffer_get_type())
#define GST_JACK_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_RING_BUFFER,GstJackRingBuffer))
#define GST_JACK_RING_BUFFER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_RING_BUFFER,GstJackRingBufferClass))
#define GST_JACK_RING_BUFFER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_JACK_RING_BUFFER, GstJackRingBufferClass))
#define GST_JACK_RING_BUFFER_CAST(obj) \
((GstJackRingBuffer *)obj)
#define GST_IS_JACK_RING_BUFFER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_RING_BUFFER))
#define GST_IS_JACK_RING_BUFFER_CLASS(klass)\
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_RING_BUFFER))
typedef struct _GstJackRingBuffer GstJackRingBuffer;
typedef struct _GstJackRingBufferClass GstJackRingBufferClass;
struct _GstJackRingBuffer
{
GstRingBuffer object;
gint sample_rate;
gint buffer_size;
gint channels;
};
struct _GstJackRingBufferClass
{
GstRingBufferClass parent_class;
};
static void gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass);
static void gst_jack_ring_buffer_init (GstJackRingBuffer * ringbuffer,
GstJackRingBufferClass * klass);
static void gst_jack_ring_buffer_dispose (GObject * object);
static void gst_jack_ring_buffer_finalize (GObject * object);
static GstRingBufferClass *ring_parent_class = NULL;
static gboolean gst_jack_ring_buffer_open_device (GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_close_device (GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_acquire (GstRingBuffer * buf,
GstRingBufferSpec * spec);
static gboolean gst_jack_ring_buffer_release (GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_start (GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_pause (GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_stop (GstRingBuffer * buf);
static guint gst_jack_ring_buffer_delay (GstRingBuffer * buf);
static gboolean
gst_jack_audio_sink_allocate_channels (GstJackAudioSink * sink, gint channels)
{
......@@ -689,25 +638,6 @@ enum
PROP_LAST
};
#define GST_TYPE_JACK_CONNECT (gst_jack_connect_get_type())
static GType
gst_jack_connect_get_type (void)
{
static GType jack_connect_type = 0;
static const GEnumValue jack_connect[] = {
{GST_JACK_CONNECT_NONE,
"Don't automatically connect ports to physical ports", "none"},
{GST_JACK_CONNECT_AUTO,
"Automatically connect ports to physical ports", "auto"},
{0, NULL, NULL},
};
if (!jack_connect_type) {
jack_connect_type = g_enum_register_static ("GstJackConnect", jack_connect);
}
return jack_connect_type;
}
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (gst_jack_audio_sink_debug, "jacksink", 0, "jacksink element");
......
......@@ -27,6 +27,7 @@
#include <gst/gst.h>
#include <gst/audio/gstbaseaudiosink.h>
#include "gstjack.h"
#include "gstjackaudioclient.h"
G_BEGIN_DECLS
......@@ -41,22 +42,6 @@ G_BEGIN_DECLS
typedef struct _GstJackAudioSink GstJackAudioSink;
typedef struct _GstJackAudioSinkClass GstJackAudioSinkClass;
/**
* GstJackConnect:
* @GST_JACK_CONNECT_NONE: Don't automatically connect to physical ports.
* In this mode, the element will accept any number of input channels and will
* create (but not connect) an output port for each channel.
* @GST_JACK_CONNECT_AUTO: In this mode, the element will try to connect each
* output port to a random physical jack input pin. The sink will
* expose the number of physical channels on its pad caps.
*
* Specify how the output ports will be connected.
*/
typedef enum {
GST_JACK_CONNECT_NONE,
GST_JACK_CONNECT_AUTO
} GstJackConnect;
/**
* GstJackAudioSink:
*
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca>
*
* 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:
*
* 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
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_JACK_AUDIO_SRC_H__
#define __GST_JACK_AUDIO_SRC_H__
#include <jack/jack.h>
#include <gst/gst.h>
#include <gst/audio/gstaudiosrc.h>
#include "gstjackaudioclient.h"
#include "gstjack.h"
G_BEGIN_DECLS
#define GST_TYPE_JACK_AUDIO_SRC (gst_jackaudiosrc_get_type())
#define GST_JACK_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_AUDIO_SRC,GstJackAudioSrc))
#define GST_JACK_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_AUDIO_SRC,GstJackAudioSrcClass))
#define GST_IS_JACK_AUDIO_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_AUDIO_SRC))
#define GST_IS_JACK_AUDIO_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_AUDIO_SRC))
typedef struct _GstJackAudioSrc GstJackAudioSrc;
typedef struct _GstJackAudioSrcClass GstJackAudioSrcClass;
struct _GstJackAudioSrc
{
GstBaseAudioSrc src;
/*< private >*/
/* cached caps */
GstCaps *caps;
/* properties */
GstJackConnect connect;
gchar *server;
/* our client */
GstJackAudioClient *client;
/* our ports */
jack_port_t **ports;
int port_count;
};
struct _GstJackAudioSrcClass
{
GstBaseAudioSrcClass parent_class;
};
GType gst_jackaudiosrc_get_type (void);
G_END_DECLS
#endif /* __GST_JACK_AUDIO_SRC_H__ */
/*
* GStreamer
* Copyright (C) 2006 Wim Taymans <wim@fluendo.com>
* Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca>
*
* 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:
*
* 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
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_JACK_RING_BUFFER_H__
#define __GST_JACK_RING_BUFFER_H__
#define GST_TYPE_JACK_RING_BUFFER (gst_jack_ring_buffer_get_type())
#define GST_JACK_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_JACK_RING_BUFFER,GstJackRingBuffer))
#define GST_JACK_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_JACK_RING_BUFFER,GstJackRingBufferClass))
#define GST_JACK_RING_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_JACK_RING_BUFFER,GstJackRingBufferClass))
#define GST_JACK_RING_BUFFER_CAST(obj) ((GstJackRingBuffer *)obj)
#define GST_IS_JACK_RING_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_JACK_RING_BUFFER))
#define GST_IS_JACK_RING_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_JACK_RING_BUFFER))
typedef struct _GstJackRingBuffer GstJackRingBuffer;
typedef struct _GstJackRingBufferClass GstJackRingBufferClass;
struct _GstJackRingBuffer
{
GstRingBuffer object;
gint sample_rate;
gint buffer_size;
gint channels;
};
struct _GstJackRingBufferClass
{
GstRingBufferClass parent_class;
};
static void gst_jack_ring_buffer_class_init(GstJackRingBufferClass * klass);
static void gst_jack_ring_buffer_init(GstJackRingBuffer * ringbuffer,
GstJackRingBufferClass * klass);
static void gst_jack_ring_buffer_dispose(GObject * object);
static void gst_jack_ring_buffer_finalize(GObject * object);
static GstRingBufferClass *ring_parent_class = NULL;
static gboolean gst_jack_ring_buffer_open_device(GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_close_device(GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_acquire(GstRingBuffer * buf,GstRingBufferSpec * spec);
static gboolean gst_jack_ring_buffer_release(GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_start(GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_pause(GstRingBuffer * buf);
static gboolean gst_jack_ring_buffer_stop(GstRingBuffer * buf);
static guint gst_jack_ring_buffer_delay(GstRingBuffer * buf);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment