New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some use-after-frees and memory leak in the wmf decoder #962
Conversation
This causes audio to skip and crackle on my machine. The reason buffers and samples were not a local variable was because the data can get GC'd during playback in some drivers if not stored somewhere, and has to be freed up after it's been played, not before. |
Thanks for the quick report, caught me by surprise; it works fine for me with both DirectSound and XAudio2. |
I updated to the latest with sample being freed last, and it seems to have fixed the crackling for me. (Windows 11, Xaudio2, ogg/mp3 testing) |
Also, the video portion of WMF can probably just be removed in the future as it shouldn't be used anymore. |
Shall we merge this for now, and then strip out the video parts in the |
I don't really know what the status with the wmf decoder's video section is. I could not get it to play any video in the first place. The _debug at pyglet/pyglet/media/codecs/wmf.py Line 576 in 45fc7d1
pyglet/pyglet/media/codecs/wmf.py Lines 590 to 593 in 45fc7d1
[WinError -1072875852] The data specified for the media type is invalid, inconsistent, or not supported by this object for a variety of videos in different formats i've thrown at it.I was focusing this PR on fixing issues in the audio section only; i feel any changes regarding the video part are kinda out of scope for this PR |
I'm still hesitant about tearing out the WMF video decoding. If we can get MP4 to work and establish a baseline for the video stream across Mac & Windows, we'd have a 0-pyglet video equivalent to MP3. That could be a significant decrease in download size. |
The formats are somewhat limited I believe. Video stuff can be removed at a later date.
Unfortunately with WMF it's not hardware accelerated without DirectX and I am not quite up to the task of creating a DirectX-OpenGL link just to make video work for whatever formats it supports when FFmpeg does it all better. We can leave the video stuff for another PR later down the road. |
This says "some" cause the video part is intentionally using a use-after-free to expose the frame.
In any case, the primary reason for this PR is to fix the jumping leak from #926 stemming from the
_source_reader
not being released, now that the other one turned out to be a Python bug.