Replies: 7 comments
-
there is a global soundStream tucked in an anonymous namespace in ofSoundStream.cpp openFrameworks/libs/openFrameworks/sound/ofSoundStream.cpp Lines 23 to 25 in 72a6ea3 it connects with the pseudo-static so having so in short: remove the maybe the idea of doing that that should not be proposed, and if there are more methods that need access create the desired global ofSoundStream*() so there is a consistant access pattern. |
Beta Was this translation helpful? Give feedback.
-
Yeah this can explain, but I'm not sure why it only allocates the other object once we have declared ofSoundStream soundStream; and at the same time. I've noticed some years ago using ofSoundStream object was preferred over ofSoundStreamSetup. Maybe it it time to deprecate ofSoundStreamSetup ? |
Beta Was this translation helpful? Give feedback.
-
[edit: while correct it it's essence, this post had deficiencies re: c++ terminology; see the next one for more precise information] |
Beta Was this translation helpful? Give feedback.
-
I did a bit more reading to make sure my terminology is good and what happens is this: the anonymous namespace of the ofSoundStream translation unit (.cpp + included .h) contains an ofSoundStream object named but this .o gets linked into the app only if something within is referenced (note: I am not sure this must be referred to as the linking per se, or a more subtle manipulation/inclusion of the symbols within). no matter the correct term/sequence, the if the app references at least 1 symbol of ofSoundStream.o, it gets linked (the whole thing), thus (note: while it's not relevant to this discussion, there are methods to alter this behaviour: the so I guess the discussion should center on:
once understood, I find that the "automatic" instantiating(linking) of |
Beta Was this translation helpful? Give feedback.
-
I've only read a little bit, change definition of namespace{
ofSoundStream systemSoundStream;
} to: namespace{
ofSoundStream &getSystemSoundStream() {
static ofSoundStream systemSoundStream;
return systemSoundStream;
}
} and replace is this not good? |
Beta Was this translation helpful? Give feedback.
-
please check #7301 |
Beta Was this translation helpful? Give feedback.
-
@dimitre can be closed! |
Beta Was this translation helpful? Give feedback.
-
ofSoundStream::ofSoundStream() is being called twice, even if in my example I'm only using one ofSoundStream
This calls this function twice setSoundStream(std::make_shared<OF_SOUND_STREAM_TYPE>());
which creates two different objects in memory
both for iOS and macOS. probably all platforms
it can be tested in a simple example, only creating one ofSoundStream object
To inspect what is being called I've made this alterations
result
Beta Was this translation helpful? Give feedback.
All reactions