Fix destructor call in NotePlayHandleManager#3884
Conversation
|
I tested it with the 'football theme' from the original issue, #3223, and it works fine. |
|
|
||
| unlock(); | ||
|
|
||
| this->PlayHandle::~PlayHandle(); |
There was a problem hiding this comment.
It should never be necessary to call destructors explicitly in C++. If PlayHandle's destructor is never called to release the buffer, something else is wrong here - if it is called, this patch will lead to the buffer being freed twice.
There was a problem hiding this comment.
@lukas-w Usually yes, but I think no in this situation. Since NotePlayHandle uses memory allocated by NotePlayHandleManager and its destructor is never called, NotePlayHandle::done() should do what destructor does.
If you really don't like this, you may consider redesigning or removing NotePlayHandleManager.
There was a problem hiding this comment.
There was a problem hiding this comment.
Then it's a bug in NotePlayHandleManager. The destructor should be called in NotePlayHandleManager::release because it's NotePlayHandleManager::acquire where placement-new is used. Also, it looks like NotePlayHandle::done()'s code actually belongs in ~NotePlayHandle.
There was a problem hiding this comment.
Then renaming NotePlayHandle::done() to NotePlayHandle::~NotePlayHandle() and calling it in the NotePlayHandleManager::release would just be fine?
Edit: done by 2d07efd.
There was a problem hiding this comment.
Yep, I think it's fine this way 👍 As far as I can see, done() is only called in NotePlayHandleManager::release() and simply plays the role of a destructor.
|
Now |
|
Side note: |
|
Cool destructor. You can even hear it working... . ;) |
|
@zonkmachine That file stops playing for me after a couple of seconds both with and without this PR merged. Edit: Bisecting shows f23cf4e to be the commit that introduced this, so it's a regression from #3783 |
|
I bisected wrongly. Loosing my favourite game. :( |
|
Don't worry, you'll have enough chances (a.k.a. "bugs") to play this game again. :) |
Fixes buffer noises when instruments don't write the whole buffer, such as bitinvader. Related: * #3884 (comment): #3884 (comment) * #3883 # #3383
|
@zonkmachine I did some debugging and the error seems to be within bitinvader not zeroing the buffer, so I added a line in |
|
It's definitely an improvement. There is no longer a thunderclap coming out of the reverb. I still get a NaN and the noise cuts out though when moving the tempo slider while looping. I ran it with the fpe debug and got the backtrace below. It reminds me of a comment here which also had a problem file with a bitinvader in it. |
|
@zonkmachine It looks like #3775. |
|
Yes, that looks like it. |
|
@zonkmachine So I guess it's not related to this PR or #3783? |
|
Yes, job done here. |
Fix missing destructor call in NotePlayHandle
Fixes buffer noises when instruments don't write the whole buffer, such as bitinvader. Related: * LMMS#3884 (comment): LMMS#3884 (comment) * LMMS#3883 # LMMS#3383
Fixes a regression from #3783 due to missing destructor call. It should have been added in 42e67d2, but not.
Since
BufferManager::releaseBuffer()call is moved in #3783, buffer isn't freed(byMM_FREE()) inNotePlayHandle::done(). It isn't a memory leak becauseMemoryManagerworks as a garbage collector, but decreases usable memory.This PR also makes sure
PlayHandle::m_processingLock's destructor is called.