summaryrefslogtreecommitdiff
path: root/ext/jack
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-08-18 19:21:07 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2011-08-18 19:21:07 +0200
commit09b15d7dfebf5bce173e2083d9dd2b305ab97070 (patch)
treeb5c2a8b0da5f46a3ad6ab0ac33d7dd1348fe61b8 /ext/jack
parent44c1589b482e5a105c5b0cfd3fec3c96f3e22896 (diff)
port to new audio caps.
Diffstat (limited to 'ext/jack')
-rw-r--r--ext/jack/gstjack.h6
-rw-r--r--ext/jack/gstjackaudiosink.c27
-rw-r--r--ext/jack/gstjackaudiosrc.c27
3 files changed, 34 insertions, 26 deletions
diff --git a/ext/jack/gstjack.h b/ext/jack/gstjack.h
index d923866df..9724cc0ed 100644
--- a/ext/jack/gstjack.h
+++ b/ext/jack/gstjack.h
@@ -49,6 +49,12 @@ typedef jack_default_audio_sample_t sample_t;
#define GST_TYPE_JACK_CONNECT (gst_jack_connect_get_type())
#define GST_TYPE_JACK_CLIENT (gst_jack_client_get_type ())
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define GST_JACK_FORMAT_STR "F32_LE"
+#else
+#define GST_JACK_FORMAT_STR "F32_BE"
+#endif
+
GType gst_jack_client_get_type(void);
GType gst_jack_connect_get_type(void);
diff --git a/ext/jack/gstjackaudiosink.c b/ext/jack/gstjackaudiosink.c
index 7f4ecf73b..0434089f0 100644
--- a/ext/jack/gstjackaudiosink.c
+++ b/ext/jack/gstjackaudiosink.c
@@ -195,7 +195,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
buf = GST_RING_BUFFER_CAST (arg);
sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
- channels = buf->spec.channels;
+ channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
/* get target buffers */
for (i = 0; i < channels; i++) {
@@ -396,7 +396,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
GstJackRingBuffer *abuf;
const char **ports;
gint sample_rate, buffer_size;
- gint i, channels, res;
+ gint i, rate, bpf, channels, res;
jack_client_t *client;
sink = GST_JACK_AUDIO_SINK (GST_OBJECT_PARENT (buf));
@@ -406,12 +406,15 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
client = gst_jack_audio_client_get_client (sink->client);
+ rate = GST_AUDIO_INFO_RATE (&spec->info);
+
/* sample rate must be that of the server */
sample_rate = jack_get_sample_rate (client);
- if (sample_rate != spec->rate)
+ if (sample_rate != rate)
goto wrong_samplerate;
- channels = spec->channels;
+ channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
+ bpf = GST_AUDIO_INFO_BPF (&spec->info);
if (!gst_jack_audio_sink_allocate_channels (sink, channels))
goto out_of_ports;
@@ -422,7 +425,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
* for all channels */
spec->segsize = buffer_size * sizeof (gfloat) * channels;
spec->latency_time = gst_util_uint64_scale (spec->segsize,
- (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
+ (GST_SECOND / GST_USECOND), rate * bpf);
/* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
if (spec->segtotal < 2) {
@@ -482,7 +485,7 @@ done:
abuf->sample_rate = sample_rate;
abuf->buffer_size = buffer_size;
- abuf->channels = spec->channels;
+ abuf->channels = channels;
return TRUE;
@@ -491,7 +494,7 @@ wrong_samplerate:
{
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
("Wrong samplerate, server is running at %d and we received %d",
- sample_rate, spec->rate));
+ sample_rate, rate));
return FALSE;
}
out_of_ports:
@@ -631,9 +634,8 @@ static GstStaticPadTemplate jackaudiosink_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 32, "
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " GST_JACK_FORMAT_STR ", "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
@@ -835,9 +837,8 @@ gst_jack_audio_sink_getcaps (GstBaseSink * bsink, GstCaps * filter)
GST_DEBUG_OBJECT (sink, "got %d-%d ports, samplerate: %d", min, max, rate);
if (!sink->caps) {
- sink->caps = gst_caps_new_simple ("audio/x-raw-float",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 32,
+ sink->caps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, GST_JACK_FORMAT_STR,
"rate", G_TYPE_INT, rate,
"channels", GST_TYPE_INT_RANGE, min, max, NULL);
}
diff --git a/ext/jack/gstjackaudiosrc.c b/ext/jack/gstjackaudiosrc.c
index 5f18f4339..12c276828 100644
--- a/ext/jack/gstjackaudiosrc.c
+++ b/ext/jack/gstjackaudiosrc.c
@@ -215,7 +215,7 @@ jack_process_cb (jack_nframes_t nframes, void *arg)
buf = GST_RING_BUFFER_CAST (arg);
src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
- channels = buf->spec.channels;
+ channels = GST_AUDIO_INFO_CHANNELS (&buf->spec.info);
/* get input buffers */
for (i = 0; i < channels; i++)
@@ -404,7 +404,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
GstJackRingBuffer *abuf;
const char **ports;
gint sample_rate, buffer_size;
- gint i, channels, res;
+ gint i, bpf, rate, channels, res;
jack_client_t *client;
src = GST_JACK_AUDIO_SRC (GST_OBJECT_PARENT (buf));
@@ -414,12 +414,15 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
client = gst_jack_audio_client_get_client (src->client);
+ rate = GST_AUDIO_INFO_RATE (&spec->info);
+
/* sample rate must be that of the server */
sample_rate = jack_get_sample_rate (client);
- if (sample_rate != spec->rate)
+ if (sample_rate != rate)
goto wrong_samplerate;
- channels = spec->channels;
+ bpf = GST_AUDIO_INFO_BPF (&spec->info);
+ channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
if (!gst_jack_audio_src_allocate_channels (src, channels))
goto out_of_ports;
@@ -432,7 +435,7 @@ gst_jack_ring_buffer_acquire (GstRingBuffer * buf, GstRingBufferSpec * spec)
* for all channels */
spec->segsize = buffer_size * sizeof (gfloat) * channels;
spec->latency_time = gst_util_uint64_scale (spec->segsize,
- (GST_SECOND / GST_USECOND), spec->rate * spec->bytes_per_sample);
+ (GST_SECOND / GST_USECOND), rate * bpf);
/* segtotal based on buffer-time latency */
spec->segtotal = spec->buffer_time / spec->latency_time;
if (spec->segtotal < 2) {
@@ -494,7 +497,7 @@ done:
abuf->sample_rate = sample_rate;
abuf->buffer_size = buffer_size;
- abuf->channels = spec->channels;
+ abuf->channels = channels;
return TRUE;
@@ -503,7 +506,7 @@ wrong_samplerate:
{
GST_ELEMENT_ERROR (src, RESOURCE, SETTINGS, (NULL),
("Wrong samplerate, server is running at %d and we received %d",
- sample_rate, spec->rate));
+ sample_rate, rate));
return FALSE;
}
out_of_ports:
@@ -668,9 +671,8 @@ enum
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, "
- "width = (int) 32, "
+ GST_STATIC_CAPS ("audio/x-raw, "
+ "format = (string) " GST_JACK_FORMAT_STR ", "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]")
);
@@ -858,9 +860,8 @@ gst_jack_audio_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
GST_DEBUG_OBJECT (src, "got %d-%d ports, samplerate: %d", min, max, rate);
if (!src->caps) {
- src->caps = gst_caps_new_simple ("audio/x-raw-float",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, 32,
+ src->caps = gst_caps_new_simple ("audio/x-raw",
+ "format", G_TYPE_STRING, GST_JACK_FORMAT_STR,
"rate", G_TYPE_INT, rate,
"channels", GST_TYPE_INT_RANGE, min, max, NULL);
}