port to new audio caps.

This commit is contained in:
Wim Taymans 2011-08-18 19:21:07 +02:00
parent 44c1589b48
commit 09b15d7dfe
8 changed files with 138 additions and 165 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -1274,16 +1274,16 @@ server_dead:
G_STMT_START { \
guint8 *sb = s, *db = d; \
while (s <= se && d < de) { \
memcpy (d, s, bps); \
s += bps; \
memcpy (d, s, bpf); \
s += bpf; \
*accum += outr; \
if ((*accum << 1) >= inr) { \
*accum -= inr; \
d += bps; \
d += bpf; \
} \
} \
in_samples -= (s - sb)/bps; \
out_samples -= (d - db)/bps; \
in_samples -= (s - sb)/bpf; \
out_samples -= (d - db)/bpf; \
GST_DEBUG ("fwd_up end %d/%d",*accum,*toprocess); \
} G_STMT_END
@ -1292,16 +1292,16 @@ G_STMT_START { \
G_STMT_START { \
guint8 *sb = s, *db = d; \
while (s <= se && d < de) { \
memcpy (d, s, bps); \
d += bps; \
memcpy (d, s, bpf); \
d += bpf; \
*accum += inr; \
if ((*accum << 1) >= outr) { \
*accum -= outr; \
s += bps; \
s += bpf; \
} \
} \
in_samples -= (s - sb)/bps; \
out_samples -= (d - db)/bps; \
in_samples -= (s - sb)/bpf; \
out_samples -= (d - db)/bpf; \
GST_DEBUG ("fwd_down end %d/%d",*accum,*toprocess); \
} G_STMT_END
@ -1309,16 +1309,16 @@ G_STMT_START { \
G_STMT_START { \
guint8 *sb = se, *db = d; \
while (s <= se && d < de) { \
memcpy (d, se, bps); \
se -= bps; \
memcpy (d, se, bpf); \
se -= bpf; \
*accum += outr; \
while (d < de && (*accum << 1) >= inr) { \
*accum -= inr; \
d += bps; \
d += bpf; \
} \
} \
in_samples -= (sb - se)/bps; \
out_samples -= (d - db)/bps; \
in_samples -= (sb - se)/bpf; \
out_samples -= (d - db)/bpf; \
GST_DEBUG ("rev_up end %d/%d",*accum,*toprocess); \
} G_STMT_END
@ -1326,16 +1326,16 @@ G_STMT_START { \
G_STMT_START { \
guint8 *sb = se, *db = d; \
while (s <= se && d < de) { \
memcpy (d, se, bps); \
d += bps; \
memcpy (d, se, bpf); \
d += bpf; \
*accum += inr; \
while (s <= se && (*accum << 1) >= outr) { \
*accum -= outr; \
se -= bps; \
se -= bpf; \
} \
} \
in_samples -= (sb - se)/bps; \
out_samples -= (d - db)/bps; \
in_samples -= (sb - se)/bpf; \
out_samples -= (d - db)/bpf; \
GST_DEBUG ("rev_down end %d/%d",*accum,*toprocess); \
} G_STMT_END
@ -1351,7 +1351,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
guint8 *data_end;
gboolean reverse;
gint *toprocess;
gint inr, outr, bps;
gint inr, outr, bpf;
gint64 offset;
guint bufsize;
@ -1381,7 +1381,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
GST_DEBUG_OBJECT (psink, "entering commit");
pbuf->in_commit = TRUE;
bps = buf->spec.bytes_per_sample;
bpf = GST_AUDIO_INFO_BPF (&buf->spec.info);
bufsize = buf->spec.segsize * buf->spec.segtotal;
/* our toy resampler for trick modes */
@ -1400,7 +1400,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
/* data_end points to the last sample we have to write, not past it. This is
* needed to properly handle reverse playback: it points to the last sample. */
data_end = data + (bps * inr);
data_end = data + (bpf * inr);
#ifdef HAVE_PULSE_1_0
if (g_atomic_int_get (&psink->format_lost)) {
@ -1413,7 +1413,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
goto was_paused;
/* offset is in bytes */
offset = *sample * bps;
offset = *sample * bpf;
while (*toprocess > 0) {
size_t avail;
@ -1427,7 +1427,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
GST_LOG_OBJECT (psink, "discontinuity, offset is %" G_GINT64_FORMAT ", "
"last offset was %" G_GINT64_FORMAT, offset, pbuf->m_lastoffset);
towrite = out_samples * bps;
towrite = out_samples * bpf;
/* Only ever write segsize bytes at once. This will
* also limit the PA shm buffer to segsize
@ -1444,7 +1444,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
GST_LOG_OBJECT (psink,
"flushing %u samples at offset %" G_GINT64_FORMAT,
(guint) pbuf->m_towrite / bps, pbuf->m_offset);
(guint) pbuf->m_towrite / bpf, pbuf->m_offset);
if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
pbuf->m_towrite, NULL, pbuf->m_offset, PA_SEEK_ABSOLUTE) < 0) {
@ -1468,8 +1468,8 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
if (pbuf->m_writable == (size_t) - 1)
goto writable_size_failed;
pbuf->m_writable /= bps;
pbuf->m_writable *= bps; /* handle only complete samples */
pbuf->m_writable /= bpf;
pbuf->m_writable *= bpf; /* handle only complete samples */
if (pbuf->m_writable >= towrite)
break;
@ -1518,7 +1518,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
if (pbuf->m_writable < towrite)
towrite = pbuf->m_writable;
avail = towrite / bps;
avail = towrite / bpf;
GST_LOG_OBJECT (psink, "writing %u samples at offset %" G_GUINT64_FORMAT,
(guint) avail, offset);
@ -1569,14 +1569,14 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
pbuf->m_towrite += towrite;
pbuf->m_writable -= towrite;
avail = towrite / bps;
avail = towrite / bpf;
}
/* flush the buffer if it's full */
if ((pbuf->m_data != NULL) && (pbuf->m_towrite > 0)
&& (pbuf->m_writable == 0)) {
GST_LOG_OBJECT (psink, "flushing %u samples at offset %" G_GINT64_FORMAT,
(guint) pbuf->m_towrite / bps, pbuf->m_offset);
(guint) pbuf->m_towrite / bpf, pbuf->m_offset);
if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
pbuf->m_towrite, NULL, pbuf->m_offset, PA_SEEK_ABSOLUTE) < 0) {
@ -1587,7 +1587,7 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
}
*sample += avail;
offset += avail * bps;
offset += avail * bpf;
pbuf->m_lastoffset = offset;
/* check if we need to uncork after writing the samples */
@ -1615,13 +1615,13 @@ gst_pulseringbuffer_commit (GstRingBuffer * buf, guint64 * sample,
fake_done:
#endif
/* we consumed all samples here */
data = data_end + bps;
data = data_end + bpf;
pbuf->in_commit = FALSE;
pa_threaded_mainloop_unlock (mainloop);
done:
result = inr - ((data_end - data) / bps);
result = inr - ((data_end - data) / bpf);
GST_LOG_OBJECT (psink, "wrote %d samples", result);
return result;
@ -1686,12 +1686,12 @@ gst_pulsering_flush (GstPulseRingBuffer * pbuf)
/* flush the buffer if possible */
if (pbuf->stream && (pbuf->m_data != NULL) && (pbuf->m_towrite > 0)) {
#ifndef GST_DISABLE_GST_DEBUG
gint bps;
gint bpf;
bps = (GST_RING_BUFFER_CAST (pbuf))->spec.bytes_per_sample;
bpf = (GST_RING_BUFFER_CAST (pbuf))->spec.info.bpf;
GST_LOG_OBJECT (psink,
"flushing %u samples at offset %" G_GINT64_FORMAT,
(guint) pbuf->m_towrite / bps, pbuf->m_offset);
(guint) pbuf->m_towrite / bpf, pbuf->m_offset);
#endif
if (pa_stream_write (pbuf->stream, (uint8_t *) pbuf->m_data,
@ -1728,49 +1728,18 @@ static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element,
GstStateChange transition);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
# define FORMATS "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, " \
"S24_3LE, S24_3BE, S24_LE, S24_BE, S8 }"
#else
# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
# define FORMATS "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, " \
"S24_3BE, S24_3LE, S24_BE, S24_LE, S8 }"
#endif
static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-float, "
"endianness = (int) { " ENDIANNESS " }, "
"width = (int) 32, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 32, "
"depth = (int) 32, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 24, "
"depth = (int) 24, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 32, "
"depth = (int) 24, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"signed = (boolean) FALSE, "
"width = (int) 8, "
"depth = (int) 8, "
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMATS ", "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-alaw, "

View file

@ -99,37 +99,16 @@ static GstStateChangeReturn gst_pulsesrc_change_state (GstElement *
element, GstStateChange transition);
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
# define ENDIANNESS "LITTLE_ENDIAN, BIG_ENDIAN"
# define FORMATS "{ S16_LE, S16_BE, F32_LE, F32_BE, S32_LE, S32_BE, U8 }"
#else
# define ENDIANNESS "BIG_ENDIAN, LITTLE_ENDIAN"
# define FORMATS "{ S16_BE, S16_LE, F32_BE, F32_LE, S32_BE, S32_LE, U8 }"
#endif
static GstStaticPadTemplate pad_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-float, "
"endianness = (int) { " ENDIANNESS " }, "
"width = (int) 32, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"endianness = (int) { " ENDIANNESS " }, "
"signed = (boolean) TRUE, "
"width = (int) 32, "
"depth = (int) 32, "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-raw-int, "
"signed = (boolean) FALSE, "
"width = (int) 8, "
"depth = (int) 8, "
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) " FORMATS ", "
"rate = (int) [ 1, MAX ], "
"channels = (int) [ 1, 32 ];"
"audio/x-alaw, "
@ -853,9 +832,9 @@ gst_pulsesrc_create_stream (GstPulseSrc * pulsesrc, GstCaps * caps)
s = gst_caps_get_structure (caps, 0);
if (!gst_structure_has_field (s, "channel-layout") ||
!gst_pulse_gst_to_channel_map (&channel_map, &spec)) {
if (spec.channels == 1)
if (spec.info.channels == 1)
pa_channel_map_init_mono (&channel_map);
else if (spec.channels == 2)
else if (spec.info.channels == 2)
pa_channel_map_init_stereo (&channel_map);
else
need_channel_layout = TRUE;

View file

@ -80,37 +80,53 @@ gboolean
gst_pulse_fill_sample_spec (GstRingBufferSpec * spec, pa_sample_spec * ss)
{
if (spec->format == GST_MU_LAW && spec->width == 8)
if (spec->type == GST_BUFTYPE_RAW) {
switch (GST_AUDIO_INFO_FORMAT (&spec->info)) {
case GST_AUDIO_FORMAT_U8:
ss->format = PA_SAMPLE_U8;
break;
case GST_AUDIO_FORMAT_S16_LE:
ss->format = PA_SAMPLE_S16LE;
break;
case GST_AUDIO_FORMAT_S16_BE:
ss->format = PA_SAMPLE_S16BE;
break;
case GST_AUDIO_FORMAT_F32_LE:
ss->format = PA_SAMPLE_FLOAT32LE;
break;
case GST_AUDIO_FORMAT_F32_BE:
ss->format = PA_SAMPLE_FLOAT32BE;
break;
case GST_AUDIO_FORMAT_S32_LE:
ss->format = PA_SAMPLE_S32LE;
break;
case GST_AUDIO_FORMAT_S32_BE:
ss->format = PA_SAMPLE_S32BE;
break;
case GST_AUDIO_FORMAT_S24_3LE:
ss->format = PA_SAMPLE_S24LE;
break;
case GST_AUDIO_FORMAT_S24_3BE:
ss->format = PA_SAMPLE_S24BE;
break;
case GST_AUDIO_FORMAT_S24_LE:
ss->format = PA_SAMPLE_S24_32LE;
break;
case GST_AUDIO_FORMAT_S24_BE:
ss->format = PA_SAMPLE_S24_32BE;
break;
default:
return FALSE;
}
} else if (spec->type == GST_BUFTYPE_MU_LAW) {
ss->format = PA_SAMPLE_ULAW;
else if (spec->format == GST_A_LAW && spec->width == 8)
} else if (spec->type == GST_BUFTYPE_A_LAW) {
ss->format = PA_SAMPLE_ALAW;
else if (spec->format == GST_U8 && spec->width == 8)
ss->format = PA_SAMPLE_U8;
else if (spec->format == GST_S16_LE && spec->width == 16)
ss->format = PA_SAMPLE_S16LE;
else if (spec->format == GST_S16_BE && spec->width == 16)
ss->format = PA_SAMPLE_S16BE;
else if (spec->format == GST_FLOAT32_LE && spec->width == 32)
ss->format = PA_SAMPLE_FLOAT32LE;
else if (spec->format == GST_FLOAT32_BE && spec->width == 32)
ss->format = PA_SAMPLE_FLOAT32BE;
else if (spec->format == GST_S32_LE && spec->width == 32)
ss->format = PA_SAMPLE_S32LE;
else if (spec->format == GST_S32_BE && spec->width == 32)
ss->format = PA_SAMPLE_S32BE;
else if (spec->format == GST_S24_3LE && spec->width == 24)
ss->format = PA_SAMPLE_S24LE;
else if (spec->format == GST_S24_3BE && spec->width == 24)
ss->format = PA_SAMPLE_S24BE;
else if (spec->format == GST_S24_LE && spec->width == 32)
ss->format = PA_SAMPLE_S24_32LE;
else if (spec->format == GST_S24_BE && spec->width == 32)
ss->format = PA_SAMPLE_S24_32BE;
else
} else
return FALSE;
ss->channels = spec->channels;
ss->rate = spec->rate;
ss->channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
ss->rate = GST_AUDIO_INFO_RATE (&spec->info);
if (!pa_sample_spec_valid (ss))
return FALSE;
@ -236,7 +252,7 @@ gst_pulse_gst_to_channel_map (pa_channel_map * map,
return NULL;
}
for (i = 0; i < spec->channels; i++) {
for (i = 0; i < spec->info.channels; i++) {
if (pos[i] == GST_AUDIO_CHANNEL_POSITION_NONE) {
/* no valid mappings for these channels */
g_free (pos);
@ -248,7 +264,7 @@ gst_pulse_gst_to_channel_map (pa_channel_map * map,
}
g_free (pos);
map->channels = spec->channels;
map->channels = spec->info.channels;
if (!pa_channel_map_valid (map)) {
return NULL;
@ -264,12 +280,15 @@ gst_pulse_channel_map_to_gst (const pa_channel_map * map,
int i;
GstAudioChannelPosition *pos;
gboolean invalid = FALSE;
gint channels;
g_return_val_if_fail (map->channels == spec->channels, NULL);
channels = GST_AUDIO_INFO_CHANNELS (&spec->info);
pos = g_new0 (GstAudioChannelPosition, spec->channels + 1);
g_return_val_if_fail (map->channels == channels, NULL);
for (i = 0; i < spec->channels; i++) {
pos = g_new0 (GstAudioChannelPosition, channels + 1);
for (i = 0; i < channels; i++) {
if (map->map[i] == PA_CHANNEL_POSITION_INVALID) {
invalid = TRUE;
break;
@ -281,11 +300,11 @@ gst_pulse_channel_map_to_gst (const pa_channel_map * map,
}
}
if (!invalid && !gst_audio_check_channel_positions (pos, spec->channels))
if (!invalid && !gst_audio_check_channel_positions (pos, channels))
invalid = TRUE;
if (invalid) {
for (i = 0; i < spec->channels; i++)
for (i = 0; i < channels; i++)
pos[i] = GST_AUDIO_CHANNEL_POSITION_NONE;
}

View file

@ -154,8 +154,7 @@ gst_auto_audio_sink_reset (GstAutoAudioSink * sink)
gst_object_unref (targetpad);
}
static GstStaticCaps raw_caps =
GST_STATIC_CAPS ("audio/x-raw-int; audio/x-raw-float");
static GstStaticCaps raw_caps = GST_STATIC_CAPS ("audio/x-raw");
static void
gst_auto_audio_sink_init (GstAutoAudioSink * sink)

View file

@ -157,8 +157,7 @@ gst_auto_audio_src_reset (GstAutoAudioSrc * src)
gst_object_unref (targetpad);
}
static GstStaticCaps raw_caps =
GST_STATIC_CAPS ("audio/x-raw-int; audio/x-raw-float");
static GstStaticCaps raw_caps = GST_STATIC_CAPS ("audio/x-raw");
static void
gst_auto_audio_src_init (GstAutoAudioSrc * src)