Don't reload sample from disk when reversing#5701
Conversation
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Windows
Linux
macOS🤖{"platform_name_to_artifacts": {"Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://9390-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-729%2Bgdde5576be-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9390?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://9393-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-729%2Bgdde5576be-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9393?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://9391-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-729%2Bgdde5576-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9391?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "macOS": [{"artifact": {"title": {"title": "", "platform_name": "macOS"}, "link": {"link": "https://9392-15778896-gh.circle-artifacts.com/0/lmms-1.2.3-729%2Bgdde5576be-mac10.13.dmg"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/9392?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}]}, "commit_sha": "eb6b8b3753cd936213ada57cfcb50aee6d7a2f6f"} |
|
Code looks reasonable to me! Do you want any testing on this? Anything specific? |
|
Wait, actually, doesn't this assume that every call to setReversed toggles the state? It appears to me that |
|
Good catch! I was looking at similar code by Reflexe, but didn't quite take in that he changed the function from In terms of testing, I don't think an awful lot is required. Flip some samples back and forth in AFP, make sure they save and load the same way round. |
JohannesLorenz
left a comment
There was a problem hiding this comment.
LGTM
Still not RT safe, but a great performance increase.
|
Did some very quick testing, everything worked as it should. I would probably have wrapped the whole function inside |
If this function is going to be called from multiple threads, the variable should be read and written under the same lock. Suppose two threads tried to reverse the sample simultaneously - both see that it's not reversed, so both reverse it and it ends up unreversed, even though Anyway, this has two approvals now, so I will merge it tomorrow if there are no objections. |
|
Ah, great point. |
Currently, when reversing a sample,
SampleBufferreloads it from disk. This is unnecessary and makes it impossible to do so in realtime code. This change still isn't realtime safe, since it locks a mutex, but a proper fix requires much wider changes, and it doesn't read from the disk any more at least.Blocks #5695.