Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

AL_INVALID_VALUE error when loading the first sound of the game #49

Closed
ghost opened this issue Aug 7, 2012 · 4 comments
Closed

AL_INVALID_VALUE error when loading the first sound of the game #49

ghost opened this issue Aug 7, 2012 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 7, 2012

On OSX, there is a bug when starting solarus.

"Cannot copy the sound samples into buffer 2400
Sound 'sounds/arrow_hit.ogg' will not be played"

Strangely, this is not really an OpenAl bug. The sound is loaded on the second try.

Actually, there is an AL_INVALID_VALUE error happening in the Sound::load_all() function, when storing the first all_sounds[] element :
all_sounds[resource_id] = Sound(resource_id);
This explain why the first sound is considered as invalid, even before loading it.
If I empty the OpenAl error buffer just after this line with alGetError(), there is no more loading problem.

At this point I don't understand the behavior.
Is your code using some OpenAl function elsewhere when calling the Sound constructor or something which can explain why this error on an empty constructor ?

@ghost
Copy link
Author

ghost commented Aug 16, 2012

Actually it's the first call to alGenBuffers() on the OSX implementation which fail. (since OpenAl 1.1 according to my following research)

A simple call with NULL buffer at the begining of Sound::load_all() makes the error disappear.

I don't know why cleaning OpenAl error buffer before Sound::load() (and then just after construct it) make disappear the error too, and I also don't know how to solve it properly ;)

@christopho
Copy link
Collaborator

I can accept this kind of workaround. I implemented it in commit 35120c3 (branch master). Does it work?
Feel free to make a pull request to fix it if it's not okay.

I don't want to make the call with the NULL buffer from Sound::load_all() because Sound::load_all() is not necessarily called.

@ghost
Copy link
Author

ghost commented Aug 17, 2012

Works fine for me :)

Because of the high number of OSX's (or not) workaround, what do you think about manage them by adding some SOLARUS_WORKAROUND_XXX definition in the CMakeList file ?
Not really useful (unless there is an huge commit on all used lib which fix every bug) but it can provide better vision of the OS's dependent code when all "strange issue" will be solved.

EDIT : The patch I just submitted propose an implementation. Accept it if this solution suits you ;)

@ghost ghost closed this as completed Aug 17, 2012
@christopho
Copy link
Collaborator

Hi,
I applied a part of your changes, and added new compilation flags to remove some #ifdef APPLE_, #ifdef __PANDORA, etc.
I removed both workarounds because it's not a problem to apply them in all cases. The less OS-specific code, the better.

Thanks for your patch!

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant