-
-
Notifications
You must be signed in to change notification settings - Fork 253
Modify memory management of AudioIO and Effects subsystems #430
base: master
Are you sure you want to change the base?
Conversation
Fails to build on Windows with MSVC:
master 5c8f61a builds fine. Replacing this line with |
That is a bug which is already addressed in master, I just needed to pull changes and merge. |
Your commits are difficult to review due to mixing functional changes with style changes. |
Agreed. This needs to be rebased into at least three separate commits, for cache-friendliness, memory leak fixes, and stylistic changes. |
I've done quite a bit of testing and ran a memory analysis both with and without using realtime effects. No new memory leaks and no other issues that I can find. |
Maybe beyond the scope of this PR, but why are C arrays being used all over C++ code?? |
Instead of what? |
C++ classes with ergonomic zero cost abstractions |
I don't get your fancy words. Name a standard C++ class that you mean. This, maybe? But it's only for use with an array bound known at compile time. https://en.cppreference.com/w/cpp/container/array |
No, write your own, or use a library with utility classes for working with audio buffers, or maybe copy code from Mixxx. |
Can you point to some code you would rewrite? |
Every use of a C array in C++ code (except where interfacing with a C library) |
There is much in a 20 year old accumulation of code dating from only shortly after the 1998 C++ standard, that could be made nicer and more modern, using types and templates and the newer standard library more smartly. See TranslatableString for instance, added in many many places, with the advantage that it stops careless neglect of internationalization of new literals with compilation failures. I know the guy who did that. He also made a comprehensive cleanup of naked news and deletes in favor of smart pointers, so he knows a thing about allocations too. But even that guy has limited time available to fix every primitive C idiom that the early developers hadn't unlearned. The transformations I named brought a real advantage in maintainability. What advantage would your rewrites bring? |
Regarding the commit messages, you need to use put brackets ( |
...? they are already there, GitHub converts emails sometimes to w/o brackets but as a link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's difficult to find the functional changes here mixed in with the formatting changes. I cannot in good conscious approve merging this without a clear view of what is actually changing. The little bit I did notice is very concerning as it introduces more time unbounded behavior in the audio thread.
I think we should revert #412, step back, and reconsider priorities here. There are tons of problems to fix in this codebase, but before we start on that journey (which I anticipate will take many years), I think we should focus on getting a first release out. For that we need to clean up the build system (#228) and complete rebranding. Then let's dig into the C++ and start refactoring.
src/AudioIO.cpp
Outdated
@@ -3979,6 +3979,7 @@ bool AudioIoCallback::FillOutputBuffers( | |||
// wxASSERT( maxLen == toGet ); | |||
|
|||
em.RealtimeProcessEnd(); | |||
delete bufHelper.release(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to my world. You will need patience, persistence! |
I am very familiar with the world of cleaning up horrible technical decisions made long ago. |
We may be attuned to different horriblenesses. I have worked for years on several that may be disjoint from your concerns. Using RAII better, using types better, and, ongoing, fixing problems in the compilation and linkage dependency graph that make the program too monolithic. |
cbf8a24
to
0572d94
Compare
#ifndef REALTIME_EFFECT_BUFFER_HELPER_H | ||
#define REALTIME_EFFECT_BUFFER_HELPER_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use #pragma once
in new files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should 100% not use #pragma once
standalone. We can add it in addition, if you want, since that may speed up compilation in some situations. But I actually already looked into this exact issue probably 4 days ago and came to the conclusion using a #pragma
here isn't the best idea.
this->chans = chans; | ||
this->numSamples = numSamples; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to an initializer list
float** obuf; | ||
float* temp; | ||
|
||
RealtimeEffectBufferHelper(float** buffers, const unsigned int chans, const size_t numSamples) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this number of samples or number of frames?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious what the difference between the buffers
parameter passed into this constructor is and the variables initialized within it. If I had a documentation comment explaining what the purpose of the class was that might be more apparent, but as it is I have to thoroughly read the entire implementation of the class to understand this.
this->chans = chans; | ||
this->numSamples = numSamples; | ||
|
||
// Allocate the in/out buffer arrays |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffers are arrays, so is this just a buffer or an array of buffers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be much clearer if there was a C++ class for buffers rather than writing C inside C++
public: | ||
|
||
// Allocate the in/out buffer arrays | ||
float** ibuf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float** inputBuffer;
spell out variables please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is this inputBuffers, plural?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm copying the original naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't adequately review this without a ton of effort with whitespace changes intermixed with functional changes. Is your editor doing this automatically? If so, please reconfigure it to stop doing so.
0572d94
to
021a96a
Compare
Improves performance of project loading substantively. Signed-off-by: Emily Mabrey <[email protected]> Helped-by: Alex Disibio <[email protected]>
Signed-off-by: Emily Mabrey <[email protected]>
Signed-off-by: Emily Mabrey <[email protected]>
021a96a
to
d4a560f
Compare
Signed-off-by: Emily Mabrey <[email protected]>
ad2a4c9
to
d7695f3
Compare
Signed-off-by: Emily Mabrey <[email protected]>
fa53530
to
68daa33
Compare
I have nothing to do with this PR, but I want to support doubts about the advisability of replacing C-type arrays with something more unwieldy unnecessarily. |
Modify memory usage of audio playback and effects preview features to eliminate leaks and use heap memory.
Signed-off-by: Emily Mabrey [email protected]
Helped-by: Alex Disibio [email protected]
Helped-by: Rikard Jansson [email protected]
This is a remake of the previous PR because the previous one wasn't broad enough to cover all the changes within the scope of this one.
Checklist
-s
orSigned-off-by
* (See: Contributing § DCO)* indicates required