Skip to content

Commit 69af556

Browse files
authored
don't initialize until needed (#7301)
#fchangelog #sound
1 parent 46f36d3 commit 69af556

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libs/openFrameworks/sound/ofSoundStream.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#endif
2222

2323
namespace{
24-
ofSoundStream systemSoundStream;
24+
ofSoundStream &getSystemSoundStream() {
25+
static ofSoundStream _;
26+
return _;
27+
}
2528
}
2629

2730
using std::shared_ptr;
@@ -118,27 +121,27 @@ void ofSoundStreamSetup(int nOutputChannels, int nInputChannels, ofBaseApp * app
118121

119122
//------------------------------------------------------------
120123
void ofSoundStreamSetup(ofSoundStreamSettings & settings) {
121-
systemSoundStream.setup(settings);
124+
getSystemSoundStream().setup(settings);
122125
}
123126

124127
//------------------------------------------------------------
125128
void ofSoundStreamStop(){
126-
systemSoundStream.stop();
129+
getSystemSoundStream().stop();
127130
}
128131

129132
//------------------------------------------------------------
130133
void ofSoundStreamStart(){
131-
systemSoundStream.start();
134+
getSystemSoundStream().start();
132135
}
133136

134137
//------------------------------------------------------------
135138
void ofSoundStreamClose(){
136-
systemSoundStream.close();
139+
getSystemSoundStream().close();
137140
}
138141

139142
//------------------------------------------------------------
140143
vector<ofSoundDevice> ofSoundStreamListDevices(){
141-
vector<ofSoundDevice> deviceList = systemSoundStream.getDeviceList();
144+
vector<ofSoundDevice> deviceList = getSystemSoundStream().getDeviceList();
142145
ofLogNotice("ofSoundStreamListDevices") << std::endl << deviceList;
143146
return deviceList;
144147
}

0 commit comments

Comments
 (0)