GNOME Bugzilla – Bug 709408
audioconvert: modifies buffer mapped for READ
Last modified: 2013-10-10 10:32:13 UTC
Created attachment 256443 [details] [review] audioconvert: map memory as readwrite if buffer is writable the input buffer is always mapped as READ, even if the data gets modified. This causes problem when the memory is shared between multiple buffers. (patch might need rebasing, let me know if it does).
looks good in principle. It's interesting, I thought there was a rationale/rule that you couldn't write in the input buffer provided by basetransform when not working in-place... but I couldn't find anything in basetransform's code.
I think it's a bit unexpected that this buffer is modified though. Where does this happen in the audioconvert code? And you only map writable if the buffer is writable, but I assume the data of that buffer is also modified in other situations?
gboolean audio_convert_convert (AudioConvertCtx * ctx, gpointer src, gpointer dst, gint samples, gboolean src_writable) later src is used as tmpbuf if ((insize >= biggest) && src_writable && (ctx->in.bpf >= size)) tmpbuf = src; it looks like just a way to avoid creating temporary buffer. Thinking of it, perhaps src_writable should only be set if buffer is writable and the memory is writable, otherwise it just copies the entire memory instead of creating temporary buffer.
Yes, that sounds sensible
Created attachment 256467 [details] [review] Path to check if buffer and memory is writable
commit 12f85c325db81e36d12bcbb348d4806eb5057458 Author: Matej Knopp <matej.knopp@gmail.com> Date: Fri Oct 4 13:57:51 2013 +0200 audioconvert: Map buffer as READWRITE if the buffer and memory is writable and only use the input buffer as temporary buffer in that case. https://bugzilla.gnome.org/show_bug.cgi?id=709408