2 * Copyright (C) 2006 Wim Taymans <wim@fluendo.com>
4 * gstjackaudiosink.c: jack audio sink implementation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * SECTION:element-jackaudiosink
24 * @see_also: #GstBaseAudioSink, #GstRingBuffer
26 * A Sink that outputs data to Jack ports.
28 * It will create N Jack ports named out_<name>_<num> where
29 * <name> is the element name and <num> is starting from 1.
30 * Each port corresponds to a gstreamer channel.
32 * The samplerate as exposed on the caps is always the same as the samplerate of
35 * When the #GstJackAudioSink:connect property is set to auto, this element
36 * will try to connect each output port to a random physical jack input pin. In
37 * this mode, the sink will expose the number of physical channels on its pad
40 * When the #GstJackAudioSink:connect property is set to none, the element will
41 * accept any number of input channels and will create (but not connect) an
42 * output port for each channel.
44 * The element will generate an error when the Jack server is shut down when it
45 * was PAUSED or PLAYING. This element does not support dynamic rate and buffer
46 * size changes at runtime.
49 * <title>Example launch line</title>
51 * gst-launch audiotestsrc ! jackaudiosink
52 * ]| Play a sine wave to using jack.
55 * Last reviewed on 2006-11-30 (0.10.4)
62 #include <gst/gst-i18n-plugin.h>
66 #include "gstjackaudiosink.h"
67 #include "gstjackringbuffer.h"
69 GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_sink_debug);
70 #define GST_CAT_DEFAULT gst_jack_audio_sink_debug
73 gst_jack_audio_sink_allocate_channels (GstJackAudioSink * sink, gint channels)
75 jack_client_t *client;
77 client = gst_jack_audio_client_get_client (sink->client);
79 /* remove ports we don't need */
80 while (sink->port_count > channels) {
81 jack_port_unregister (client, sink->ports[--sink->port_count]);
84 /* alloc enough output ports */
85 sink->ports = g_realloc (sink->ports, sizeof (jack_port_t *) * channels);
86 sink->buffers = g_realloc (sink->buffers, sizeof (sample_t *) * channels);
88 /* create an output port for each channel */
89 while (sink->port_count < channels) {
92 /* port names start from 1 and are local to the element */
94 g_strdup_printf ("out_%s_%d", GST_ELEMENT_NAME (sink),
95 sink->port_count + 1);
96 sink->ports[sink->port_count] =
97 jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE,
99 if (sink->ports[sink->port_count] == NULL)
110 gst_jack_audio_sink_free_channels (GstJackAudioSink * sink)
113 jack_client_t *client;
115 client = gst_jack_audio_client_get_client (sink->client);
117 /* get rid of all ports */
118 while (sink->port_count) {
119 GST_LOG_OBJECT (sink, "unregister port %d", i);
120 if ((res = jack_port_unregister (client, sink->ports[i++]))) {
121 GST_DEBUG_OBJECT (sink, "unregister of port failed (%d)", res);
125 g_free (sink->ports);
127 g_free (sink->buffers);
128 sink->buffers = NULL;
131 /* ringbuffer abstract base class */
133 gst_jack_ring_buffer_get_type (void)
135 static volatile gsize ringbuffer_type = 0;
137 if (g_once_init_enter (&ringbuffer_type)) {
138 static const GTypeInfo ringbuffer_info = {
139 sizeof (GstJackRingBufferClass),
142 (GClassInitFunc) gst_jack_ring_buffer_class_init,
145 sizeof (GstJackRingBuffer),
147 (GInstanceInitFunc) gst_jack_ring_buffer_init,
150 GType tmp = g_type_register_static (GST_TYPE_RING_BUFFER,
151 "GstJackAudioSinkRingBuffer", &ringbuffer_info, 0);
152 g_once_init_leave (&ringbuffer_type, tmp);
155 return (GType) ringbuffer_type;
159 gst_jack_ring_buffer_class_init (GstJackRingBufferClass * klass)
161 GstRingBufferClass *gstringbuffer_class;
163 gstringbuffer_class = (GstRingBufferClass *) klass;
165 ring_parent_class = g_type_class_peek_parent (klass);
167 gstringbuffer_class->open_device =
168 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_open_device);
169 gstringbuffer_class->close_device =
170 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_close_device);
171 gstringbuffer_class->acquire =
172 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_acquire);
173 gstringbuffer_class->release =
174 GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_release);
175 gstringbuffer_class->start = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
176 gstringbuffer_class->pause = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_pause);
177 gstringbuffer_class->resume = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_start);
178 gstringbuffer_class->stop = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_stop);
180 gstringbuffer_class->delay = GST_DEBUG_FUNCPTR (gst_jack_ring_buffer_delay);
183 /* this is the callback of jack. This should RT-safe.
186 jack_process_cb (jack_nframes_t nframes, void *arg)
188 GstJackAudioSink *sink;
192 gint i, j, flen, channels;
195 buf = GST_RING_BUFFER_CAST (arg);
196 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
198 channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
200 /* get target buffers */
201 for (i = 0; i < channels; i++) {
203 (sample_t *) jack_port_get_buffer (sink->ports[i], nframes);
206 if (gst_ring_buffer_prepare_read (buf, &readseg, &readptr, &len)) {
207 flen = len / channels;
209 /* the number of samples must be exactly the segment size */
210 if (nframes * sizeof (sample_t) != flen)
213 GST_DEBUG_OBJECT (sink, "copy %d frames: %p, %d bytes, %d channels",
214 nframes, readptr, flen, channels);
215 data = (sample_t *) readptr;
217 /* the samples in the ringbuffer have the channels interleaved, we need to
218 * deinterleave into the jack target buffers */
219 for (i = 0; i < nframes; i++) {
220 for (j = 0; j < channels; j++) {
221 sink->buffers[j][i] = *data++;
225 /* clear written samples in the ringbuffer */
226 gst_ring_buffer_clear (buf, readseg);
228 /* we wrote one segment */
229 gst_ring_buffer_advance (buf, 1);
231 GST_DEBUG_OBJECT (sink, "write %d frames silence", nframes);
232 /* We are not allowed to read from the ringbuffer, write silence to all
233 * jack output buffers */
234 for (i = 0; i < channels; i++) {
235 memset (sink->buffers[i], 0, nframes * sizeof (sample_t));
243 GST_ERROR_OBJECT (sink, "nbytes (%d) != flen (%d)",
244 (gint) (nframes * sizeof (sample_t)), flen);
251 jack_sample_rate_cb (jack_nframes_t nframes, void *arg)
253 GstJackAudioSink *sink;
254 GstJackRingBuffer *abuf;
256 abuf = GST_JACK_RING_BUFFER_CAST (arg);
257 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg));
259 if (abuf->sample_rate != -1 && abuf->sample_rate != nframes)
267 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
268 (NULL), ("Jack changed the sample rate, which is not supported"));
275 jack_buffer_size_cb (jack_nframes_t nframes, void *arg)
277 GstJackAudioSink *sink;
278 GstJackRingBuffer *abuf;
280 abuf = GST_JACK_RING_BUFFER_CAST (arg);
281 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg));
283 if (abuf->buffer_size != -1 && abuf->buffer_size != nframes)
291 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
292 (NULL), ("Jack changed the buffer size, which is not supported"));
298 jack_shutdown_cb (void *arg)
300 GstJackAudioSink *sink;
302 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (arg));
304 GST_DEBUG_OBJECT (sink, "shutdown");
306 GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
307 (NULL), ("Jack server shutdown"));
311 gst_jack_ring_buffer_init (GstJackRingBuffer * buf,
312 GstJackRingBufferClass * g_class)
315 buf->buffer_size = -1;
316 buf->sample_rate = -1;
319 /* the _open_device method should make a connection with the server
322 gst_jack_ring_buffer_open_device (GstRingBuffer * buf)
324 GstJackAudioSink *sink;
325 jack_status_t status = 0;
328 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
330 GST_DEBUG_OBJECT (sink, "open");
332 name = g_get_application_name ();
336 sink->client = gst_jack_audio_client_new (name, sink->server,
338 GST_JACK_CLIENT_SINK,
340 jack_process_cb, jack_buffer_size_cb, jack_sample_rate_cb, buf, &status);
341 if (sink->client == NULL)
344 GST_DEBUG_OBJECT (sink, "opened");
351 if (status & JackServerFailed) {
352 GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
353 (_("Jack server not found")),
354 ("Cannot connect to the Jack server (status %d)", status));
356 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
357 (NULL), ("Jack client open error (status %d)", status));
363 /* close the connection with the server
366 gst_jack_ring_buffer_close_device (GstRingBuffer * buf)
368 GstJackAudioSink *sink;
370 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
372 GST_DEBUG_OBJECT (sink, "close");
374 gst_jack_audio_sink_free_channels (sink);
375 gst_jack_audio_client_free (sink->client);
381 /* allocate a buffer and setup resources to process the audio samples of
382 * the format as specified in @spec.
384 * We allocate N jack ports, one for each channel. If we are asked to
385 * automatically make a connection with physical ports, we connect as many
386 * ports as there are physical ports, leaving leftover ports unconnected.
388 * It is assumed that samplerate and number of channels are acceptable since our
389 * getcaps method will always provide correct values. If unacceptable caps are
390 * received for some reason, we fail here.
393 gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
395 GstJackAudioSink *sink;
396 GstJackRingBuffer *abuf;
398 gint sample_rate, buffer_size;
399 gint i, rate, bpf, channels, res;
400 jack_client_t *client;
402 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
403 abuf = GST_JACK_RING_BUFFER_CAST (buf);
405 GST_DEBUG_OBJECT (sink, "acquire");
407 client = gst_jack_audio_client_get_client (sink->client);
409 rate = GST_AUDIO_INFO_RATE (&spec->info);
411 /* sample rate must be that of the server */
412 sample_rate = jack_get_sample_rate (client);
413 if (sample_rate != rate)
414 goto wrong_samplerate;
416 channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
417 bpf = GST_AUDIO_INFO_BPF (&spec->info);
419 if (!gst_jack_audio_sink_allocate_channels (sink, channels))
422 buffer_size = jack_get_buffer_size (client);
424 /* the segment size in bytes, this is large enough to hold a buffer of 32bit floats
425 * for all channels */
426 spec->segsize = buffer_size * sizeof (gfloat) * channels;
427 spec->latency_time = gst_util_uint64_scale (spec->segsize,
428 (GST_SECOND / GST_USECOND), rate * bpf);
429 /* segtotal based on buffer-time latency */
430 spec->segtotal = spec->buffer_time / spec->latency_time;
431 if (spec->segtotal < 2) {
433 spec->buffer_time = spec->latency_time * spec->segtotal;
436 GST_DEBUG_OBJECT (sink, "buffer time: %" G_GINT64_FORMAT " usec",
438 GST_DEBUG_OBJECT (sink, "latency time: %" G_GINT64_FORMAT " usec",
440 GST_DEBUG_OBJECT (sink, "buffer_size %d, segsize %d, segtotal %d",
441 buffer_size, spec->segsize, spec->segtotal);
443 /* allocate the ringbuffer memory now */
444 buf->size = spec->segtotal * spec->segsize;
445 buf->memory = g_malloc0 (buf->size);
447 if ((res = gst_jack_audio_client_set_active (sink->client, TRUE)))
448 goto could_not_activate;
450 /* if we need to automatically connect the ports, do so now. We must do this
451 * after activating the client. */
452 if (sink->connect == GST_JACK_CONNECT_AUTO
453 || sink->connect == GST_JACK_CONNECT_AUTO_FORCED) {
454 /* find all the physical input ports. A physical input port is a port
455 * associated with a hardware device. Someone needs connect to a physical
456 * port in order to hear something. */
457 ports = jack_get_ports (client, NULL, NULL,
458 JackPortIsPhysical | JackPortIsInput);
460 /* no ports? fine then we don't do anything except for posting a warning
462 GST_ELEMENT_WARNING (sink, RESOURCE, NOT_FOUND, (NULL),
463 ("No physical input ports found, leaving ports unconnected"));
467 for (i = 0; i < channels; i++) {
468 /* stop when all input ports are exhausted */
469 if (ports[i] == NULL) {
470 /* post a warning that we could not connect all ports */
471 GST_ELEMENT_WARNING (sink, RESOURCE, NOT_FOUND, (NULL),
472 ("No more physical ports, leaving some ports unconnected"));
475 GST_DEBUG_OBJECT (sink, "try connecting to %s",
476 jack_port_name (sink->ports[i]));
477 /* connect the port to a physical port */
478 res = jack_connect (client, jack_port_name (sink->ports[i]), ports[i]);
479 if (res != 0 && res != EEXIST)
486 abuf->sample_rate = sample_rate;
487 abuf->buffer_size = buffer_size;
488 abuf->channels = channels;
495 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
496 ("Wrong samplerate, server is running at %d and we received %d",
502 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
503 ("Cannot allocate more Jack ports"));
508 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
509 ("Could not activate client (%d:%s)", res, g_strerror (res)));
514 GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
515 ("Could not connect output ports to physical ports (%d:%s)",
516 res, g_strerror (res)));
522 /* function is called with LOCK */
524 gst_jack_ring_buffer_release (GstRingBuffer * buf)
526 GstJackAudioSink *sink;
527 GstJackRingBuffer *abuf;
530 abuf = GST_JACK_RING_BUFFER_CAST (buf);
531 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
533 GST_DEBUG_OBJECT (sink, "release");
535 if ((res = gst_jack_audio_client_set_active (sink->client, FALSE))) {
536 /* we only warn, this means the server is probably shut down and the client
538 GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, (NULL),
539 ("Could not deactivate Jack client (%d)", res));
543 abuf->buffer_size = -1;
544 abuf->sample_rate = -1;
546 /* free the buffer */
547 g_free (buf->memory);
554 gst_jack_ring_buffer_start (GstRingBuffer * buf)
556 GstJackAudioSink *sink;
558 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
560 GST_DEBUG_OBJECT (sink, "start");
566 gst_jack_ring_buffer_pause (GstRingBuffer * buf)
568 GstJackAudioSink *sink;
570 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
572 GST_DEBUG_OBJECT (sink, "pause");
578 gst_jack_ring_buffer_stop (GstRingBuffer * buf)
580 GstJackAudioSink *sink;
582 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
584 GST_DEBUG_OBJECT (sink, "stop");
589 #if defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)
591 gst_jack_ring_buffer_delay (GstRingBuffer * buf)
593 GstJackAudioSink *sink;
595 jack_latency_range_t range;
597 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
599 for (i = 0; i < sink->port_count; i++) {
600 jack_port_get_latency_range (sink->ports[i], JackPlaybackLatency, &range);
605 GST_LOG_OBJECT (sink, "delay %u", res);
609 #else /* !(defined (HAVE_JACK_0_120_1) || defined(HAVE_JACK_1_9_7)) */
611 gst_jack_ring_buffer_delay (GstRingBuffer * buf)
613 GstJackAudioSink *sink;
616 jack_client_t *client;
618 sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
619 client = gst_jack_audio_client_get_client (sink->client);
621 for (i = 0; i < sink->port_count; i++) {
622 latency = jack_port_get_total_latency (client, sink->ports[i]);
627 GST_LOG_OBJECT (sink, "delay %u", res);
633 static GstStaticPadTemplate jackaudiosink_sink_factory =
634 GST_STATIC_PAD_TEMPLATE ("sink",
637 GST_STATIC_CAPS ("audio/x-raw, "
638 "format = (string) " GST_JACK_FORMAT_STR ", "
639 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
642 /* AudioSink signals and args */
649 #define DEFAULT_PROP_CONNECT GST_JACK_CONNECT_AUTO
650 #define DEFAULT_PROP_SERVER NULL
661 #define gst_jack_audio_sink_parent_class parent_class
662 G_DEFINE_TYPE (GstJackAudioSink, gst_jack_audio_sink, GST_TYPE_BASE_AUDIO_SINK);
664 static void gst_jack_audio_sink_dispose (GObject * object);
665 static void gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
666 const GValue * value, GParamSpec * pspec);
667 static void gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
668 GValue * value, GParamSpec * pspec);
670 static GstCaps *gst_jack_audio_sink_getcaps (GstBaseSink * bsink,
672 static GstRingBuffer *gst_jack_audio_sink_create_ringbuffer (GstBaseAudioSink *
676 gst_jack_audio_sink_class_init (GstJackAudioSinkClass * klass)
678 GObjectClass *gobject_class;
679 GstElementClass *gstelement_class;
680 GstBaseSinkClass *gstbasesink_class;
681 GstBaseAudioSinkClass *gstbaseaudiosink_class;
683 GST_DEBUG_CATEGORY_INIT (gst_jack_audio_sink_debug, "jacksink", 0,
686 gobject_class = (GObjectClass *) klass;
687 gstelement_class = (GstElementClass *) klass;
688 gstbasesink_class = (GstBaseSinkClass *) klass;
689 gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
691 gobject_class->dispose = gst_jack_audio_sink_dispose;
692 gobject_class->get_property = gst_jack_audio_sink_get_property;
693 gobject_class->set_property = gst_jack_audio_sink_set_property;
695 g_object_class_install_property (gobject_class, PROP_CONNECT,
696 g_param_spec_enum ("connect", "Connect",
697 "Specify how the output ports will be connected",
698 GST_TYPE_JACK_CONNECT, DEFAULT_PROP_CONNECT,
699 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
701 g_object_class_install_property (gobject_class, PROP_SERVER,
702 g_param_spec_string ("server", "Server",
703 "The Jack server to connect to (NULL = default)",
704 DEFAULT_PROP_SERVER, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
706 g_object_class_install_property (gobject_class, PROP_CLIENT,
707 g_param_spec_boxed ("client", "JackClient", "Handle for jack client",
708 GST_TYPE_JACK_CLIENT,
709 GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
710 G_PARAM_STATIC_STRINGS));
712 gst_element_class_set_details_simple (gstelement_class, "Audio Sink (Jack)",
713 "Sink/Audio", "Output audio to a JACK server",
714 "Wim Taymans <wim.taymans@gmail.com>");
716 gst_element_class_add_pad_template (gstelement_class,
717 gst_static_pad_template_get (&jackaudiosink_sink_factory));
719 gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_jack_audio_sink_getcaps);
721 gstbaseaudiosink_class->create_ringbuffer =
722 GST_DEBUG_FUNCPTR (gst_jack_audio_sink_create_ringbuffer);
724 /* ref class from a thread-safe context to work around missing bit of
725 * thread-safety in GObject */
726 g_type_class_ref (GST_TYPE_JACK_RING_BUFFER);
728 gst_jack_audio_client_init ();
732 gst_jack_audio_sink_init (GstJackAudioSink * sink)
734 sink->connect = DEFAULT_PROP_CONNECT;
735 sink->server = g_strdup (DEFAULT_PROP_SERVER);
736 sink->jclient = NULL;
738 sink->port_count = 0;
739 sink->buffers = NULL;
743 gst_jack_audio_sink_dispose (GObject * object)
745 GstJackAudioSink *sink = GST_JACK_AUDIO_SINK (object);
747 gst_caps_replace (&sink->caps, NULL);
748 G_OBJECT_CLASS (parent_class)->dispose (object);
752 gst_jack_audio_sink_set_property (GObject * object, guint prop_id,
753 const GValue * value, GParamSpec * pspec)
755 GstJackAudioSink *sink;
757 sink = GST_JACK_AUDIO_SINK (object);
761 sink->connect = g_value_get_enum (value);
764 g_free (sink->server);
765 sink->server = g_value_dup_string (value);
768 if (GST_STATE (sink) == GST_STATE_NULL ||
769 GST_STATE (sink) == GST_STATE_READY) {
770 sink->jclient = g_value_get_boxed (value);
774 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
780 gst_jack_audio_sink_get_property (GObject * object, guint prop_id,
781 GValue * value, GParamSpec * pspec)
783 GstJackAudioSink *sink;
785 sink = GST_JACK_AUDIO_SINK (object);
789 g_value_set_enum (value, sink->connect);
792 g_value_set_string (value, sink->server);
795 g_value_set_boxed (value, sink->jclient);
798 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
804 gst_jack_audio_sink_getcaps (GstBaseSink * bsink, GstCaps * filter)
806 GstJackAudioSink *sink = GST_JACK_AUDIO_SINK (bsink);
810 jack_client_t *client;
812 if (sink->client == NULL)
815 client = gst_jack_audio_client_get_client (sink->client);
817 if (sink->connect == GST_JACK_CONNECT_AUTO) {
818 /* get a port count, this is the number of channels we can automatically
820 ports = jack_get_ports (client, NULL, NULL,
821 JackPortIsPhysical | JackPortIsInput);
824 for (; ports[max]; max++);
829 /* we allow any number of pads, something else is going to connect the
835 rate = jack_get_sample_rate (client);
837 GST_DEBUG_OBJECT (sink, "got %d-%d ports, samplerate: %d", min, max, rate);
840 sink->caps = gst_caps_new_simple ("audio/x-raw",
841 "format", G_TYPE_STRING, GST_JACK_FORMAT_STR,
842 "rate", G_TYPE_INT, rate,
843 "channels", GST_TYPE_INT_RANGE, min, max, NULL);
845 GST_INFO_OBJECT (sink, "returning caps %" GST_PTR_FORMAT, sink->caps);
847 return gst_caps_ref (sink->caps);
852 GST_DEBUG_OBJECT (sink, "device not open, using template caps");
853 /* base class will get template caps for us when we return NULL */
858 static GstRingBuffer *
859 gst_jack_audio_sink_create_ringbuffer (GstBaseAudioSink * sink)
861 GstRingBuffer *buffer;
863 buffer = g_object_new (GST_TYPE_JACK_RING_BUFFER, NULL);
864 GST_DEBUG_OBJECT (sink, "created ringbuffer @%p", buffer);