Fix joining unmuted on macOS.

This commit is contained in:
John Preston
2026-04-21 17:10:07 +07:00
parent f34e62f24a
commit c79f62d874
4 changed files with 27 additions and 6 deletions
+4 -4
View File
@@ -1196,6 +1196,10 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
raw->setIncomingVideoOutput(_videoIncoming->sink());
raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled());
_muted.value() | rpl::on_next([=](bool muted) {
Core::App().mediaDevices().setCaptureMuted(muted);
}, _instanceLifetime);
_state.value() | rpl::on_next([=](State state) {
const auto track = (state != State::FailedHangingUp)
&& (state != State::Failed)
@@ -1207,10 +1211,6 @@ void Call::createAndStartController(const MTPDphoneCall &call) {
Core::App().mediaDevices().setCaptureMuteTracker(this, track);
}, _instanceLifetime);
_muted.value() | rpl::on_next([=](bool muted) {
Core::App().mediaDevices().setCaptureMuted(muted);
}, _instanceLifetime);
#if 0
Core::App().batterySaving().value(
) | rpl::on_next([=](bool isSaving) {
@@ -1606,6 +1606,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
_joinState.action = JoinAction::Joining;
_joinState.ssrc = 0;
_initialMuteStateSent = false;
_systemMuteReconciled = false;
setState(State::Joining);
if (!tryCreateController()) {
setInstanceMode(InstanceMode::None);
@@ -1794,6 +1795,13 @@ void GroupCall::joinDone(
: State::Joined);
applyMeInCallLocally();
maybeSendMutedUpdate(wasMuteState);
_systemMuteReconciled = true;
if (!_rtmp) {
const auto state = muted();
const auto nowMuted = (state != MuteState::Active)
&& (state != MuteState::PushToTalk);
Core::App().mediaDevices().setCaptureMuted(nowMuted);
}
for (auto &state : _subchains) {
// Accept initial join blocks.
@@ -2699,8 +2707,8 @@ void GroupCall::setupMediaDevices() {
const auto muted = (state != MuteState::Active)
&& (state != MuteState::PushToTalk);
const auto track = !muted || (state == MuteState::Muted);
devices->setCaptureMuteTracker(this, track);
devices->setCaptureMuted(muted);
devices->setCaptureMuteTracker(this, track);
}, _lifetime);
}
}
@@ -2712,8 +2720,20 @@ void GroupCall::captureMuteChanged(bool mute) {
|| oldState == MuteState::RaisedHand
|| oldState == MuteState::Muted)) {
return;
} else if (!mute
&& (oldState == MuteState::ForceMuted
|| oldState == MuteState::RaisedHand)) {
crl::on_main(this, [] {
Core::App().mediaDevices().setCaptureMuted(true);
});
return;
} else if (!mute && oldState != MuteState::Muted) {
return;
} else if (!mute && !_systemMuteReconciled) {
crl::on_main(this, [] {
Core::App().mediaDevices().setCaptureMuted(true);
});
return;
}
setMutedAndUpdate(mute ? MuteState::Muted : MuteState::Active);
}
@@ -727,6 +727,7 @@ private:
rpl::variable<bool> _emptyRtmp = false;
rpl::variable<bool> _messagesEnabled = false;
bool _initialMuteStateSent = false;
bool _systemMuteReconciled = false;
bool _acceptFields = false;
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;