@@ -9,9 +9,31 @@ import { Services } from 'components-react/service-provider';
9
9
import { Menu } from 'util/menus/Menu' ;
10
10
import { $t } from 'services/i18n' ;
11
11
import { useRealmObject } from 'components-react/hooks/realm' ;
12
+ import { getDefined } from 'util/properties-type-guards' ;
12
13
13
14
const mins = { x : 150 , y : 120 } ;
14
15
16
+ export function getVisibleAudioSourcesIds ( ) {
17
+ const { ScenesService, AudioService } = Services ;
18
+ const activeScene = getDefined ( ScenesService . views . activeScene ) ;
19
+
20
+ // Get sources ids for visible scene items
21
+ // using the Set to avoid duplicates and improve performance
22
+ const visibleSourcesIds = new Set (
23
+ activeScene . items . filter ( item => item . visible ) . map ( item => item . sourceId ) ,
24
+ ) ;
25
+
26
+ return AudioService . views . sourcesForCurrentScene
27
+ . filter ( source => {
28
+ return (
29
+ ! source . mixerHidden &&
30
+ source . isControlledViaObs &&
31
+ ( visibleSourcesIds . has ( source . sourceId ) || source . isGlobal ( ) )
32
+ ) ;
33
+ } )
34
+ . map ( source => source . sourceId ) ;
35
+ }
36
+
15
37
export function Mixer ( ) {
16
38
const { EditorCommandsService, AudioService, CustomizationService } = Services ;
17
39
@@ -26,11 +48,7 @@ export function Mixer() {
26
48
} , [ ] ) ;
27
49
28
50
const performanceMode = useRealmObject ( CustomizationService . state ) . performanceMode ;
29
- const { audioSourceIds } = useVuex ( ( ) => ( {
30
- audioSourceIds : AudioService . views . sourcesForCurrentScene
31
- . filter ( source => ! source . mixerHidden && source . isControlledViaObs )
32
- . map ( source => source . sourceId ) ,
33
- } ) ) ;
51
+ const audioSourceIds = useVuex ( getVisibleAudioSourcesIds ) ;
34
52
35
53
function showAdvancedSettings ( ) {
36
54
AudioService . actions . showAdvancedSettings ( ) ;
0 commit comments