Skip to content

fix: Fix issue when using AudioSourceType.Microphone#883

Merged
karasusan merged 1 commit intomainfrom
fix/audiosourcetype
Feb 20, 2023
Merged

fix: Fix issue when using AudioSourceType.Microphone#883
karasusan merged 1 commit intomainfrom
fix/audiosourcetype

Conversation

@karasusan
Copy link
Copy Markdown
Collaborator

@karasusan karasusan commented Feb 17, 2023

We got an error when using AudioSourceType.Microphone in Broadcast sample. The cause of this error is attaching multiple AudioSource components to the single gameObject. To fix this issue, this pull request fixes that instantiate new GameObject for attaching AudioSource component to play Microphone.

GameObject has multiple AudioSources and/or AudioListeners attached. While built-in filters like lowpass are instantiated separately, components implementing OnAudioFilterRead may only be used by either one AudioSource or AudioListener at a time.
The reason for this is that any state information used by the callback exists only once in the component, and the source or listener calling it cannot be inferred from the callback.
In this case the OnAudioFilterRead callback of script AudioCustomFilter was first attached to a component of type AudioSource on the game object MainCamera after which a component of type AudioListener tried to attach it.
UnityEngine.GameObject:AddComponent<Unity.WebRTC.AudioCustomFilter> ()
Unity.WebRTC.AudioStreamTrack:.ctor (UnityEngine.AudioSource) (at Library/PackageCache/com.unity.webrtc@3.0.0-pre.4/Runtime/Scripts/AudioStreamTrack.cs:193)
Unity.RenderStreaming.AudioStreamSender/AudioStreamSourceMicrophone/<CreateTrackCoroutine>d__8:MoveNext () (at Packages/com.unity.renderstreaming/Runtime/Scripts/AudioStreamSender.cs:422)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

@karasusan karasusan marked this pull request as ready for review February 17, 2023 08:53
@karasusan karasusan merged commit 0bebc23 into main Feb 20, 2023
@karasusan karasusan deleted the fix/audiosourcetype branch February 20, 2023 08:02
sanalpencere pushed a commit to vagonhq/VagonUnityRenderStreaming that referenced this pull request Aug 21, 2024
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

Successfully merging this pull request may close these issues.

2 participants