openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.91k stars 2.55k forks source link

ofxOpenALSoundPlayer - still crashes on deletion / exit #2018

Closed ofTheo closed 11 years ago

ofTheo commented 11 years ago

Even with latest develop branch and this fix: #1861 I still get crashes with iOS when a sound object is playing and is deleted ( or the app is exited ).

I can minimize this happening by disabling the automatic calls to initializeSoundEngine() and closeSoundEngine() and instead call initializeSoundEngine() once when the app launches. But if I call closeSoundEngine() on app exit then 30% of the time I will get a crash relating to OpenAL or SoundEngine code.

My feeling is that as a default sound player for iOS @julapy 's https://github.com/julapy/ofxiOSSoundPlayer is a much better option.

It supports everything ofxOpenALSoundPlayer does ( except multiplay ) and it is able to quickly load mp3 and other compressed files, using hardware decoding.

For people who want 3D sound playback or multiplay I suggest a thorough revamp / rewrite of ofxOpenALSoundPlayer.

There is also another issue with using ofxOpenALSoundPlayer, which is it prevents you from opening the microphone at the same time. A rewrite with a more modern approach could solve this problem. ( Will post this as a separate issue ).

Curious what @julapy @damiannz and @arturoc - think about this suggestion.

Related issues:

1324

1325

1385

julapy commented 11 years ago

hey @ofTheo, i think you are right about ofxOpenALSoundPlayer needing a complete rewrite. theres loads of issues with it atm...

ofxiOSSoundPlayer is light weight and it utilises all the AVAudioPlayer features. apart from multiplay not being supported, one other limitation i've encountered is that playback speed only works between 0.5 and 2.0 so playing sound backwards or faster then 2x speed is not possible.

good thing about ofxiOSSoundPlayer is it supports all the iOS sound formats and they all behave exactly the same. when using ofxOpenALSoundPlayer i noticed lots of discrepancies in behaviour between different formats.

another nice feature is that ofxiOSSoundPlayer is really just a wrapper for AVSoundPlayer, so you can use AVSoundPlayer in obj-c projects when not using OF...

+1 for swapping ofxOpenALSoundPlayer for ofxiOSSoundPlayer.

but id be keen to hear if anyone else can foresee any issues with this.

L.

admsyn commented 11 years ago

Hey @julapy, is your ofxiPhoneSoundStream refactor going to involve making the AVFoundation ofxiOSSoundPlayer the default? If not, would this be a good time to go for it?

Let me know if there's any way I can help, because all of the section-sound + 0.8.0 issues are in some way or another related to this. https://github.com/openframeworks/openFrameworks/issues?labels=section-sound&milestone=11&state=open

PS. Is the refactor going to make direct use of the AURemoteIO? There's a pretty awesome inter-app audio streaming feature coming in iOS 7 that relies on an AURemoteIO being available (see the What's New in Core Audio for iOS WWDC video)

julapy commented 11 years ago

hey @admsyn, ofxiPhoneSoundStream refactoring is separate to ofxiOSSoundPlayer, and theres no dependencies between the two. ive been doing a lot of work with ofxiPhoneSoundStream recently and have come up against crashes & leaks when swapping between streaming-in and streaming-out. so this refactoring will fix that... but the code will be essentially the same, still using AudioUnits.... it will also separate the obj-c classes from c++ OF classes like was done with the ofxiPhoneVideoPlayer.

here is the branch so far, https://github.com/julapy/openFrameworks/commits/ofxiOSSoundStream aiming to get this finished today.

but back to ofxiOSSoundPlayer, think the general consensus is to make ofxiOSSoundPlayer the default for ios. @ofTheo is keen to swap it out and theres been no other arguments against... probably a good time to do it this weekend if everyone else keen?!

julapy commented 11 years ago

nudge, should i put a PR through for ofxiOSSoundPlayer?

ofTheo commented 11 years ago

yes!

there is one other issue I noticed that might be worth checking out before submitting a PR. I've had issues playing relative paths before - might be worth checking it with just a couple of different path types ( relative, relative nested, absolute ) and just make sure it plays them okay.

If it all seems good def submit a PR - ofxOpenALSoundPlayer is actually a huge pain to use on iOS.

incase people want the 3D sound that OpenAL offered - I added that stuff as ofxiOSSoundPlayer3D https://gist.github.com/ofTheo/5796441

Not sure if it should be in the ofxiPhone addon though. What do you think @julapy @admsyn ?

julapy commented 11 years ago

yeah i saw that path issue you logged a while ago and i think ive addressed it since, but i'll spend some more time tomorrow testing it before the PR.

i haven't used the 3D sound feature on iOS before and i imagine the majority of users wouldn't have either, so i would be leaning more to leaving it out as an addon.

ofTheo commented 11 years ago

sounds good to me! :)

admsyn commented 11 years ago

I agree RE: leaving the 3D features as an addon.

AVFoundation! :thumbsup:

julapy commented 11 years ago

so im removing ofxOpenALSoundPlayer and SoundEngine from ofxiPhone and a couple questions popped up, 1) is ofxiOSSoundPlayer3D replacing them? 2) will ofxOpenALSoundPlayer live somewhere else for people that need to still use it?

bilderbuchi commented 11 years ago

Closed by #2127