oto icon indicating copy to clipboard operation
oto copied to clipboard

request: `(*Context).Close()`

Open kpeu3i opened this issue 4 years ago • 6 comments

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?

kpeu3i avatar Aug 22 '21 16:08 kpeu3i

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.

hajimehoshi avatar Aug 22 '21 17:08 hajimehoshi

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

kpeu3i avatar Aug 22 '21 17:08 kpeu3i

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 avatar Aug 22 '21 17:08 hajimehoshi

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

kpeu3i avatar Aug 22 '21 17:08 kpeu3i

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

hajimehoshi avatar Aug 22 '21 17:08 hajimehoshi