mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-11 19:06:33 +00:00
jackaudiosrc: Port to the new multichannel audio caps
This commit is contained in:
parent
e1bf53562e
commit
531d611f83
3 changed files with 25 additions and 28 deletions
|
@ -428,7 +428,7 @@ gst_jack_ring_buffer_acquire (GstAudioRingBuffer * buf,
|
||||||
if (!gst_jack_audio_src_allocate_channels (src, channels))
|
if (!gst_jack_audio_src_allocate_channels (src, channels))
|
||||||
goto out_of_ports;
|
goto out_of_ports;
|
||||||
|
|
||||||
gst_jack_set_layout_on_caps (&spec->caps, channels);
|
gst_jack_set_layout (buf, spec);
|
||||||
|
|
||||||
buffer_size = jack_get_buffer_size (client);
|
buffer_size = jack_get_buffer_size (client);
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gstjackutil.h"
|
#include "gstjackutil.h"
|
||||||
#include <gst/audio/multichannel.h>
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
static const GstAudioChannelPosition default_positions[8][8] = {
|
static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
/* 1 channel */
|
/* 1 channel */
|
||||||
{
|
{
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_MONO,
|
GST_AUDIO_CHANNEL_POSITION_MONO,
|
||||||
},
|
},
|
||||||
/* 2 channels */
|
/* 2 channels */
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
{
|
{
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_LFE, /* or FRONT_CENTER for 3.0? */
|
GST_AUDIO_CHANNEL_POSITION_LFE1, /* or FRONT_CENTER for 3.0? */
|
||||||
},
|
},
|
||||||
/* 4 channels (4.0 or 3.1?) */
|
/* 4 channels (4.0 or 3.1?) */
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
||||||
},
|
},
|
||||||
/* 7 channels */
|
/* 7 channels */
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
|
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
|
||||||
},
|
},
|
||||||
/* 8 channels */
|
/* 8 channels */
|
||||||
|
@ -77,7 +77,7 @@ static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
||||||
GST_AUDIO_CHANNEL_POSITION_LFE,
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
||||||
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
||||||
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
||||||
}
|
}
|
||||||
|
@ -87,28 +87,24 @@ static const GstAudioChannelPosition default_positions[8][8] = {
|
||||||
/* if channels are less than or equal to 8, we set a default layout,
|
/* if channels are less than or equal to 8, we set a default layout,
|
||||||
* otherwise set layout to an array of GST_AUDIO_CHANNEL_POSITION_NONE */
|
* otherwise set layout to an array of GST_AUDIO_CHANNEL_POSITION_NONE */
|
||||||
void
|
void
|
||||||
gst_jack_set_layout_on_caps (GstCaps ** caps, gint channels)
|
gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec * spec)
|
||||||
{
|
{
|
||||||
int c;
|
gint i;
|
||||||
GValue pos = { 0 };
|
|
||||||
GValue chanpos = { 0 };
|
|
||||||
gst_caps_unref (*caps);
|
|
||||||
|
|
||||||
if (channels <= 8) {
|
if (spec->info.channels <= 8) {
|
||||||
g_assert (channels >= 1);
|
for (i = 0; i < spec->info.channels; i++)
|
||||||
gst_audio_set_channel_positions (gst_caps_get_structure (*caps, 0),
|
spec->info.position[i] = default_positions[spec->info.channels - 1][i];
|
||||||
default_positions[channels - 1]);
|
gst_audio_channel_positions_to_valid_order (spec->info.position,
|
||||||
|
spec->info.channels);
|
||||||
|
gst_audio_ring_buffer_set_channel_positions (buffer,
|
||||||
|
default_positions[spec->info.channels - 1]);
|
||||||
} else {
|
} else {
|
||||||
g_value_init (&chanpos, GST_TYPE_ARRAY);
|
spec->info.flags |= GST_AUDIO_FLAG_UNPOSITIONED;
|
||||||
g_value_init (&pos, GST_TYPE_AUDIO_CHANNEL_POSITION);
|
for (i = 0; i < G_N_ELEMENTS (spec->info.position); i++)
|
||||||
for (c = 0; c < channels; c++) {
|
spec->info.position[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
|
||||||
g_value_set_enum (&pos, GST_AUDIO_CHANNEL_POSITION_NONE);
|
gst_audio_ring_buffer_set_channel_positions (buffer, spec->info.position);
|
||||||
gst_value_array_append_value (&chanpos, &pos);
|
|
||||||
}
|
}
|
||||||
g_value_unset (&pos);
|
|
||||||
gst_structure_set_value (gst_caps_get_structure (*caps, 0),
|
gst_caps_unref (spec->caps);
|
||||||
"channel-positions", &chanpos);
|
spec->caps = gst_audio_info_to_caps (&spec->info);
|
||||||
g_value_unset (&chanpos);
|
|
||||||
}
|
|
||||||
gst_caps_ref (*caps);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
#define _GST_JACK_UTIL_H_
|
#define _GST_JACK_UTIL_H_
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/audio/gstaudioringbuffer.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_jack_set_layout_on_caps (GstCaps **caps, gint channels);
|
gst_jack_set_layout (GstAudioRingBuffer * buffer, GstAudioRingBufferSpec *spec);
|
||||||
|
|
||||||
#endif // _GST_JACK_UTIL_H_
|
#endif // _GST_JACK_UTIL_H_
|
||||||
|
|
Loading…
Reference in a new issue