Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

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

Draft
m3taphysics wants to merge 7 commits into
devfrom
fix/audio-source-changes
Draft

Introduce AudioSystem to write back the current state of an audio source#6135
m3taphysics wants to merge 7 commits into
devfrom
fix/audio-source-changes

Conversation

@m3taphysics

Copy link
Copy Markdown
Contributor

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
using DCL.ECSRuntime;
using RPC.Context;
using System.Collections.Generic;
using UnityEngine;

Copy link
Copy Markdown
Contributor

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?

Comment thread unity-renderer/Assets/DCLPlugins/ECS7/ECS7Plugin.cs
using DCL.Helpers;
using DCL.Models;
using DCL.SettingsCommon;
using System.Collections.Generic;

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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?

@pravusjif pravusjif Jun 4, 2024

Copy link
Copy Markdown
Member

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants