Skip to content

Commit f0bbb50

Browse files
committed
gstdec: Update in line with GStreamer 1.18 API break
This fixes an issue seen when calculating fingerprints with GStreamer 1.18: ... File "/usr/lib/python3.9/site-packages/acoustid.py", line 333, in fingerprint_file return _fingerprint_file_audioread(path, maxlength) File "/usr/lib/python3.9/site-packages/acoustid.py", line 275, in _fingerprint_file_audioread fp = fingerprint(f.samplerate, f.channels, iter(f), maxlength) File "/usr/lib/python3.9/site-packages/acoustid.py", line 217, in fingerprint fper.feed(block) File "/usr/lib/python3.9/site-packages/chromaprint.py", line 145, in feed data = BYTES_TYPE(data) ValueError: operation forbidden on released memoryview object This occurs due to an API break in the Python bindings. The `Gst.Memory.map()` previously returned a copy of the audio data, but it now returns a `memoryview()` instance pointing directly to the memory. Since this is only valid while the Gst.Memory is mapped, we need to manually copy it into a bytes() object. The relevant GStreamer change is: https://gitlab.freedesktop.org/gstreamer/gst-python/-/commit/fecfe451a7566740960d87da8a177f8a776f6137
1 parent a4d29ab commit f0bbb50

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

audioread/gstdec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,14 @@ def _new_sample(self, sink):
321321
mem = buf.get_all_memory()
322322
success, info = mem.map(Gst.MapFlags.READ)
323323
if success:
324-
data = info.data
324+
if isinstance(info.data, memoryview):
325+
# We need to copy the data as the memoryview is released
326+
# when we call mem.unmap()
327+
data = bytes(info.data)
328+
else:
329+
# GStreamer Python bindings <= 1.16 return a copy of the
330+
# data as bytes()
331+
data = info.data
325332
mem.unmap(info)
326333
self.queue.put(data)
327334
else:

0 commit comments

Comments
 (0)