Commit 12ee4182 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

port some more to new memory API

Fixes #668677.
parent 7aead776
......@@ -826,8 +826,7 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *value;
GstBuffer *priv;
gchar *codec_private;
gsize codec_private_size;
GstMapInfo map;
gboolean ret = FALSE;
structure = gst_caps_get_structure (caps, 0);
......@@ -842,16 +841,14 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps)
priv = gst_value_get_buffer (value);
g_return_val_if_fail (priv != NULL, FALSE);
codec_private =
gst_buffer_map (priv, &codec_private_size, NULL, GST_MAP_READ);
gst_buffer_map (priv, &map, GST_MAP_READ);
if (!render->ass_track)
render->ass_track = ass_new_track (render->ass_library);
ass_process_codec_private (render->ass_track,
codec_private, codec_private_size);
ass_process_codec_private (render->ass_track, (char *) map.data, map.size);
gst_buffer_unmap (priv, codec_private, codec_private_size);
gst_buffer_unmap (priv, &map);
GST_DEBUG_OBJECT (render, "ass track created");
......@@ -877,8 +874,7 @@ static void
gst_ass_render_process_text (GstAssRender * render, GstBuffer * buffer,
GstClockTime running_time, GstClockTime duration)
{
gchar *data;
gsize size;
GstMapInfo map;
gdouble pts_start, pts_end;
pts_start = running_time;
......@@ -891,13 +887,14 @@ gst_ass_render_process_text (GstAssRender * render, GstBuffer * buffer,
" and duration %" GST_TIME_FORMAT, GST_TIME_ARGS (running_time),
GST_TIME_ARGS (duration));
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
g_mutex_lock (&render->ass_mutex);
ass_process_chunk (render->ass_track, data, size, pts_start, pts_end);
ass_process_chunk (render->ass_track, (gchar *) map.data, map.size,
pts_start, pts_end);
g_mutex_unlock (&render->ass_mutex);
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
}
......
......@@ -488,6 +488,7 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
gboolean need_renegotiation = FALSE;
guint8 *data;
gsize size;
GstMapInfo map;
gint chans;
gint length = 0, flags, sample_rate, bit_rate, frame_length;
GstFlowReturn result = GST_FLOW_OK;
......@@ -500,7 +501,9 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
return GST_FLOW_OK;
/* parsed stuff already, so this should work out fine */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
g_assert (size >= 7);
bit_rate = dts->bit_rate;
......@@ -585,12 +588,12 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
flags |= DCA_ADJUST_LEVEL;
dts->level = 1;
if (dca_frame (dts->state, data, &flags, &dts->level, dts->bias)) {
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
GST_AUDIO_DECODER_ERROR (dts, 1, STREAM, DECODE, (NULL),
("dts_frame error"), result);
goto exit;
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
channels = flags & (DCA_CHANNEL_MASK | DCA_LFE);
if (dts->using_channels != channels) {
......@@ -621,7 +624,9 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
outbuf =
gst_buffer_new_and_alloc (256 * chans * (SAMPLE_WIDTH / 8) * num_blocks);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
data = map.data;
size = map.size;
{
guint8 *ptr = data;
for (i = 0; i < num_blocks; i++) {
......@@ -645,7 +650,7 @@ gst_dtsdec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buffer)
ptr += 256 * chans * (SAMPLE_WIDTH / 8);
}
}
gst_buffer_unmap (outbuf, data, size);
gst_buffer_unmap (outbuf, &map);
result = gst_audio_decoder_finish_frame (bdec, outbuf, 1);
......
......@@ -644,14 +644,13 @@ gst_faac_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *out_buf;
gsize size, ret_size;
GstMapInfo map, omap;
guint8 *data;
guint8 *out_data;
gsize out_size;
GstAudioInfo *info =
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (faac));
out_buf = gst_buffer_new_and_alloc (faac->bytes);
out_data = gst_buffer_map (out_buf, &out_size, NULL, GST_MAP_WRITE);
gst_buffer_map (out_buf, &omap, GST_MAP_WRITE);
if (G_LIKELY (in_buf)) {
if (memcmp (info->position, aac_channel_positions[info->channels - 1],
......@@ -661,26 +660,29 @@ gst_faac_handle_frame (GstAudioEncoder * enc, GstBuffer * in_buf)
info->channels, info->position,
aac_channel_positions[info->channels - 1]);
}
data = gst_buffer_map (in_buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (in_buf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
} else {
data = NULL;
size = 0;
}
if (G_UNLIKELY ((ret_size = faacEncEncode (faac->handle, (gint32 *) data,
size / (info->finfo->width / 8), out_data, out_size)) < 0))
size / (info->finfo->width / 8), omap.data, omap.size)) < 0))
goto encode_failed;
if (in_buf)
gst_buffer_unmap (in_buf, data, -1);
gst_buffer_unmap (in_buf, &map);
GST_LOG_OBJECT (faac, "encoder return: %" G_GSIZE_FORMAT, ret_size);
if (ret_size > 0) {
gst_buffer_unmap (out_buf, out_data, ret_size);
gst_buffer_unmap (out_buf, &omap);
gst_buffer_resize (out_buf, 0, ret_size);
ret = gst_audio_encoder_finish_frame (enc, out_buf, faac->samples);
} else {
gst_buffer_unmap (out_buf, out_data, 0);
gst_buffer_unmap (out_buf, &omap);
gst_buffer_unref (out_buf);
/* re-create encoder after final flush */
if (!in_buf) {
......@@ -698,8 +700,8 @@ encode_failed:
{
GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
if (in_buf)
gst_buffer_unmap (in_buf, data, -1);
gst_buffer_unmap (out_buf, out_data, 0);
gst_buffer_unmap (in_buf, &map);
gst_buffer_unmap (out_buf, &omap);
gst_buffer_unref (out_buf);
return GST_FLOW_ERROR;
}
......
......@@ -262,6 +262,7 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
GstStructure *str = gst_caps_get_structure (caps, 0);
GstBuffer *buf;
const GValue *value;
GstMapInfo map;
guint8 *cdata;
gsize csize;
......@@ -285,7 +286,9 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
buf = gst_value_get_buffer (value);
g_return_val_if_fail (buf != NULL, FALSE);
cdata = gst_buffer_map (buf, &csize, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
cdata = map.data;
csize = map.size;
if (csize < 2)
goto wrong_length;
......@@ -319,6 +322,7 @@ gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
faad->channels = 0;
faad->init = TRUE;
gst_buffer_unmap (buf, &map);
} else if ((value = gst_structure_get_value (str, "framed")) &&
g_value_get_boolean (value) == TRUE) {
faad->packetised = TRUE;
......@@ -356,21 +360,21 @@ wrong_length:
{
GST_DEBUG_OBJECT (faad, "codec_data less than 2 bytes long");
gst_object_unref (faad);
gst_buffer_unmap (buf, cdata, csize);
gst_buffer_unmap (buf, &map);
return FALSE;
}
open_failed:
{
GST_DEBUG_OBJECT (faad, "failed to create decoder");
gst_object_unref (faad);
gst_buffer_unmap (buf, cdata, csize);
gst_buffer_unmap (buf, &map);
return FALSE;
}
init_failed:
{
GST_DEBUG_OBJECT (faad, "faacDecInit2() failed");
gst_object_unref (faad);
gst_buffer_unmap (buf, cdata, csize);
gst_buffer_unmap (buf, &map);
return FALSE;
}
}
......@@ -662,6 +666,7 @@ gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
{
GstFaad *faad;
GstFlowReturn ret = GST_FLOW_OK;
GstMapInfo map;
gsize input_size;
guchar *input_data;
GstBuffer *outbuf;
......@@ -674,7 +679,9 @@ gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
if (G_UNLIKELY (!buffer))
return GST_FLOW_OK;
input_data = gst_buffer_map (buffer, &input_size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
input_data = map.data;
input_size = map.size;
init:
/* init if not already done during capsnego */
......@@ -763,7 +770,7 @@ init:
} while (FALSE);
out:
gst_buffer_unmap (buffer, input_data, input_size);
gst_buffer_unmap (buffer, &map);
return ret;
......
......@@ -444,6 +444,7 @@ gst_flite_test_src_create (GstBaseSrc * basesrc, guint64 offset,
GstBuffer *buf;
char *text;
int i;
GstMapInfo map;
gint16 *data;
cst_wave *wave;
gsize size;
......@@ -460,12 +461,13 @@ gst_flite_test_src_create (GstBaseSrc * basesrc, guint64 offset,
size = src->info.channels * sizeof (gint16) * wave->num_samples;
buf = gst_buffer_new_and_alloc (size);
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (buf, &map, GST_MAP_WRITE);
data = (gint16 *) map.data;
memset (data, 0, size);
for (i = 0; i < wave->num_samples; i++) {
data[i * src->info.channels + src->channel] = wave->samples[i];
}
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
src->channel++;
if (src->channel == src->info.channels) {
......
......@@ -353,14 +353,14 @@ gst_gme_play (GstPad * pad)
const int NUM_SAMPLES = 1600; /* 4 bytes (stereo 16-bit) per sample */
if (!seeking) {
short *data;
GstMapInfo map;
out = gst_buffer_new_and_alloc (NUM_SAMPLES * 4);
GST_BUFFER_TIMESTAMP (out) = gme_tell (gme->player) * GST_MSECOND;
data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
gme_err = gme_play (gme->player, NUM_SAMPLES * 2, data);
gst_buffer_unmap (out, data, -1);
gst_buffer_map (out, &map, GST_MAP_WRITE);
gme_err = gme_play (gme->player, NUM_SAMPLES * 2, (short *) map.data);
gst_buffer_unmap (out, &map);
if (gme_err) {
GST_ELEMENT_ERROR (gme, STREAM, DEMUX, (NULL), (gme_err));
......@@ -412,8 +412,7 @@ gme_setup (GstGmeDec * gme)
guint64 fade_time;
GstBuffer *buffer;
GstSegment seg;
guint8 *data;
gsize size;
GstMapInfo map;
if (!gst_adapter_available (gme->adapter) || !gme_negotiate (gme)) {
return FALSE;
......@@ -423,9 +422,9 @@ gme_setup (GstGmeDec * gme)
gst_adapter_take_buffer (gme->adapter,
gst_adapter_available (gme->adapter));
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gme_err = gme_open_data (data, size, &gme->player, 32000);
gst_buffer_unmap (buffer, data, size);
gst_buffer_map (buffer, &map, GST_MAP_READ);
gme_err = gme_open_data (map.data, map.size, &gme->player, 32000);
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
if (gme_err || !gme->player) {
......
......@@ -101,12 +101,9 @@ void
GstMplexOutputStream::Write (guint8 * data, guint len)
{
GstBuffer *buf;
gpointer bdata;
buf = gst_buffer_new_and_alloc (len);
bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
memcpy (bdata, data, len);
gst_buffer_unmap (buf, bdata, -1);
gst_buffer_fill (buf, 0, data, len);
size += len;
GST_MPLEX_MUTEX_LOCK (mplex);
......
......@@ -205,8 +205,7 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstRTMPSink *sink = GST_RTMP_SINK (bsink);
GstBuffer *reffed_buf = NULL;
guint8 *data;
gsize size;
GstMapInfo map;
if (sink->first) {
/* open the connection */
......@@ -244,12 +243,12 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
GST_LOG_OBJECT (sink, "Sending %" G_GSIZE_FORMAT " bytes to RTMP server",
gst_buffer_get_size (buf));
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
if (!RTMP_Write (sink->rtmp, (char *) data, size))
if (!RTMP_Write (sink->rtmp, (char *) map.data, map.size))
goto write_failed;
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
if (reffed_buf)
gst_buffer_unref (reffed_buf);
......@@ -259,7 +258,7 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
write_failed:
{
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL), ("Failed to write data"));
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
if (reffed_buf)
gst_buffer_unref (reffed_buf);
return GST_FLOW_ERROR;
......
......@@ -294,7 +294,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
{
GstRTMPSrc *src;
GstBuffer *buf;
guint8 *data, *bdata;
GstMapInfo map;
guint8 *data;
guint todo;
gsize bsize;
int read;
......@@ -316,7 +317,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
}
bsize = todo = size;
bdata = data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (buf, &map, GST_MAP_WRITE);
data = map.data;
read = bsize = 0;
while (todo > 0) {
......@@ -342,7 +344,8 @@ gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
}
GST_LOG (" got size %d", read);
}
gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, bsize);
if (src->discont) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
......
......@@ -361,14 +361,14 @@ gst_voaacenc_create_source_pad_caps (GstVoAacEnc * voaacenc)
GstCaps *caps = NULL;
gint index;
GstBuffer *codec_data;
guint8 *data;
GstMapInfo map;
if ((index = gst_voaacenc_get_rate_index (voaacenc->rate)) >= 0) {
codec_data = gst_buffer_new_and_alloc (VOAAC_ENC_CODECDATA_LEN);
data = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (codec_data, &map, GST_MAP_WRITE);
/* LC profile only */
data[0] = ((0x02 << 3) | (index >> 1));
data[1] = ((index & 0x01) << 7) | (voaacenc->channels << 3);
map.data[0] = ((0x02 << 3) | (index >> 1));
map.data[1] = ((index & 0x01) << 7) | (voaacenc->channels << 3);
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, VOAAC_ENC_MPEGVERSION,
......@@ -378,9 +378,9 @@ gst_voaacenc_create_source_pad_caps (GstVoAacEnc * voaacenc)
(voaacenc->output_format ? "adts" : "raw")
, NULL);
gst_codec_utils_aac_caps_set_level_and_profile (caps, data,
gst_codec_utils_aac_caps_set_level_and_profile (caps, map.data,
VOAAC_ENC_CODECDATA_LEN);
gst_buffer_unmap (codec_data, data, -1);
gst_buffer_unmap (codec_data, &map);
if (!voaacenc->output_format) {
gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, codec_data,
......@@ -436,8 +436,7 @@ gst_voaacenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
VO_AUDIO_OUTPUTINFO output_info = { {0} };
VO_CODECBUFFER input = { 0 };
VO_CODECBUFFER output = { 0 };
gsize size;
guint8 *data, *out_data;
GstMapInfo map, omap;
GstAudioInfo *info = gst_audio_encoder_get_audio_info (benc);
voaacenc = GST_VOAACENC (benc);
......@@ -458,39 +457,40 @@ gst_voaacenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf)
aac_channel_positions[info->channels - 1]);
}
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
if (G_UNLIKELY (size < voaacenc->inbuf_size)) {
gst_buffer_unmap (buf, data, -1);
GST_DEBUG_OBJECT (voaacenc, "discarding trailing data %d", (gint) size);
if (G_UNLIKELY (map.size < voaacenc->inbuf_size)) {
gst_buffer_unmap (buf, &map);
GST_DEBUG_OBJECT (voaacenc, "discarding trailing data %d", (gint) map.size);
ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
goto exit;
}
/* max size */
out = gst_buffer_new_and_alloc (voaacenc->inbuf_size);
out_data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (out, &omap, GST_MAP_WRITE);
output.Buffer = out_data;
output.Buffer = omap.data;
output.Length = voaacenc->inbuf_size;
g_assert (size == voaacenc->inbuf_size);
input.Buffer = data;
g_assert (map.size == voaacenc->inbuf_size);
input.Buffer = map.data;
input.Length = voaacenc->inbuf_size;
voaacenc->codec_api.SetInputData (voaacenc->handle, &input);
/* encode */
if (voaacenc->codec_api.GetOutputData (voaacenc->handle, &output,
&output_info) != VO_ERR_NONE) {
gst_buffer_unmap (buf, data, -1);
gst_buffer_unmap (out, out_data, -1);
gst_buffer_unmap (buf, &map);
gst_buffer_unmap (out, &omap);
gst_buffer_unref (out);
goto encode_failed;
}
GST_LOG_OBJECT (voaacenc, "encoded to %d bytes", output.Length);
gst_buffer_unmap (out, out_data, output.Length);
gst_buffer_unmap (buf, data, -1);
gst_buffer_unmap (buf, &map);
gst_buffer_unmap (out, &omap);
gst_buffer_resize (out, 0, output.Length);
ret = gst_audio_encoder_finish_frame (benc, out, 1024);
......
......@@ -268,8 +268,7 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
const int buffer_size = sizeof (short) * L_FRAME16k;
GstBuffer *out;
gint outsize;
gsize size;
guint8 *data, *outdata;
GstMapInfo map, omap;
amrwbenc = GST_VOAMRWBENC (benc);
......@@ -281,24 +280,25 @@ gst_voamrwbenc_handle_frame (GstAudioEncoder * benc, GstBuffer * buffer)
goto done;
}
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
if (G_UNLIKELY (size < buffer_size)) {
GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d", (gint) size);
gst_buffer_unmap (buffer, data, -1);
if (G_UNLIKELY (map.size < buffer_size)) {
GST_DEBUG_OBJECT (amrwbenc, "discarding trailing data %d", (gint) map.size);
gst_buffer_unmap (buffer, &map);
ret = gst_audio_encoder_finish_frame (benc, NULL, -1);
goto done;
}
out = gst_buffer_new_and_alloc (buffer_size);
outdata = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (out, &omap, GST_MAP_WRITE);
/* encode */
outsize = E_IF_encode (amrwbenc->handle, amrwbenc->bandmode,
(const short *) data, (unsigned char *) outdata, 0);
(const short *) map.data, (unsigned char *) omap.data, 0);
GST_LOG_OBJECT (amrwbenc, "encoded to %d bytes", outsize);
gst_buffer_unmap (out, outdata, outsize);
gst_buffer_unmap (buffer, data, -1);
gst_buffer_unmap (out, &omap);
gst_buffer_unmap (buffer, &map);
gst_buffer_resize (out, 0, outsize);
ret = gst_audio_encoder_finish_frame (benc, out, L_FRAME16k);
......
......@@ -366,8 +366,7 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
vpx_image_t *img;
long decoder_deadline = 0;
GstClockTimeDiff deadline;
gsize size;
gpointer data;
GstMapInfo map;
GST_DEBUG_OBJECT (decoder, "handle_frame");
......@@ -383,13 +382,13 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
memset (&stream_info, 0, sizeof (stream_info));
stream_info.sz = sizeof (stream_info);
data = gst_buffer_map (frame->sink_buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (frame->sink_buffer, &map, GST_MAP_READ);
status =
vpx_codec_peek_stream_info (&vpx_codec_vp8_dx_algo, data, size,
vpx_codec_peek_stream_info (&vpx_codec_vp8_dx_algo, map.data, map.size,
&stream_info);
gst_buffer_unmap (frame->sink_buffer, data, size);
gst_buffer_unmap (frame->sink_buffer, &map);
if (status != VPX_CODEC_OK || !stream_info.is_kf) {
GST_WARNING_OBJECT (decoder, "No keyframe, skipping");
......@@ -456,11 +455,13 @@ gst_vp8_dec_handle_frame (GstBaseVideoDecoder * decoder,
decoder_deadline = MAX (1, deadline / GST_MSECOND);
}
data = gst_buffer_map (frame->sink_buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (frame->sink_buffer, &map, GST_MAP_READ);
status = vpx_codec_decode (&dec->decoder, data, size, NULL, decoder_deadline);
status =
vpx_codec_decode (&dec->decoder, map.data, map.size, NULL,
decoder_deadline);
gst_buffer_unmap (frame->sink_buffer, data, size);
gst_buffer_unmap (frame->sink_buffer, &map);
if (status) {
GST_ELEMENT_ERROR (decoder, LIBRARY, ENCODE,
......
......@@ -854,7 +854,7 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
const GstTagList *iface_tags;
GValue array = { 0, };
GValue value = { 0, };
gsize size;
GstMapInfo map;
s = gst_caps_get_structure (caps, 0);
/* put buffers in a fixed list */
......@@ -863,7 +863,8 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
/* Create Ogg stream-info */
stream_hdr = gst_buffer_new_and_alloc (26);
data = gst_buffer_map (stream_hdr, &size, NULL, GST_MAP_WRITE);
gst_buffer_map (stream_hdr, &map, GST_MAP_WRITE);
data = map.data;
GST_WRITE_UINT8 (data, 0x4F);
GST_WRITE_UINT32_BE (data + 1, 0x56503830); /* "VP80" */
......@@ -877,7 +878,7 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder,
GST_WRITE_UINT32_BE (data + 18, info->fps_n);
GST_WRITE_UINT32_BE (data + 22, info->fps_d);
gst_buffer_unmap (stream_hdr, data, size);
gst_buffer_unmap (stream_hdr, &map);
GST_BUFFER_FLAG_SET (stream_hdr, GST_BUFFER_FLAG_IN_CAPS);
gst_value_set_buffer (&value, stream_hdr);
......
......@@ -901,14 +901,14 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
gint ret_val = 0;
GstBuffer *buf = gst_buffer_new_and_alloc (size);
GstClockTime timeout = object->timeout * GST_USECOND;
guint8 *data;
GstMapInfo map;
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
if (object->fd_dvr < 0)
return NULL;
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (buf, &map, GST_MAP_WRITE);
while (count < size) {
ret_val = gst_poll_wait (object->poll, timeout);
GST_LOG_OBJECT (object, "select returned %d", ret_val);
......@@ -923,7 +923,7 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
gst_message_new_element (GST_OBJECT (object),
gst_structure_new_empty ("dvb-read-failure")));
} else {
int nread = read (object->fd_dvr, data + count, size - count);
int nread = read (object->fd_dvr, map.data + count, size - count);
if (G_UNLIKELY (nread < 0)) {
GST_WARNING_OBJECT
......@@ -937,20 +937,21 @@ gst_dvbsrc_read_device (GstDvbSrc * object, int size)
count = count + nread;
}
}
gst_buffer_unmap (buf, data, count);
gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, count);
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
return buf;
stopped:
GST_DEBUG_OBJECT (object, "stop called");
gst_buffer_unmap (buf, data, 0);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
return NULL;
select_error:
GST_ELEMENT_ERROR (object, RESOURCE, READ, (NULL),
("select error %d: %s (%d)", ret_val, g_strerror (errno), errno));
gst_buffer_unmap (buf, data, 0);
gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
return NULL;
}
......
......@@ -58,14 +58,14 @@ buffer_new (const unsigned char *buffer_data, guint size)
gst_buffer_fill (buffer, 0, buffer_data, size);
} else {
guint i;
guint8 *data;
GstMapInfo map;
/* Create a recognizable pattern (loop 0x00 -> 0xff) in the data block */
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
for (i = 0; i < size; i++) {
data[i] = i % 0x100;
map.data[i] = i % 0x100;
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
}
GST_BUFFER_OFFSET (buffer) = dataoffset;
......
......@@ -218,8 +218,6 @@ handle_element_message (GstMessage * msg)
const GstStructure *st;
const GValue *image;
GstBuffer *buf = NULL;
guint8 *data = NULL;
gsize size = 0;
gchar *filename = NULL;
FILE *f = NULL;
size_t written;
......@@ -243,9 +241,11 @@ handle_element_message (GstMessage * msg)
g_print ("writing buffer to %s\n", filename);
f = g_fopen (filename, "w");
if (f) {
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
written = fwrite (data, size, 1, f);
gst_buffer_unmap (buf, data, size);
GstMapInfo map;
gst_buffer_map (buf, &map, GST_MAP_READ);
written = fwrite (map.data, map.size, 1, f);
gst_buffer_unmap (buf, &map);
if (!written) {
g_print ("errro writing file\n");
}
......
......@@ -239,8 +239,6 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
const GstStructure *st;
const GValue *image;
GstBuffer *buf = NULL;
guint8 *data_buf = NULL;
gsize size = 0;
gchar *preview_filename = NULL;
FILE *f = NULL;
size_t written;
......@@ -264,14 +262,16 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
//extract preview-image from msg
image = gst_structure_get_value (st, "buffer");
if (image) {
GstMapInfo map;