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

Introduce AudioSystem to write back the current state of an audio source #6135

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

m3taphysics
Copy link
Collaborator

What does this PR change?

Introduces AudioSourceSystem that can write back the state of an audio source.

Our Code Review Standards

https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md

Copilot summary

copilot:summary

@m3taphysics m3taphysics requested a review from a team as a code owner March 15, 2024 11:49
@@ -6,6 +6,7 @@
using DCL.ECSRuntime;
using RPC.Context;
using System.Collections.Generic;
using UnityEngine;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a leftover?

using DCL.Controllers;
using DCL.ECS7.InternalComponents;
using DCL.ECSRuntime;
using DCL.Helpers;
using DCL.Models;
using DCL.SettingsCommon;
using System.Collections.Generic;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using Cysharp.Threading.Tasks; and using System.Collections.Generic; are not needed, maybe a left over?

using DCL.ECSComponents;
using DCL.ECSRuntime;
using System.Collections.Generic;
using UnityEngine;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove UnityEngine and DCL.ECSRuntime 👌

var audioSourceComponentList = audioSourceComponent.GetForAll();

// Loop through every audio source component
foreach (var component in audioSourceComponentList)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be worth it to switch from a foreach to a for loop to reduce allocations. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlejandroAlvarezMelucciDCL you are right! The IEnumerator call will allocate, good spot

wrappedComponent.WrappedComponent.Model.AudioClipUrl ??= model.audioClipUrl;
wrappedComponent.WrappedComponent.Model.CurrentTime = model.audioSource.time;

if (componentsWriter.TryGetValue(scene.sceneData.sceneNumber, out var writer))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can re-order this check to the beginning to avoid doing all the above in case the componentsWriter doesn't have a writer for the given sceneNumber?

Copy link
Member

@pravusjif pravusjif Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhmmm it would be weird to have a scene without a components writer, to be honest

@m3taphysics m3taphysics marked this pull request as draft March 18, 2024 09:52
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.

3 participants