Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
22d425d8
Commit
22d425d8
authored
6 years ago
by
Greg Fodor
Browse files
Options
Downloads
Patches
Plain Diff
Fix race conditions on state
parent
5759cdb3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/react-components/ui-root.js
+16
-21
16 additions, 21 deletions
src/react-components/ui-root.js
with
16 additions
and
21 deletions
src/react-components/ui-root.js
+
16
−
21
View file @
22d425d8
...
@@ -288,17 +288,14 @@ class UIRoot extends Component {
...
@@ -288,17 +288,14 @@ class UIRoot extends Component {
setMediaStreamToDefault
=
async
()
=>
{
setMediaStreamToDefault
=
async
()
=>
{
let
hasAudio
=
false
;
let
hasAudio
=
false
;
console
.
log
(
this
.
props
.
store
.
state
);
const
{
lastUsedMicDeviceId
}
=
this
.
props
.
store
.
state
;
const
{
lastUsedMicDeviceId
}
=
this
.
props
.
store
.
state
;
// Try to fetch last used mic, and if we don't get it then fall back to default.
// Try to fetch last used mic, and if we don't get it then fall back to default.
if
(
lastUsedMicDeviceId
)
{
if
(
lastUsedMicDeviceId
)
{
console
.
log
(
"
Check for
"
+
lastUsedMicDeviceId
);
hasAudio
=
await
this
.
fetchAudioTrack
({
audio
:
{
deviceId
:
{
exact
:
lastUsedMicDeviceId
}
}
});
hasAudio
=
await
this
.
fetchAudioTrack
({
audio
:
{
deviceId
:
{
exact
:
lastUsedMicDeviceId
}
}
});
}
}
if
(
!
hasAudio
)
{
if
(
!
hasAudio
)
{
console
.
log
(
"
Use defualt
"
);
hasAudio
=
await
this
.
fetchAudioTrack
({
audio
:
true
});
hasAudio
=
await
this
.
fetchAudioTrack
({
audio
:
true
});
}
}
...
@@ -350,6 +347,8 @@ class UIRoot extends Component {
...
@@ -350,6 +347,8 @@ class UIRoot extends Component {
setupNewMediaStream
=
async
()
=>
{
setupNewMediaStream
=
async
()
=>
{
const
mediaStream
=
new
MediaStream
();
const
mediaStream
=
new
MediaStream
();
await
this
.
fetchMicDevices
();
if
(
this
.
state
.
videoTrack
)
{
if
(
this
.
state
.
videoTrack
)
{
mediaStream
.
addTrack
(
this
.
state
.
videoTrack
);
mediaStream
.
addTrack
(
this
.
state
.
videoTrack
);
}
}
...
@@ -380,17 +379,11 @@ class UIRoot extends Component {
...
@@ -380,17 +379,11 @@ class UIRoot extends Component {
this
.
setState
({
micLevel
:
this
.
micLevelMovingAverage
.
movingAverage
()
});
this
.
setState
({
micLevel
:
this
.
micLevelMovingAverage
.
movingAverage
()
});
},
50
);
},
50
);
setTimeout
(()
=>
{
const
micDeviceId
=
this
.
micDeviceIdForMicLabel
(
this
.
micLabelForMediaStream
(
mediaStream
));
// TODO DEAL WITH BY REFACTORING THESE METHODS TO PASS IN mediaStream;
const
selectedMicDeviceId
=
this
.
selectedMicDeviceId
();
console
.
log
(
this
.
selectedMicLabel
());
console
.
log
(
"
Save
"
+
selectedMicDeviceId
);
if
(
selectedMicDeviceId
)
{
if
(
micDeviceId
)
{
this
.
props
.
store
.
update
({
lastUsedMicDeviceId
:
this
.
selectedMicDeviceId
()
});
this
.
props
.
store
.
update
({
lastUsedMicDeviceId
:
micDeviceId
});
}
}
},
100
);
this
.
setState
({
micUpdateInterval
});
this
.
setState
({
micUpdateInterval
});
}
}
...
@@ -418,7 +411,6 @@ class UIRoot extends Component {
...
@@ -418,7 +411,6 @@ class UIRoot extends Component {
beginAudioSetup
=
async
()
=>
{
beginAudioSetup
=
async
()
=>
{
this
.
startTestTone
();
this
.
startTestTone
();
await
this
.
fetchMicDevices
();
this
.
setState
({
entryStep
:
ENTRY_STEPS
.
audio_setup
});
this
.
setState
({
entryStep
:
ENTRY_STEPS
.
audio_setup
});
};
};
...
@@ -441,17 +433,20 @@ class UIRoot extends Component {
...
@@ -441,17 +433,20 @@ class UIRoot extends Component {
return
!!
this
.
state
.
micDevices
.
find
(
d
=>
HMD_MIC_REGEXES
.
find
(
r
=>
d
.
label
.
match
(
r
)));
return
!!
this
.
state
.
micDevices
.
find
(
d
=>
HMD_MIC_REGEXES
.
find
(
r
=>
d
.
label
.
match
(
r
)));
};
};
micLabelForMediaStream
=
mediaStream
=>
{
return
(
mediaStream
&&
mediaStream
.
getAudioTracks
().
length
>
0
&&
mediaStream
.
getAudioTracks
()[
0
].
label
)
||
""
;
};
selectedMicLabel
=
()
=>
{
selectedMicLabel
=
()
=>
{
return
(
return
this
.
micLabelForMediaStream
(
this
.
state
.
mediaStream
);
(
this
.
state
.
mediaStream
&&
};
this
.
state
.
mediaStream
.
getAudioTracks
().
length
>
0
&&
this
.
state
.
mediaStream
.
getAudioTracks
()[
0
].
label
)
||
micDeviceIdForMicLabel
=
label
=>
{
""
return
this
.
state
.
micDevices
.
filter
(
d
=>
d
.
label
===
label
).
map
(
d
=>
d
.
deviceId
)[
0
];
);
};
};
selectedMicDeviceId
=
()
=>
{
selectedMicDeviceId
=
()
=>
{
return
this
.
state
.
micDevice
s
.
filter
(
d
=>
d
.
label
===
this
.
selectedMicLabel
()).
map
(
d
=>
d
.
deviceId
)[
0
]
;
return
this
.
micDevice
IdForMicLabel
(
this
.
selectedMicLabel
())
;
};
};
onAudioReadyButton
=
()
=>
{
onAudioReadyButton
=
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment