Openframeworks: ofSoundPlayer crashes(Segmentation fault: 11) about once in 10times

Created on 12 Mar 2021  Â·  7Comments  Â·  Source: openframeworks/openFrameworks

â– environment
â– mac
Macbook pro(16-inch, 2019)

â– OS
Big Sur(11.2.3)

â– oF
v0.11.1

â– XCode
12.4

â– source
void ofApp::setup(){
/*****
*****/
ofSetBackgroundAuto(true);
pp
ofSetWindowTitle("test_sound");
ofSetVerticalSync(true);
ofSetFrameRate(30);
ofSetWindowShape(300, 300);
ofSetEscapeQuitsApp(false);

/********************
********************/
string FileName = "sound.mp3";

Sounds.load(FileName);
Sounds.setLoop(false);
Sounds.setMultiPlay(true);
Sounds.setVolume(1.0);

}

void ofApp::draw(){
ofBackground(50);
}

void ofApp::keyPressed(int key){
switch(key){
case ' ':
Sounds.play();
break;
}
}

â– issue
Build and execute.
Then crashed about once in 10 times with Segmentation fault : 11.

It happens especially when boot from terminal like...
$ cd test_ofSound.app/Contents/MacOS/
$ ./test_ofSound

macOS

Most helpful comment

Oh great!!
I almost added it to 0.11.1, wishing I had now.
Might consider a 0.11.2 as its a pretty bad bug.

Thanks for reporting it!

All 7 comments

Here is a screen shot when it happened.
This time I run the app from Xcode.

スクリーンショット 2021-03-12 20 15 08

Hi!

I think I saw this once or twice during 0.11.1 but then later on once we got the FFT stuff switched over, I didn't see this anymore.

Can you try these two things and see if it fixes it.
Add these line below line 235 in ofFmodSoundPlayer.cpp

if( channel == NULL ){
    return false;
}

And here
https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofFmodSoundPlayer.h#L82

Change to:

        FMOD_CHANNEL * channel = NULL;

And maybe also add:

 channel = NULL;

To this line:
https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp#L181

If the above fixes it for you, I can do a PR.

Thanks!!

Hi ofTheo!!

I'm so glad to have an advice from you.
I added your 3 lines(2 + 1) and tested, and they fixed the crash!!
Now it is very stable.

Thanks!!

Oh great!!
I almost added it to 0.11.1, wishing I had now.
Might consider a 0.11.2 as its a pretty bad bug.

Thanks for reporting it!

Hey, just wanted to chime in and mention that I had the same issue and

FMOD_CHANNEL * channel = NULL;
FMOD_SOUND * sound = NULL;

was enough for me to fix the problem!
I think creating a 0.11.2 is a good idea!
Thank you so much!

Note: For me it crashes like 9/10 times because I use many ofSoundPlayer instances.

@bvoq - thanks!
Appreciate this feedback. Will do a 0.11.2 patch release soon.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glungtung picture glungtung  Â·  9Comments

sieren picture sieren  Â·  11Comments

edap picture edap  Â·  11Comments

kod3000 picture kod3000  Â·  3Comments

lewislepton picture lewislepton  Â·  7Comments