2 * Copyright (C) 2008 Tristan Matthews <tristan@sat.qc.ca>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
22 * Alternatively, the contents of this file may be used under the
23 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
24 * which case the following provisions apply instead of the ones
27 * This library is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU Library General Public
29 * License as published by the Free Software Foundation; either
30 * version 2 of the License, or (at your option) any later version.
32 * This library is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 * Library General Public License for more details.
37 * You should have received a copy of the GNU Library General Public
38 * License along with this library; if not, write to the
39 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
40 * Boston, MA 02111-1307, USA.
44 * SECTION:element-jackaudiosrc
45 * @see_also: #GstBaseAudioSrc, #GstRingBuffer
47 * A Src that inputs data from Jack ports.
49 * It will create N Jack ports named in_<name>_<num> where
50 * <name> is the element name and <num> is starting from 1.
51 * Each port corresponds to a gstreamer channel.
53 * The samplerate as exposed on the caps is always the same as the samplerate of
56 * When the #GstJackAudioSrc:connect property is set to auto, this element
57 * will try to connect each input port to a random physical jack output pin.
59 * When the #GstJackAudioSrc:connect property is set to none, the element will
60 * accept any number of output channels and will create (but not connect) an
61 * input port for each channel.
63 * The element will generate an error when the Jack server is shut down when it
64 * was PAUSED or PLAYING. This element does not support dynamic rate and buffer
65 * size changes at runtime.
68 * <title>Example launch line</title>
70 * gst-launch jackaudiosrc connect=0 ! jackaudiosink connect=0
71 * ]| Get audio input into gstreamer from jack.
74 * Last reviewed on 2008-07-22 (0.10.4)
81 #include <gst/gst-i18n-plugin.h>
85 #include "gstjackaudiosrc.h"
86 #include "gstjackringbuffer.h"
87 #include "gstjackutil.h"
89 GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_src_debug);
90 #define GST_CAT_DEFAULT gst_jack_audio_src_debug
93 gst_jack_audio_src_allocate_channels (GstJackAudioSrc * src, gint channels)
95 jack_client_t *client;
97 client = gst_jack_audio_client_get_client (src->client);
99 /* remove ports we don't need */
100 while (src->port_count > channels)
101 jack_port_unregister (client, src->ports[--src->port_count]);
103 /* alloc enough input ports */
104 src->ports = g_realloc (src->ports, sizeof (jack_port_t *) * channels);
105 src->buffers = g_realloc (src->buffers, sizeof (sample_t *) * channels);
107 /* create an input port for each channel */
108 while (src->port_count < channels) {
111 /* port names start from 1 and are local to the element */
113 g_strdup_printf ("in_%s_%d", GST_ELEMENT_NAME (src),
114 src->port_count + 1);
115 src->ports[src->port_count] =
116 jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE,
118 if (src->ports[src->port_count] == NULL)
129 gst_jack_audio_src_free_channels (GstJackAudioSrc * src)
132 jack_client_t *client;
134 client = gst_jack_audio_client_get_client (src->client);
136 /* get rid of all ports */
137 while (src->port_count) {
138 GST_LOG_OBJECT (src, "unregister port %d", i);
139 if ((res = jack_port_unregister (client, src->ports[i++])))
140 GST_DEBUG_OBJECT (src, "unregister of port failed (%d)", res);
146 g_free (src->buffers);
150 /* ringbuffer abstract base class */
152 gst_jack_ring_buffer_get_type (void)
154 static volatile gsize ringbuffer_type = 0;
156 if (g_once_init_enter (&ringbuffer_type)) {
157 static const GTypeInfo ringbuffer_info = { sizeof (GstJackRingBufferClass),
160 (GClassInitFunc) gst_jack_ring_buffer_class_init,
163 sizeof (GstJackRingBuffer),
165 (GInstanceInitFunc) gst_jack_ring_buffer_init,
168 GType tmp = g_type_register_static (GST_TYPE_RING_BUFFER,
169 "GstJackAudioSrcRingBuffer", &ringbuffer_info, 0);
170 g_once_init_leave (&ringbuffer_type, tmp);
173 return (GType) ringbuffer_type;
177 gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass)
179 GObjectClass *gobject_class;
180 GstObjectClass *gstobject_class;
181 GstRingBufferClass *gstringbuffer_class;
183 gobject_class = (GObjectClass *) klass;
184 gstobject_class = (GstObjectClass *) klass;
185 gstringbuffer_class = (GstRingBufferClass *) klass;
187 ring_parent_class = g_type_class_peek_parent (klass);
189 gstringbuffer_class->open_device =
190 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_open_device);
191 gstringbuffer_class->close_device =
192 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_close_device);
193 gstringbuffer_class->acquire =
194 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_acquire);
195 gstringbuffer_class->release =
196 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_release);
197 gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
198 gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_pause);
199 gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
200 gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_stop);
202 gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_delay);
205 /* this is the callback of jack. This should be RT-safe.
206 * Writes samples from the jack input port's buffer to the gst ring buffer.
209 jack_process_cb (jack_nframes_t nframes, void *arg)
211 GstJackAudioSrc *src;
216 gint channels, i, j, flen;
219 buf = GST_RING_BUFFER_CAST (arg);
220 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
222 channels = buf->spec.channels;
224 /* get input buffers */
225 for (i = 0; i < channels; i++)
227 (sample_t *) jack_port_get_buffer (src->ports[i], nframes);
229 if (gst_ring_buffer_prepare_read (buf, &writeseg, &writeptr, &len)) {
230 flen = len / channels;
232 /* the number of samples must be exactly the segment size */
233 if (nframes * sizeof (sample_t) != flen)
236 /* the samples in the jack input buffers have to be interleaved into the
238 data = (sample_t *) writeptr;
239 for (i = 0; i < nframes; ++i)
240 for (j = 0; j < channels; ++j)
241 *data++ = src->buffers[j][i];
243 GST_DEBUG ("copy %d frames: %p, %d bytes, %d channels", nframes, writeptr,
244 len / channels, channels);
246 /* we wrote one segment */
247 gst_ring_buffer_advance (buf, 1);
254 GST_ERROR_OBJECT (src, "nbytes (%d) != flen (%d)",
255 (gint) (nframes * sizeof (sample_t)), flen);
262 jack_sample_rate_cb (jack_nframes_t nframes, void *arg)
264 GstJackAudioSrc *src;
265 GstJackRingBuffer *abuf;
267 abuf = GST_JACK_RING_BUFFER_CAST (arg);
268 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
270 if (abuf->sample_rate != -1 && abuf->sample_rate != nframes)
278 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS,
279 (NULL), ("Jack changed the sample rate, which is not supported"));
286 jack_buffer_size_cb (jack_nframes_t nframes, void *arg)
288 GstJackAudioSrc *src;
289 GstJackRingBuffer *abuf;
291 abuf = GST_JACK_RING_BUFFER_CAST (arg);
292 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
294 if (abuf->buffer_size != -1 && abuf->buffer_size != nframes)
302 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS,
303 (NULL), ("Jack changed the buffer size, which is not supported"));
309 jack_shutdown_cb (void *arg)
311 GstJackAudioSrc *src;
313 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
315 GST_DEBUG_OBJECT (src, "shutdown");
317 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
318 (NULL), ("Jack server shutdown"));
322 gst_jack_ring_buffer_init (GstJackRingBuffer * buf,
323 GstJackRingBufferClass * g_class)
326 buf->buffer_size = -1;
327 buf->sample_rate = -1;
330 /* the _open_device method should make a connection with the server
333 gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
335 GstJackAudioSrc *src;
336 jack_status_t status = 0;
339 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
341 GST_DEBUG_OBJECT (src, "open");
343 name = g_get_application_name ();
347 src->client = gst_jack_audio_client_new (name, src->server,
349 GST_JACK_CLIENT_SOURCE,
351 jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status);
352 if (src->client == NULL)
355 GST_DEBUG_OBJECT (src, "opened");
362 if (status & JackServerFailed) {
363 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
364 (_("Jack server not found")),
365 ("Cannot connect to the Jack server (status %d)", status));
367 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_WRITE,
368 (NULL), ("Jack client open error (status %d)", status));
374 /* close the connection with the server
377 gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
379 GstJackAudioSrc *src;
381 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
383 GST_DEBUG_OBJECT (src, "close");
385 gst_jack_audio_src_free_channels (src);
386 gst_jack_audio_client_free (src->client);
393 /* allocate a buffer and setup resources to process the audio samples of
394 * the format as specified in @spec.
396 * We allocate N jack ports, one for each channel. If we are asked to
397 * automatically make a connection with physical ports, we connect as many
398 * ports as there are physical ports, leaving leftover ports unconnected.
400 * It is assumed that samplerate and number of channels are acceptable since our
401 * getcaps method will always provide correct values. If unacceptable caps are
402 * received for some reason, we fail here.
405 gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
407 GstJackAudioSrc *src;
408 GstJackRingBuffer *abuf;
410 gint sample_rate, buffer_size;
411 gint i, channels, res;
412 jack_client_t *client;
414 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
415 abuf = GST_JACK_RING_BUFFER_CAST (buf);
417 GST_DEBUG_OBJECT (src, "acquire");
419 client = gst_jack_audio_client_get_client (src->client);
421 /* sample rate must be that of the server */
422 sample_rate = jack_get_sample_rate (client);
423 if (sample_rate != spec->rate)
424 goto wrong_samplerate;
426 channels = spec->channels;
428 if (!gst_jack_audio_src_allocate_channels (src, channels))
431 gst_jack_set_layout_on_caps (&spec->caps, channels);
433 buffer_size = jack_get_buffer_size (client);
435 /* the segment size in bytes, this is large enough to hold a buffer of 32bit floats
436 * for all channels */
437 spec->segsize = buffer_size * sizeof (gfloat) * channels;
438 spec->latency_time = gst_util_uint64_scale (spec->segsize,
439 (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
440 /* segtotal based on buffer-time latency */
441 spec->segtotal = spec->buffer_time / spec->latency_time;
442 if (spec->segtotal < 2) {
444 spec->buffer_time = spec->latency_time * spec->segtotal;
447 GST_DEBUG_OBJECT (src, "buffer time: %" G_GINT64_FORMAT " usec",
449 GST_DEBUG_OBJECT (src, "latency time: %" G_GINT64_FORMAT " usec",
451 GST_DEBUG_OBJECT (src, "buffer_size %d, segsize %d, segtotal %d",
452 buffer_size, spec->segsize, spec->segtotal);
454 /* allocate the ringbuffer memory now */
455 buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
456 memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
458 if ((res = gst_jack_audio_client_set_active (src->client, TRUE)))
459 goto could_not_activate;
461 /* if we need to automatically connect the ports, do so now. We must do this
462 * after activating the client. */
463 if (src->connect == GST_JACK_CONNECT_AUTO
464 || src->connect == GST_JACK_CONNECT_AUTO_FORCED) {
465 /* find all the physical output ports. A physical output port is a port
466 * associated with a hardware device. Someone needs connect to a physical
467 * port in order to capture something. */
469 jack_get_ports (client, NULL, NULL,
470 JackPortIsPhysical | JackPortIsOutput);
472 /* no ports? fine then we don't do anything except for posting a warning
474 GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL),
475 ("No physical output ports found, leaving ports unconnected"));
479 for (i = 0; i < channels; i++) {
480 /* stop when all output ports are exhausted */
481 if (ports[i] == NULL) {
482 /* post a warning that we could not connect all ports */
483 GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL),
484 ("No more physical ports, leaving some ports unconnected"));
487 GST_DEBUG_OBJECT (src, "try connecting to %s",
488 jack_port_name (src->ports[i]));
490 /* connect the physical port to a port */
491 res = jack_connect (client, ports[i], jack_port_name (src->ports[i]));
492 if (res != 0 && res != EEXIST)
499 abuf->sample_rate = sample_rate;
500 abuf->buffer_size = buffer_size;
501 abuf->channels = spec->channels;
508 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
509 ("Wrong samplerate, server is running at %d and we received %d",
510 sample_rate, spec->rate));
515 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
516 ("Cannot allocate more Jack ports"));
521 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
522 ("Could not activate client (%d:%s)", res, g_strerror (res)));
527 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
528 ("Could not connect input ports to physical ports (%d:%s)",
529 res, g_strerror (res)));
535 /* function is called with LOCK */
537 gst_jack_ring_buffer_release (GstRingBuffer * buf)
539 GstJackAudioSrc *src;
540 GstJackRingBuffer *abuf;
543 abuf = GST_JACK_RING_BUFFER_CAST (buf);
544 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
546 GST_DEBUG_OBJECT (src, "release");
548 if ((res = gst_jack_audio_client_set_active (src->client, FALSE))) {
549 /* we only warn, this means the server is probably shut down and the client
551 GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
552 ("Could not deactivate Jack client (%d)", res));
556 abuf->buffer_size = -1;
557 abuf->sample_rate = -1;
559 /* free the buffer */
560 gst_buffer_unref (buf->data);
567 gst_jack_ring_buffer_start (GstRingBuffer * buf)
569 GstJackAudioSrc *src;
571 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
573 GST_DEBUG_OBJECT (src, "start");
579 gst_jack_ring_buffer_pause (GstRingBuffer * buf)
581 GstJackAudioSrc *src;
583 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
585 GST_DEBUG_OBJECT (src, "pause");
591 gst_jack_ring_buffer_stop (GstRingBuffer * buf)
593 GstJackAudioSrc *src;
595 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
597 GST_DEBUG_OBJECT (src, "stop");
603 gst_jack_ring_buffer_delay (GstRingBuffer * buf)
605 GstJackAudioSrc *src;
607 #ifdef HAVE_JACK_0_120_2
608 jack_latency_range_t range;
612 jack_client_t *client;
614 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
615 client = gst_jack_audio_client_get_client (src->client);
617 for (i = 0; i < src->port_count; i++) {
618 #ifdef HAVE_JACK_0_120_2
619 jack_port_get_latency_range (src->ports[i], JackCaptureLatency, &range);
623 latency = jack_port_get_total_latency (client, src->ports[i]);
629 GST_DEBUG_OBJECT (src, "delay %u", res);
634 /* Audiosrc signals and args */
641 #define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO
642 #define DEFAULT_PROP_SERVER NULL
654 /* the capabilities of the inputs and outputs.
656 * describe the real formats here.
659 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
662 GST_STATIC_CAPS ("audio/x-raw-float, "
663 "endianness = (int) BYTE_ORDER, "
665 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
668 #define _do_init(bla) \
669 GST_DEBUG_CATEGORY_INIT(gst_jack_audio_src_debug, "jacksrc", 0, "jacksrc element");
671 GST_BOILERPLATE_FULL (GstJackAudioSrc, gst_jack_audio_src, GstBaseAudioSrc,
672 GST_TYPE_BASE_AUDIO_SRC, _do_init);
674 static void gst_jack_audio_src_dispose (GObject * object);
675 static void gst_jack_audio_src_set_property (GObject * object, guint prop_id,
676 const GValue * value, GParamSpec * pspec);
677 static void gst_jack_audio_src_get_property (GObject * object, guint prop_id,
678 GValue * value, GParamSpec * pspec);
680 static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc);
681 static GstRingBuffer *gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc *
684 /* GObject vmethod implementations */
687 gst_jack_audio_src_base_init (gpointer gclass)
689 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
691 gst_element_class_add_pad_template (element_class,
692 gst_static_pad_template_get (&src_factory));
693 gst_element_class_set_details_simple (element_class, "Audio Source (Jack)",
694 "Source/Audio", "Captures audio from a JACK server",
695 "Tristan Matthews <tristan@sat.qc.ca>");
698 /* initialize the jack_audio_src's class */
700 gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
702 GObjectClass *gobject_class;
703 GstElementClass *gstelement_class;
704 GstBaseSrcClass *gstbasesrc_class;
705 GstBaseAudioSrcClass *gstbaseaudiosrc_class;
707 gobject_class = (GObjectClass *) klass;
708 gstelement_class = (GstElementClass *) klass;
710 gstbasesrc_class = (GstBaseSrcClass *) klass;
711 gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
713 gobject_class->dispose = gst_jack_audio_src_dispose;
714 gobject_class->set_property = gst_jack_audio_src_set_property;
715 gobject_class->get_property = gst_jack_audio_src_get_property;
717 g_object_class_install_property (gobject_class, PROP_CONNECT,
718 g_param_spec_enum ("connect", "Connect",
719 "Specify how the input ports will be connected",
720 GST_TYPE_JACK_CONNECT, DEFAULT_PROP_CONNECT,
721 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
723 g_object_class_install_property (gobject_class, PROP_SERVER,
724 g_param_spec_string ("server", "Server",
725 "The Jack server to connect to (NULL = default)",
726 DEFAULT_PROP_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
728 g_object_class_install_property (gobject_class, PROP_CLIENT,
729 g_param_spec_boxed ("client", "JackClient", "Handle for jack client",
730 GST_TYPE_JACK_CLIENT,
731 GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
732 G_PARAM_STATIC_STRINGS));
734 gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_src_getcaps);
735 gstbaseaudiosrc_class->create_ringbuffer =
736 GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer);
738 /* ref class from a thread-safe context to work around missing bit of
739 * thread-safety in GObject */
740 g_type_class_ref (GST_TYPE_JACK_RING_BUFFER);
742 gst_jack_audio_client_init ();
745 /* initialize the new element
746 * instantiate pads and add them to element
747 * set pad calback functions
748 * initialize instance structure
751 gst_jack_audio_src_init (GstJackAudioSrc * src, GstJackAudioSrcClass * gclass)
753 //gst_base_src_set_live(GST_BASE_SRC (src), TRUE);
754 src->connect = DEFAULT_PROP_CONNECT;
755 src->server = g_strdup (DEFAULT_PROP_SERVER);
763 gst_jack_audio_src_dispose (GObject * object)
765 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object);
767 gst_caps_replace (&src->caps, NULL);
768 G_OBJECT_CLASS (parent_class)->dispose (object);
772 gst_jack_audio_src_set_property (GObject * object, guint prop_id,
773 const GValue * value, GParamSpec * pspec)
775 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object);
779 src->connect = g_value_get_enum (value);
782 g_free (src->server);
783 src->server = g_value_dup_string (value);
786 if (GST_STATE (src) == GST_STATE_NULL ||
787 GST_STATE (src) == GST_STATE_READY) {
788 src->jclient = g_value_get_boxed (value);
792 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
798 gst_jack_audio_src_get_property (GObject * object, guint prop_id,
799 GValue * value, GParamSpec * pspec)
801 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object);
805 g_value_set_enum (value, src->connect);
808 g_value_set_string (value, src->server);
811 g_value_set_boxed (value, src->jclient);
814 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
820 gst_jack_audio_src_getcaps (GstBaseSrc * bsrc)
822 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (bsrc);
826 jack_client_t *client;
828 if (src->client == NULL)
831 client = gst_jack_audio_client_get_client (src->client);
833 if (src->connect == GST_JACK_CONNECT_AUTO) {
834 /* get a port count, this is the number of channels we can automatically
836 ports = jack_get_ports (client, NULL, NULL,
837 JackPortIsPhysical | JackPortIsOutput);
840 for (; ports[max]; max++);
846 /* we allow any number of pads, something else is going to connect the
852 rate = jack_get_sample_rate (client);
854 GST_DEBUG_OBJECT (src, "got %d-%d ports, samplerate: %d", min, max, rate);
857 src->caps = gst_caps_new_simple ("audio/x-raw-float",
858 "endianness", G_TYPE_INT, G_BYTE_ORDER,
859 "width", G_TYPE_INT, 32,
860 "rate", G_TYPE_INT, rate,
861 "channels", GST_TYPE_INT_RANGE, min, max, NULL);
863 GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, src->caps);
865 return gst_caps_ref (src->caps);
870 GST_DEBUG_OBJECT (src, "device not open, using template caps");
871 /* base class will get template caps for us when we return NULL */
876 static GstRingBuffer *
877 gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
879 GstRingBuffer *buffer;
881 buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL);
882 GST_DEBUG_OBJECT (src, "created ringbuffer @%p", buffer);