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

request: (*Context).Close() #149

Open
kpeu3i opened this issue Aug 22, 2021 · 5 comments
Open

request: (*Context).Close() #149

kpeu3i opened this issue Aug 22, 2021 · 5 comments

Comments

@kpeu3i
Copy link

kpeu3i commented Aug 22, 2021

I'm trying to switch to a new version (v2) of the library but seems there is no way to recreate context now. But I see this option documented here https://github.com/hajimehoshi/oto/blob/main/driver.go#L26? What I missed? Context has Suspend and Resume methods, are they do the job?

@hajimehoshi
Copy link
Member

hajimehoshi commented Aug 22, 2021

I have removed Close from Context as of v2. Then the context will live until the process dies.

Suspend and Resume work if you want to pause audio temporarily.

@kpeu3i
Copy link
Author

kpeu3i commented Aug 22, 2021

hmm, but what if having different contexts created with the different args (sampleRate, channelNum, bitDepthInBytes) might be necessary during the app lifecycle?

@hajimehoshi
Copy link
Member

Yeah, or creating a process, using oto there, and closing it would be necessary.

I welcome contributions to add (*Context).Close though I think it is not easy to implement this correctly in all the platforms...

@hajimehoshi hajimehoshi changed the title How to close context? request: (*Context).Close Aug 22, 2021
@hajimehoshi hajimehoshi changed the title request: (*Context).Close request: (*Context).Close() Aug 22, 2021
@kpeu3i
Copy link
Author

kpeu3i commented Aug 22, 2021

Got it, thank you for the quick response! Seems like I can reuse the same context in my app...

@hajimehoshi
Copy link
Member

Another suggestion is to resample your audio source, which can be a quite heavy task.

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