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 "gstjackaudiosrc.h"
82 #include "gstjackringbuffer.h"
84 GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_src_debug);
85 #define GST_CAT_DEFAULT gst_jack_audio_src_debug
88 gst_jack_audio_src_allocate_channels (GstJackAudioSrc * src, gint channels)
90 jack_client_t *client;
92 client = gst_jack_audio_client_get_client (src->client);
94 /* remove ports we don't need */
95 while (src->port_count > channels)
96 jack_port_unregister (client, src->ports[--src->port_count]);
98 /* alloc enough input ports */
99 src->ports = g_realloc (src->ports, sizeof (jack_port_t *) * channels);
101 /* create an input port for each channel */
102 while (src->port_count < channels) {
105 /* port names start from 1 and are local to the element */
107 g_strdup_printf ("in_%s_%d", GST_ELEMENT_NAME (src),
108 src->port_count + 1);
109 src->ports[src->port_count] =
110 jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE,
112 if (src->ports[src->port_count] == NULL)
123 gst_jack_audio_src_free_channels (GstJackAudioSrc * src)
126 jack_client_t *client;
128 client = gst_jack_audio_client_get_client (src->client);
130 /* get rid of all ports */
131 while (src->port_count) {
132 GST_LOG_OBJECT (src, "unregister port %d", i);
133 if ((res = jack_port_unregister (client, src->ports[i++])))
134 GST_DEBUG_OBJECT (src, "unregister of port failed (%d)", res);
142 /* ringbuffer abstract base class */
144 gst_jack_ring_buffer_get_type (void)
146 static GType ringbuffer_type = 0;
148 if (!ringbuffer_type) {
149 static const GTypeInfo ringbuffer_info = { sizeof (GstJackRingBufferClass),
152 (GClassInitFunc) gst_jack_ring_buffer_class_init,
155 sizeof (GstJackRingBuffer),
157 (GInstanceInitFunc) gst_jack_ring_buffer_init,
162 g_type_register_static (GST_TYPE_RING_BUFFER,
163 "GstJackAudioSrcRingBuffer", &ringbuffer_info, 0);
165 return ringbuffer_type;
169 gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass)
171 GObjectClass *gobject_class;
172 GstObjectClass *gstobject_class;
173 GstRingBufferClass *gstringbuffer_class;
175 gobject_class = (GObjectClass *) klass;
176 gstobject_class = (GstObjectClass *) klass;
177 gstringbuffer_class = (GstRingBufferClass *) klass;
179 ring_parent_class = g_type_class_peek_parent (klass);
181 gobject_class->dispose = gst_jack_ring_buffer_dispose;
182 gobject_class->finalize = gst_jack_ring_buffer_finalize;
184 gstringbuffer_class->open_device =
185 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_open_device);
186 gstringbuffer_class->close_device =
187 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_close_device);
188 gstringbuffer_class->acquire =
189 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_acquire);
190 gstringbuffer_class->release =
191 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_release);
192 gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
193 gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_pause);
194 gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
195 gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_stop);
197 gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_delay);
200 /* this is the callback of jack. This should be RT-safe.
201 * Writes samples from the jack input port's buffer to the gst ring buffer.
204 jack_process_cb (jack_nframes_t nframes, void *arg)
206 GstJackAudioSrc *src;
208 GstJackRingBuffer *abuf;
210 guint8 *writeptr, *dataStart;
213 sample_t **buffers, *data;
215 buf = GST_RING_BUFFER_CAST (arg);
216 abuf = GST_JACK_RING_BUFFER_CAST (arg);
217 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
219 channels = buf->spec.channels;
220 len = sizeof (sample_t) * nframes * channels;
222 /* alloc pointers to samples */
223 buffers = g_alloca (sizeof (sample_t *) * channels);
224 data = g_alloca (len);
226 /* get input buffers */
227 for (i = 0; i < channels; i++)
228 buffers[i] = (sample_t *) jack_port_get_buffer (src->ports[i], nframes);
231 dataStart = (guint8 *) data;
233 /* the samples in the jack input buffers have to be interleaved into the
236 for (i = 0; i < nframes; ++i)
237 for (j = 0; j < channels; ++j)
238 *data++ = buffers[j][i];
240 if (gst_ring_buffer_prepare_read (buf, &writeseg, &writeptr, &givenLen)) {
241 memcpy (writeptr, (char *) dataStart, givenLen);
243 GST_DEBUG ("copy %d frames: %p, %d bytes, %d channels", nframes, writeptr,
244 len / channels, channels);
246 /* clear written samples in the ringbuffer */
247 // gst_ring_buffer_clear(buf, 0);
249 /* we wrote one segment */
250 gst_ring_buffer_advance (buf, 1);
257 jack_sample_rate_cb (jack_nframes_t nframes, void *arg)
259 GstJackAudioSrc *src;
260 GstJackRingBuffer *abuf;
262 abuf = GST_JACK_RING_BUFFER_CAST (arg);
263 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
265 if (abuf->sample_rate != -1 && abuf->sample_rate != nframes)
273 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS,
274 (NULL), ("Jack changed the sample rate, which is not supported"));
281 jack_buffer_size_cb (jack_nframes_t nframes, void *arg)
283 GstJackAudioSrc *src;
284 GstJackRingBuffer *abuf;
286 abuf = GST_JACK_RING_BUFFER_CAST (arg);
287 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
289 if (abuf->buffer_size != -1 && abuf->buffer_size != nframes)
297 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS,
298 (NULL), ("Jack changed the buffer size, which is not supported"));
304 jack_shutdown_cb (void *arg)
306 GstJackAudioSrc *src;
308 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (arg));
310 GST_DEBUG_OBJECT (src, "shutdown");
312 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
313 (NULL), ("Jack server shutdown"));
317 gst_jack_ring_buffer_init (GstJackRingBuffer * buf,
318 GstJackRingBufferClass * g_class)
321 buf->buffer_size = -1;
322 buf->sample_rate = -1;
326 gst_jack_ring_buffer_dispose (GObject * object)
328 G_OBJECT_CLASS (ring_parent_class)->dispose (object);
332 gst_jack_ring_buffer_finalize (GObject * object)
334 GstJackRingBuffer *ringbuffer;
335 ringbuffer = GST_JACK_RING_BUFFER_CAST (object);
336 G_OBJECT_CLASS (ring_parent_class)->finalize (object);
339 /* the _open_device method should make a connection with the server
342 gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
344 GstJackAudioSrc *src;
345 jack_status_t status = 0;
348 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
350 GST_DEBUG_OBJECT (src, "open");
352 name = g_get_application_name ();
356 src->client = gst_jack_audio_client_new (name, src->server,
357 GST_JACK_CLIENT_SOURCE,
359 jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status);
360 if (src->client == NULL)
363 GST_DEBUG_OBJECT (src, "opened");
370 if (status & JackServerFailed) {
371 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
372 (NULL), ("Cannot connect to the Jack server (status %d)", status));
374 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_WRITE,
375 (NULL), ("Jack client open error (status %d)", status));
381 /* close the connection with the server
384 gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
386 GstJackAudioSrc *src;
388 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
390 GST_DEBUG_OBJECT (src, "close");
392 gst_jack_audio_src_free_channels (src);
393 gst_jack_audio_client_free (src->client);
400 /* allocate a buffer and setup resources to process the audio samples of
401 * the format as specified in @spec.
403 * We allocate N jack ports, one for each channel. If we are asked to
404 * automatically make a connection with physical ports, we connect as many
405 * ports as there are physical ports, leaving leftover ports unconnected.
407 * It is assumed that samplerate and number of channels are acceptable since our
408 * getcaps method will always provide correct values. If unacceptable caps are
409 * received for some reason, we fail here.
412 gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
414 GstJackAudioSrc *src;
415 GstJackRingBuffer *abuf;
417 gint sample_rate, buffer_size;
418 gint i, channels, res;
419 jack_client_t *client;
421 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
422 abuf = GST_JACK_RING_BUFFER_CAST (buf);
424 GST_DEBUG_OBJECT (src, "acquire");
426 client = gst_jack_audio_client_get_client (src->client);
428 /* sample rate must be that of the server */
429 sample_rate = jack_get_sample_rate (client);
430 if (sample_rate != spec->rate)
431 goto wrong_samplerate;
433 channels = spec->channels;
435 if (!gst_jack_audio_src_allocate_channels (src, channels))
438 buffer_size = jack_get_buffer_size (client);
440 /* the segment size in bytes, this is large enough to hold a buffer of 32bit floats
441 * for all channels */
442 spec->segsize = buffer_size * sizeof (gfloat) * channels;
443 spec->latency_time = gst_util_uint64_scale (spec->segsize,
444 (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
445 /* segtotal based on buffer-time latency */
446 spec->segtotal = spec->buffer_time / spec->latency_time;
447 if (spec->segtotal < 2) {
449 spec->buffer_time = spec->latency_time * spec->segtotal;
452 GST_DEBUG_OBJECT (src, "buffer time: %" G_GINT64_FORMAT " usec",
454 GST_DEBUG_OBJECT (src, "latency time: %" G_GINT64_FORMAT " usec",
456 GST_DEBUG_OBJECT (src, "buffer_size %d, segsize %d, segtotal %d",
457 buffer_size, spec->segsize, spec->segtotal);
459 /* allocate the ringbuffer memory now */
460 buf->data = gst_buffer_new_and_alloc (spec->segtotal * spec->segsize);
461 memset (GST_BUFFER_DATA (buf->data), 0, GST_BUFFER_SIZE (buf->data));
463 if ((res = gst_jack_audio_client_set_active (src->client, TRUE)))
464 goto could_not_activate;
466 /* if we need to automatically connect the ports, do so now. We must do this
467 * after activating the client. */
468 if (src->connect == GST_JACK_CONNECT_AUTO
469 || src->connect == GST_JACK_CONNECT_AUTO_FORCED) {
470 /* find all the physical output ports. A physical output port is a port
471 * associated with a hardware device. Someone needs connect to a physical
472 * port in order to capture something. */
474 jack_get_ports (client, NULL, NULL,
475 JackPortIsPhysical | JackPortIsOutput);
477 /* no ports? fine then we don't do anything except for posting a warning
479 GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL),
480 ("No physical output ports found, leaving ports unconnected"));
484 for (i = 0; i < channels; i++) {
485 /* stop when all output ports are exhausted */
486 if (ports[i] == NULL) {
487 /* post a warning that we could not connect all ports */
488 GST_ELEMENT_WARNING (src, RESOURCE, NOT_FOUND, (NULL),
489 ("No more physical ports, leaving some ports unconnected"));
492 GST_DEBUG_OBJECT (src, "try connecting to %s",
493 jack_port_name (src->ports[i]));
495 /* connect the physical port to a port */
496 res = jack_connect (client, ports[i], jack_port_name (src->ports[i]));
497 if (res != 0 && res != EEXIST)
504 abuf->sample_rate = sample_rate;
505 abuf->buffer_size = buffer_size;
506 abuf->channels = spec->channels;
513 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
514 ("Wrong samplerate, server is running at %d and we received %d",
515 sample_rate, spec->rate));
520 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
521 ("Cannot allocate more Jack ports"));
526 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
527 ("Could not activate client (%d:%s)", res, g_strerror (res)));
532 GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
533 ("Could not connect input ports to physical ports (%d:%s)",
534 res, g_strerror (res)));
540 /* function is called with LOCK */
542 gst_jack_ring_buffer_release (GstRingBuffer * buf)
544 GstJackAudioSrc *src;
545 GstJackRingBuffer *abuf;
548 abuf = GST_JACK_RING_BUFFER_CAST (buf);
549 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
551 GST_DEBUG_OBJECT (src, "release");
553 if ((res = gst_jack_audio_client_set_active (src->client, FALSE))) {
554 /* we only warn, this means the server is probably shut down and the client
556 GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, (NULL),
557 ("Could not deactivate Jack client (%d)", res));
561 abuf->buffer_size = -1;
562 abuf->sample_rate = -1;
564 /* free the buffer */
565 gst_buffer_unref (buf->data);
572 gst_jack_ring_buffer_start (GstRingBuffer * buf)
574 GstJackAudioSrc *src;
576 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
578 GST_DEBUG_OBJECT (src, "start");
584 gst_jack_ring_buffer_pause (GstRingBuffer * buf)
586 GstJackAudioSrc *src;
588 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
590 GST_DEBUG_OBJECT (src, "pause");
596 gst_jack_ring_buffer_stop (GstRingBuffer * buf)
598 GstJackAudioSrc *src;
600 src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
602 GST_DEBUG_OBJECT (src, "stop");
608 gst_jack_ring_buffer_delay (GstRingBuffer * buf)
610 GstJackAudioSrc *src;
611 guint i, res = 0, latency;
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 latency = jack_port_get_total_latency (client, src->ports[i]);
623 GST_DEBUG_OBJECT (src, "delay %u", res);
628 /* Audiosrc signals and args */
635 #define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO
636 #define DEFAULT_PROP_SERVER NULL
647 /* the capabilities of the inputs and outputs.
649 * describe the real formats here.
652 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
655 GST_STATIC_CAPS ("audio/x-raw-float, "
656 "endianness = (int) { " G_STRINGIFY (G_BYTE_ORDER) " }, "
658 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
661 #define _do_init(bla) \
662 GST_DEBUG_CATEGORY_INIT(gst_jack_audio_src_debug, "jacksrc", 0, "jacksrc element");
664 GST_BOILERPLATE_FULL (GstJackAudioSrc, gst_jack_audio_src, GstBaseAudioSrc,
665 GST_TYPE_BASE_AUDIO_SRC, _do_init);
667 static void gst_jack_audio_src_set_property (GObject * object, guint prop_id,
668 const GValue * value, GParamSpec * pspec);
669 static void gst_jack_audio_src_get_property (GObject * object, guint prop_id,
670 GValue * value, GParamSpec * pspec);
672 static GstCaps *gst_jack_audio_src_getcaps (GstBaseSrc * bsrc);
673 static GstRingBuffer *gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc *
676 /* GObject vmethod implementations */
679 gst_jack_audio_src_base_init (gpointer gclass)
682 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
684 gst_element_class_add_pad_template (element_class,
685 gst_static_pad_template_get (&src_factory));
686 gst_element_class_set_details_simple (element_class, "Audio Source (Jack)",
688 "Input from Jack", "Tristan Matthews <tristan@sat.qc.ca>");
691 /* initialize the jack_audio_src's class */
693 gst_jack_audio_src_class_init (GstJackAudioSrcClass * klass)
695 GObjectClass *gobject_class;
696 GstElementClass *gstelement_class;
697 GstBaseSrcClass *gstbasesrc_class;
698 GstBaseAudioSrcClass *gstbaseaudiosrc_class;
700 gobject_class = (GObjectClass *) klass;
701 gstelement_class = (GstElementClass *) klass;
703 gstbasesrc_class = (GstBaseSrcClass *) klass;
704 gstbaseaudiosrc_class = (GstBaseAudioSrcClass *) klass;
706 gobject_class->set_property = gst_jack_audio_src_set_property;
707 gobject_class->get_property = gst_jack_audio_src_get_property;
709 g_object_class_install_property (gobject_class, PROP_CONNECT,
710 g_param_spec_enum ("connect", "Connect",
711 "Specify how the input ports will be connected",
712 GST_TYPE_JACK_CONNECT, DEFAULT_PROP_CONNECT, G_PARAM_READWRITE));
714 g_object_class_install_property (gobject_class, PROP_SERVER,
715 g_param_spec_string ("server", "Server",
716 "The Jack server to connect to (NULL = default)",
717 DEFAULT_PROP_SERVER, G_PARAM_READWRITE));
719 gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_src_getcaps);
720 gstbaseaudiosrc_class->create_ringbuffer =
721 GST_DEBUG_FUNCPTR (gst_jack_audio_src_create_ringbuffer);
723 /* ref class from a thread-safe context to work around missing bit of
724 * thread-safety in GObject */
725 g_type_class_ref (GST_TYPE_JACK_RING_BUFFER);
727 gst_jack_audio_client_init ();
730 /* initialize the new element
731 * instantiate pads and add them to element
732 * set pad calback functions
733 * initialize instance structure
736 gst_jack_audio_src_init (GstJackAudioSrc * src, GstJackAudioSrcClass * gclass)
738 //gst_base_src_set_live(GST_BASE_SRC (src), TRUE);
739 src->connect = DEFAULT_PROP_CONNECT;
740 src->server = g_strdup (DEFAULT_PROP_SERVER);
746 gst_jack_audio_src_set_property (GObject * object, guint prop_id,
747 const GValue * value, GParamSpec * pspec)
749 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object);
753 src->connect = g_value_get_enum (value);
756 g_free (src->server);
757 src->server = g_value_dup_string (value);
760 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
766 gst_jack_audio_src_get_property (GObject * object, guint prop_id,
767 GValue * value, GParamSpec * pspec)
769 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (object);
773 g_value_set_enum (value, src->connect);
776 g_value_set_string (value, src->server);
779 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
785 gst_jack_audio_src_getcaps (GstBaseSrc * bsrc)
787 GstJackAudioSrc *src = GST_JACK_AUDIO_SRC (bsrc);
791 jack_client_t *client;
793 if (src->client == NULL)
796 client = gst_jack_audio_client_get_client (src->client);
798 if (src->connect == GST_JACK_CONNECT_AUTO) {
799 /* get a port count, this is the number of channels we can automatically
801 ports = jack_get_ports (client, NULL, NULL,
802 JackPortIsPhysical | JackPortIsOutput);
805 for (; ports[max]; max++);
811 /* we allow any number of pads, something else is going to connect the
817 rate = jack_get_sample_rate (client);
819 GST_DEBUG_OBJECT (src, "got %d-%d ports, samplerate: %d", min, max, rate);
822 src->caps = gst_caps_new_simple ("audio/x-raw-float",
823 "endianness", G_TYPE_INT, G_BYTE_ORDER,
824 "width", G_TYPE_INT, 32,
825 "rate", G_TYPE_INT, rate,
826 "channels", GST_TYPE_INT_RANGE, min, max, NULL);
828 GST_INFO_OBJECT (src, "returning caps %" GST_PTR_FORMAT, src->caps);
830 return gst_caps_ref (src->caps);
835 GST_DEBUG_OBJECT (src, "device not open, using template caps");
836 /* base class will get template caps for us when we return NULL */
841 static GstRingBuffer *
842 gst_jack_audio_src_create_ringbuffer (GstBaseAudioSrc * src)
844 GstRingBuffer *buffer;
846 buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL);
847 GST_DEBUG_OBJECT (src, "created ringbuffer @%p", buffer);