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

VideoKitAudioManager OnAudioBuffer dosen't work, throws exception #69

Closed
marvpaul opened this issue Nov 1, 2023 · 2 comments
Closed
Labels
bug Something isn't working critical Issues of utmost importance

Comments

@marvpaul
Copy link

marvpaul commented Nov 1, 2023

I tried to use the OnAudioBuffer feature of the VideoKitAudioManager.
I assigned a device to the script and called StartRunning

GameObject.Find("Recorder").GetComponent<VideoKitAudioManager>().device = audioDevice;
await GameObject.Find("Recorder").GetComponent<VideoKitAudioManager>().StartRunning();

I configured this empty method to be the callback:
Screenshot 2023-11-01 at 17 32 30
Screenshot 2023-11-01 at 17 32 48

When starting, I get a lot of exceptions caused by VideoKit:

UnityException: get_isPlaying can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
UnityEngine.Events.PersistentCall.GetRuntimeCall (UnityEngine.Events.UnityEventBase theEvent) (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:451)
UnityEngine.Events.PersistentCallGroup.Initialize (UnityEngine.Events.InvokableCallList invokableList, UnityEngine.Events.UnityEventBase unityEventBase) (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:656)
UnityEngine.Events.UnityEventBase.RebuildPersistentCallsIfNeeded () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:837)
UnityEngine.Events.UnityEventBase.PrepareInvoke () (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:880)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at /Users/bokken/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_1.cs:53)
VideoKit.VideoKitAudioManager.OnSampleBuffer (VideoKit.Devices.AudioBuffer audioBuffer) (at Library/PackageCache/ai.natml.videokit@0.0.15/Runtime/VideoKitAudioManager.cs:187)
VideoKit.Devices.AudioDevice+<>c__DisplayClass11_0.<StartRunning>b__0 (System.IntPtr sampleBuffer) (at Library/PackageCache/ai.natml.videokit@0.0.15/Runtime/Devices/AudioDevice.cs:63)
VideoKit.Devices.AudioDevice.OnAudioBuffer (System.IntPtr context, System.IntPtr sampleBuffer) (at Library/PackageCache/ai.natml.videokit@0.0.15/Runtime/Devices/AudioDevice.cs:185)
UnityEngine.Debug:LogException(Exception)
VideoKit.Devices.AudioDevice:OnAudioBuffer(IntPtr, IntPtr) (at Library/PackageCache/ai.natml.videokit@0.0.15/Runtime/Devices/AudioDevice.cs:188)

@marvpaul
Copy link
Author

marvpaul commented Nov 18, 2023

Bump
I came across this issue in one of my other projects when trying to record from Microphone device using VideoKitRecorder. Would be great to see it fixed soon so I can add Videokit's VideoKitRecorder to my project instead of using my own recording logic.

@olokobayusuf olokobayusuf added bug Something isn't working critical Issues of utmost importance labels Nov 22, 2023
@marvpaul
Copy link
Author

Working now with 0.0.16, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical Issues of utmost importance
Projects
None yet
Development

No branches or pull requests

2 participants