Commit a06e9901 authored by George Kiagiadakis's avatar George Kiagiadakis

audioresample: use GstAudioMeta, which enables using non-interleaved buffers

parent fd2e6853
......@@ -548,8 +548,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
GstFlowReturn res;
gint outsize;
gsize out_len;
GstMapInfo map;
gpointer out[1];
GstAudioMapInfo map;
g_assert (resample->converter != NULL);
......@@ -565,13 +564,15 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
outsize = out_len * resample->in.bpf;
outbuf = gst_buffer_new_and_alloc (outsize);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
gst_buffer_add_audio_meta (outbuf, resample->out.finfo->format,
resample->out.layout, resample->out.channels, out_len, NULL);
gst_audio_buffer_map (outbuf, &map, GST_MAP_WRITE);
out[0] = map.data;
gst_audio_converter_samples (resample->converter, 0, NULL, history_len,
out, out_len);
map.planes, out_len);
gst_buffer_unmap (outbuf, &map);
gst_audio_buffer_unmap (outbuf, &map);
/* time */
if (GST_CLOCK_TIME_IS_VALID (resample->t0)) {
......@@ -703,7 +704,7 @@ static GstFlowReturn
gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
GstBuffer * outbuf)
{
GstMapInfo in_map, out_map;
GstAudioMapInfo in_map, out_map;
gsize outsize;
guint32 in_len;
guint32 out_len;
......@@ -711,16 +712,19 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
gst_audio_converter_get_max_latency (resample->converter) * 2;
gboolean inbuf_writable;
in_len = gst_buffer_get_size (inbuf) / resample->in.bpf;
out_len = gst_buffer_get_size (outbuf) / resample->out.bpf;
inbuf_writable = gst_buffer_is_writable (inbuf)
&& gst_buffer_n_memory (inbuf) == 1
&& gst_memory_is_writable (gst_buffer_peek_memory (inbuf, 0));
gst_buffer_map (inbuf, &in_map,
inbuf_writable ? GST_MAP_READWRITE : GST_MAP_READ);
gst_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
gst_buffer_add_audio_meta (outbuf, resample->out.finfo->format,
resample->out.layout, resample->out.channels, out_len, NULL);
in_len = in_map.size / resample->in.bpf;
out_len = out_map.size / resample->out.bpf;
gst_audio_buffer_map (inbuf, &in_map,
inbuf_writable ? GST_MAP_READWRITE : GST_MAP_READ);
gst_audio_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
resample->num_nongap_samples = 0;
......@@ -749,7 +753,7 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
else
out_len = 0;
memset (out_map.data, 0, out_map.size);
memset (out_map.map_info.data, 0, out_map.map_info.size);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
resample->num_gap_samples += in_len;
}
......@@ -771,17 +775,14 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
}
{
/* process */
gpointer in[1], out[1];
GstAudioConverterFlags flags;
flags = 0;
if (inbuf_writable)
flags |= GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE;
in[0] = in_map.data;
out[0] = out_map.data;
gst_audio_converter_samples (resample->converter, flags, in, in_len,
out, out_len);
gst_audio_converter_samples (resample->converter, flags, in_map.planes,
in_len, out_map.planes, out_len);
}
}
......@@ -809,8 +810,8 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
resample->samples_out += out_len;
resample->samples_in += in_len;
gst_buffer_unmap (inbuf, &in_map);
gst_buffer_unmap (outbuf, &out_map);
gst_audio_buffer_unmap (inbuf, &in_map);
gst_audio_buffer_unmap (outbuf, &out_map);
outsize = out_len * resample->in.bpf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment