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

Clear cached points on AdvancedAudioPlayer #776

Open
renezuidhof opened this issue Mar 17, 2024 · 3 comments
Open

Clear cached points on AdvancedAudioPlayer #776

renezuidhof opened this issue Mar 17, 2024 · 3 comments

Comments

@renezuidhof
Copy link

renezuidhof commented Mar 17, 2024

Superpowered version: 2.6.2 (d67e895)

Describe the bug
In my Android app I'm trying to use audioPlayer.openPCM16AudioInMemory to play audio from memory. After opening the audio in memory I want to edit the memory 'in place' while I expect the audioPlayer to always play whatever is in memory. This almost works, though it seems that the start point is cached in the audioPlayer and I can't see a way to clear this cached point.

Playing around with loopBetween, making sure it's start point is outside of the cached memory, seems to work. But this is not something I can use as it is not a very reliable fix.

Steps to Reproduce
Basically I do this:

audioPlayer.openPCM16AudioInMemory(workingAudioBuffer, sampleRate, durationInFrames);
audioPlayer.loopBetween(0, duration)

// The audio is playing

// At some point I do this:

std::copy(newAudioBuffer,
          newAudioBuffer + (duration * numberOfChannels),
          workingAudioBuffer);

// I expect the audioPlayer to play the new audio. But instead it plays ~1 second of 'old' audio and then the new audio.

Let me know if you would like an edited example project.

@gaborszanto
Copy link
Member

The player was never designed with your use-case in mind. Can I consider this as a feature request?

@renezuidhof
Copy link
Author

Yes, it is indeed more like a feature request. I guess I was hoping it would magically work :)

@renezuidhof
Copy link
Author

renezuidhof commented Mar 17, 2024

I was also trying to call openPCM16AudioInMemory again after changing the audio in memory. But I think the audioPlayer takes ownership over the memory so it gets freed after calling openPCM16AudioInMemory again. So opening the same memory location would cause problems. Correct me if I'm wrong.

Could this work with using the AudioInMemory class with a positive retain count? Is this something you would recommend?

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

2 participants