Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential problem with calculating mojoAl's Buffer size in samples #8

Open
ivan-mogilko opened this issue Jan 16, 2022 · 0 comments
Open

Comments

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jan 16, 2022

In our program we calculate full playback offset by adding number of samples from every processed buffer. We calculate samples as
buffer_samples = (buffer_size * 8) / (buffer_bits * buffer_channels);
where buffer values are retrieved using alGetBufferi with AL_SIZE, AL_BITS and AL_CHANNELS respectively.

Recently I've met an issue where this resulted in a wrong number of samples, and found out that this is because mojoAL internally stores samples as float32 in the generated buffer. If we pass a 16-bit sound data into alBufferData (AL_FORMAT_STEREO16 / AL_FORMAT_MONO16), Buffer still reports original input bitness as 16, but at the same time it has samples stores as 32-bit, therefore less samples fit into the same buffer size. This makes it impossible to calculate number samples correctly without "secret knowledge" about mojoAL's implementation, where we have to always use 32 as "buffer bits".

I must admit that I'm not very experienced with OpenAL yet, so still unsure whether this is a valid bug, or we are using a method we are not supposed to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant