Commit b4630dd3 authored by Wim Taymans's avatar Wim Taymans

more memory API porting

parent 583d39dd
......@@ -358,10 +358,13 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstCmmlDec *dec = GST_CMML_DEC (parent);
GstCmmlPacketType packet;
GstMapInfo map;
guint8 *data;
gsize size;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
if (size == 0) {
/* the EOS page could be empty */
......@@ -400,7 +403,7 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
}
done:
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
return dec->flow_return;
......
......@@ -598,23 +598,23 @@ gst_cmml_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GError *err = NULL;
GstCmmlEnc *enc = GST_CMML_ENC (parent);
gchar *data;
gsize size;
GstMapInfo map;
/* the CMML handlers registered with enc->parser will override this when
* encoding/pushing the buffers downstream
*/
enc->flow_return = GST_FLOW_OK;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
if (!gst_cmml_parser_parse_chunk (enc->parser, data, size, &err)) {
if (!gst_cmml_parser_parse_chunk (enc->parser, (gchar *) map.data, map.size,
&err)) {
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
g_error_free (err);
enc->flow_return = GST_FLOW_ERROR;
}
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer);
return enc->flow_return;
}
......
......@@ -536,8 +536,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
guint channels = frame->header.channels;
guint samples = frame->header.blocksize;
guint j, i;
gpointer data;
gsize size;
GstMapInfo map;
gboolean caps_changed;
GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
......@@ -618,9 +617,9 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
if (width == 8) {
gint8 *outbuffer = (gint8 *) data;
gint8 *outbuffer = (gint8 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) {
......@@ -637,7 +636,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
}
}
} else if (width == 16) {
gint16 *outbuffer = (gint16 *) data;
gint16 *outbuffer = (gint16 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) {
......@@ -655,7 +654,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
}
}
} else if (width == 32) {
gint32 *outbuffer = (gint32 *) data;
gint32 *outbuffer = (gint32 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) {
......@@ -675,7 +674,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
} else {
g_assert_not_reached ();
}
gst_buffer_unmap (outbuf, data, size);
gst_buffer_unmap (outbuf, &map);
GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples);
......@@ -743,17 +742,17 @@ gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf)
if (G_UNLIKELY (!dec->got_headers)) {
gboolean got_audio_frame;
gint64 unused;
guint8 *data;
gsize size;
GstMapInfo map;
/* check if this is a flac audio frame (rather than a header or junk) */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
got_audio_frame = gst_flac_dec_scan_got_frame (dec, data, size, &unused);
gst_buffer_unmap (buf, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
got_audio_frame =
gst_flac_dec_scan_got_frame (dec, map.data, map.size, &unused);
gst_buffer_unmap (buf, &map);
if (!got_audio_frame) {
GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " "
"bytes", size);
"bytes", map.size);
gst_audio_decoder_finish_frame (audio_dec, NULL, 1);
return GST_FLOW_OK;
}
......
......@@ -516,8 +516,7 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
#endif
gint i;
guint8 *data;
gsize size;
GstMapInfo map;
for (i = 0; i < n_images + n_preview_images; i++) {
if (i < n_images) {
......@@ -545,10 +544,10 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
image_type = image_type + 2;
#endif
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
data, size, TRUE);
gst_buffer_unmap (buffer, data, size);
map.data, map.size, TRUE);
gst_buffer_unmap (buffer, &map);
#if 0
/* FIXME: There's no way to set the picture type in libFLAC */
......@@ -915,6 +914,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
for (l = enc->headers; l != NULL; l = l->next) {
GstBuffer *buf;
GstMapInfo map;
guint8 *data;
gsize size;
......@@ -925,7 +925,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
buf = GST_BUFFER_CAST (l->data);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
/* find initial 4-byte marker which we need to skip later on */
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
......@@ -936,7 +938,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
vorbiscomment = buf;
}
gst_buffer_unmap (buf, data, size);
gst_buffer_unmap (buf, &map);
}
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
......@@ -951,8 +953,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
{
GstBuffer *buf;
guint16 num;
GstMapInfo map;
guint8 *bdata;
gsize bsize, slen;
gsize slen;
/* minus one for the marker that is merged with streaminfo here */
num = g_list_length (enc->headers) - 1;
......@@ -960,7 +963,8 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
slen = gst_buffer_get_size (streaminfo);
buf = gst_buffer_new_and_alloc (13 + slen);
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_WRITE);
gst_buffer_map (buf, &map, GST_MAP_WRITE);
bdata = map.data;
bdata[0] = 0x7f;
memcpy (bdata + 1, "FLAC", 4);
bdata[5] = 0x01; /* mapping version major */
......@@ -969,7 +973,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
bdata[8] = (num & 0x00FF) >> 0;
memcpy (bdata + 9, "fLaC", 4);
gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unmap (buf, &map);
notgst_value_array_append_buffer (&array, buf);
gst_buffer_unref (buf);
......@@ -1169,12 +1173,11 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
{
GstFlacEnc *flacenc;
FLAC__int32 *data;
gsize bsize;
gint samples, width, channels;
gulong i;
gint j;
FLAC__bool res;
gpointer bdata;
GstMapInfo map;
GstAudioInfo *info =
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
gint *reorder_map;
......@@ -1202,28 +1205,28 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
return flacenc->last_flow;
}
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
samples = bsize / (width >> 3);
gst_buffer_map (buffer, &map, GST_MAP_READ);
samples = map.size / (width >> 3);
data = g_malloc (samples * sizeof (FLAC__int32));
samples /= channels;
if (width == 8) {
gint8 *indata = (gint8 *) bdata;
gint8 *indata = (gint8 *) map.data;
for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++)
data[i * channels + reorder_map[j]] =
(FLAC__int32) indata[i * channels + j];
} else if (width == 16) {
gint16 *indata = (gint16 *) bdata;
gint16 *indata = (gint16 *) map.data;
for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++)
data[i * channels + reorder_map[j]] =
(FLAC__int32) indata[i * channels + j];
} else if (width == 24) {
guint8 *indata = (guint8 *) bdata;
guint8 *indata = (guint8 *) map.data;
guint32 val;
for (i = 0; i < samples; i++)
......@@ -1234,7 +1237,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
data[i * channels + reorder_map[j]] = (FLAC__int32) val;
}
} else if (width == 32) {
gint32 *indata = (gint32 *) bdata;
gint32 *indata = (gint32 *) map.data;
for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++)
......@@ -1243,7 +1246,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
} else {
g_assert_not_reached ();
}
gst_buffer_unmap (buffer, bdata, bsize);
gst_buffer_unmap (buffer, &map);
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
(const FLAC__int32 *) data, samples / channels);
......
......@@ -191,7 +191,7 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlacTag *tag;
GstFlowReturn ret;
guint8 *data;
GstMapInfo map;
gsize size;
ret = GST_FLOW_OK;
......@@ -284,9 +284,9 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
/* clear the is-last flag, as the last metadata block will
* be the vorbis comment block which we will build ourselves.
*/
data = gst_buffer_map (metadata_buffer, &size, NULL, GST_MAP_READWRITE);
data[0] &= (~0x80);
gst_buffer_unmap (metadata_buffer, data, size);
gst_buffer_map (metadata_buffer, &map, GST_MAP_READWRITE);
map.data[0] &= (~0x80);
gst_buffer_unmap (metadata_buffer, &map);
if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
GST_DEBUG_OBJECT (tag, "pushing metadata block buffer");
......@@ -362,11 +362,11 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
if (buffer == NULL)
goto no_buffer;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
memset (data, 0, size);
data[0] = 0x81; /* 0x80 = Last metadata block,
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
memset (map.data, 0, map.size);
map.data[0] = 0x81; /* 0x80 = Last metadata block,
* 0x01 = padding block */
gst_buffer_unmap (buffer, data, size);
gst_buffer_unmap (buffer, &map);
} else {
guchar header[4];
guint8 fbit[1];
......@@ -399,14 +399,14 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
/* The 4 byte metadata block header isn't accounted for in the total
* size of the metadata block
*/
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
data[1] = (((size - 4) & 0xFF0000) >> 16);
data[2] = (((size - 4) & 0x00FF00) >> 8);
data[3] = ((size - 4) & 0x0000FF);
gst_buffer_unmap (buffer, data, size);
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
map.data[1] = (((map.size - 4) & 0xFF0000) >> 16);
map.data[2] = (((map.size - 4) & 0x00FF00) >> 8);
map.data[3] = ((map.size - 4) & 0x0000FF);
gst_buffer_unmap (buffer, &map);
GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment "
"buffer", size);
"buffer", map.size);
ret = gst_pad_push (tag->srcpad, buffer);
if (ret != GST_FLOW_OK) {
......
......@@ -159,10 +159,11 @@ static void
ensure_memory (GstJpegEnc * jpegenc)
{
GstMemory *new_memory;
GstMapInfo map;
gsize old_size, desired_size, new_size;
guint8 *new_data;
old_size = jpegenc->output_size;
old_size = jpegenc->output_map.size;
if (old_size == 0)
desired_size = jpegenc->bufsize;
else
......@@ -171,19 +172,20 @@ ensure_memory (GstJpegEnc * jpegenc)
/* Our output memory wasn't big enough.
* Make a new memory that's twice the size, */
new_memory = gst_allocator_alloc (NULL, desired_size, 3);
new_data = gst_memory_map (new_memory, &new_size, NULL, GST_MAP_READWRITE);
gst_memory_map (new_memory, &map, GST_MAP_READWRITE);
new_data = map.data;
new_size = map.size;
/* copy previous data if any */
if (jpegenc->output_mem) {
memcpy (new_data, jpegenc->output_data, old_size);
gst_memory_unmap (jpegenc->output_mem);
memcpy (new_data, jpegenc->output_map.data, old_size);
gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
gst_memory_unref (jpegenc->output_mem);
}
/* drop it into place, */
jpegenc->output_mem = new_memory;
jpegenc->output_data = new_data;
jpegenc->output_size = new_size;
jpegenc->output_map = map;
/* and last, update libjpeg on where to work. */
jpegenc->jdest.next_output_byte = new_data + old_size;
......@@ -215,12 +217,12 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo)
GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
gst_memory_unmap (jpegenc->output_mem);
gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
/* Trim the buffer size. we will push it in the chain function */
gst_memory_resize (jpegenc->output_mem, 0,
jpegenc->output_size - jpegenc->jdest.free_in_buffer);
jpegenc->output_data = NULL;
jpegenc->output_size = 0;
jpegenc->output_map.size - jpegenc->jdest.free_in_buffer);
jpegenc->output_map.data = NULL;
jpegenc->output_map.size = 0;
}
static void
......@@ -566,12 +568,10 @@ gst_jpegenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
}
jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3);
jpegenc->output_data =
gst_memory_map (jpegenc->output_mem, &jpegenc->output_size, NULL,
GST_MAP_READWRITE);
gst_memory_map (jpegenc->output_mem, &jpegenc->output_map, GST_MAP_READWRITE);
jpegenc->jdest.next_output_byte = jpegenc->output_data;
jpegenc->jdest.free_in_buffer = jpegenc->output_size;
jpegenc->jdest.next_output_byte = jpegenc->output_map.data;
jpegenc->jdest.free_in_buffer = jpegenc->output_map.size;
/* prepare for raw input */
#if JPEG_LIB_VERSION >= 70
......
......@@ -86,8 +86,7 @@ struct _GstJpegEnc
GstFlowReturn last_ret;
GstMemory *output_mem;
gpointer output_data;
gsize output_size;
GstMapInfo output_map;
};
struct _GstJpegEncClass
......
......@@ -1737,8 +1737,7 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
/* FIXME: alloc memory from PA if possible */
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
GstBuffer *out;
guint8 *indata, *outdata;
gsize insize, outsize;
GstMapInfo inmap, outmap;
gboolean res;
if (framesize <= 0)
......@@ -1746,14 +1745,14 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
out = gst_buffer_new_and_alloc (framesize);
indata = gst_buffer_map (buf, &insize, NULL, GST_MAP_READ);
outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE);
gst_buffer_map (buf, &inmap, GST_MAP_READ);
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
res = gst_audio_iec61937_payload (indata, insize,
outdata, outsize, &sink->ringbuffer->spec);
res = gst_audio_iec61937_payload (inmap.data, inmap.size,
outmap.data, outmap.size, &sink->ringbuffer->spec);
gst_buffer_unmap (buf, indata, insize);
gst_buffer_unmap (out, outdata, outsize);
gst_buffer_unmap (buf, &inmap);
gst_buffer_unmap (out, &outmap);
if (!res) {
gst_buffer_unref (out);
......
......@@ -623,30 +623,28 @@ send_message_locked (GstSoupHttpClientSink * souphttpsink)
if (souphttpsink->offset == 0) {
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data;
gpointer data;
gsize size;
GstMapInfo map;
/* FIXME, lifetime of the buffer? */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body,
SOUP_MEMORY_STATIC, data, size);
n += size;
gst_buffer_unmap (buffer, data, size);
SOUP_MEMORY_STATIC, map.data, map.size);
n += map.size;
gst_buffer_unmap (buffer, &map);
}
}
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data;
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
gpointer data;
gsize size;
GstMapInfo map;
/* FIXME, lifetime of the buffer? */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
gst_buffer_map (buffer, &map, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body,
SOUP_MEMORY_STATIC, data, size);
n += size;
gst_buffer_unmap (buffer, data, size);
SOUP_MEMORY_STATIC, map.data, map.size);
n += map.size;
gst_buffer_unmap (buffer, &map);
}
}
......
......@@ -876,7 +876,7 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
typedef struct
{
GstBuffer *buffer;
gpointer data;
GstMapInfo map;
} SoupGstChunk;
static void
......@@ -884,7 +884,7 @@ gst_soup_http_src_chunk_free (gpointer user_data)
{
SoupGstChunk *chunk = (SoupGstChunk *) user_data;
gst_buffer_unmap (chunk->buffer, chunk->data, -1);
gst_buffer_unmap (chunk->buffer, &chunk->map);
gst_buffer_unref (chunk->buffer);
g_slice_free (SoupGstChunk, chunk);
}
......@@ -919,9 +919,9 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
chunk = g_slice_new0 (SoupGstChunk);
chunk->buffer = gstbuf;
chunk->data = gst_buffer_map (gstbuf, &length, NULL, GST_MAP_READWRITE);
gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
soupbuf = soup_buffer_new_with_owner (chunk->data, length,
soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
chunk, gst_soup_http_src_chunk_free);
return soupbuf;
......
......@@ -190,13 +190,12 @@ static GstFlowReturn
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
{
GstCaps *caps;
char *data;
gsize size;
GstMapInfo map;
/* get the header */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
dec->header = speex_packet_to_header (data, size);
gst_buffer_unmap (buf, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
dec->header = speex_packet_to_header ((gchar *) map.data, map.size);
gst_buffer_unmap (buf, &map);
if (!dec->header)
goto no_header;
......@@ -368,23 +367,22 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
GstFlowReturn res = GST_FLOW_OK;
gint i, fpp;
SpeexBits *bits;
gsize size;
char *data;
GstMapInfo map;
if (!dec->frame_duration)
goto not_negotiated;
if (G_LIKELY (gst_buffer_get_size (buf))) {
/* send data to the bitstream */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
speex_bits_read_from (&dec->bits, data, size);
gst_buffer_unmap (buf, data, size);
gst_buffer_map (buf, &map, GST_MAP_READ);
speex_bits_read_from (&dec->bits, (gchar *) map.data, map.size);
gst_buffer_unmap (buf, &map);
fpp = dec->header->frames_per_packet;
bits = &dec->bits;
GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT
", fpp %d, %d bits", size, fpp, speex_bits_remaining (bits));
", fpp %d, %d bits", map.size, fpp, speex_bits_remaining (bits));
} else {
/* FIXME ? actually consider how much concealment is needed */
/* concealment data, pass NULL as the bits parameters */
......@@ -396,7 +394,6 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
/* now decode each frame, catering for unknown number of them (e.g. rtp) */
for (i = 0; i < fpp; i++) {
GstBuffer *outbuf;
gint16 *out_data;
gint ret;
GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp,
......@@ -418,9 +415,8 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
gst_buffer_new_allocate (NULL,
dec->frame_size * dec->header->nb_channels * 2, 0);
out_data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
ret = speex_decode_int (dec->state, bits, out_data);
gst_buffer_unmap (outbuf, out_data, size);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
ret = speex_decode_int (dec->state, bits, (spx_int16_t *) map.data);
if (ret == -1) {
/* uh? end of stream */
......@@ -445,7 +441,10 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
gst_buffer_unref (outbuf);
}
if (dec->header->nb_channels == 2)
speex_decode_stereo_int (out_data, dec->frame_size, dec->stereo);
speex_decode_stereo_int ((spx_int16_t *) map.data, dec->frame_size,
dec->stereo);
gst_buffer_unmap (outbuf, &map);
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
......@@ -469,8 +468,8 @@ not_negotiated:
static gboolean
memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
{
GstMapInfo map;
gsize size1, size2;
gpointer data1;
gboolean res;
size1 = gst_buffer_get_size (buf1);
......@@ -479,9 +478,9 @@ memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
if (size1 != size2)
return FALSE;
data1 = gst_buffer_map (buf1, NULL, NULL, GST_MAP_READ);
res = gst_buffer_memcmp (buf2, 0, data1, size1) == 0;
gst_buffer_unmap (buf1, data1, size1);
gst_buffer_map (buf1, &map, GST_MAP_READ);
res = gst_buffer_memcmp (buf2, 0, map.data, map.size) == 0;
gst_buffer_unmap (buf1, &map);
return res;
}
......
......@@ -539,13 +539,16 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
gint frame_size = enc->frame_size;
gint bytes = frame_size * 2 * enc->channels, samples;
gint outsize, written, dtx_ret = 0;
guint8 *data, *data0 = NULL, *bdata, *outdata;
GstMapInfo map;
guint8 *data, *data0 = NULL, *bdata;
gsize bsize, size;
GstBuffer *outbuf;
GstFlowReturn ret = GST_FLOW_OK;
if (G_LIKELY (buf)) {
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
gst_buffer_map (buf, &map, GST_MAP_READ);
bdata = map.data;
bsize = map.size;
if (G_UNLIKELY (bsize % bytes)) {
GST_DEBUG_OBJECT (enc, "draining; adding silence samples");
......@@ -553,7 +556,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
size = ((bsize / bytes) + 1) * bytes;
data0 = data = g_malloc0 (size);
memcpy (data, bdata, bsize);
gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unmap (buf, &map);
bdata = NULL;
} else {
data = bdata;
......@@ -585,7 +588,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
outsize = speex_bits_nbytes (&enc->bits);
if (bdata)
gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unmap (buf, &map);
#if 0
ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc),
......@@ -596,9 +599,9 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
goto done;
#endif
outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
written = speex_bits_write (&enc->bits, (gchar *) outdata, outsize);
written = speex_bits_write (&enc->bits, (gchar *) map.data, outsize);
if (G_UNLIKELY (written < outsize)) {
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
......@@ -606,7 +609,8 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize);
written = outsize;
}
gst_buffer_unmap (outbuf, outdata, written);
gst_buffer_unmap (outbuf, &map);
gst_buffer_resize (outbuf, 0, written);
if (!dtx_ret)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
......
......@@ -152,12 +152,15 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
{
GstBuffer *buf;
guint32 num_headers;
guint8 *data, *bdata;
GstMapInfo map;
guint8 *data;
gsize size;
guint offset;
gint i, j;
bdata = data = gst_buffer_map (confbuf, &size, NULL, GST_MAP_READ);
gst_buffer_map (confbuf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size);
......@@ -295,7 +298,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
}
gst_buffer_unmap (confbuf, bdata, -1);
gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf);
return TRUE;
......@@ -304,7 +307,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
too_small:
{
GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
gst_buffer_unmap (confbuf, bdata, -1);
gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf);
return FALSE;
}
......@@ -316,23 +319,23 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
guint length)
{
GstBuffer *confbuf;
guint8 *conf;
GstMapInfo map;