feat: fix voice join/leave, channel edit defaults, channel-update stream restart
Three bugs fixed across the full stack (proto/server/core/ABI/Win/macOS/iOS): 1. Join/Leave Voice now truly subscribes/unsubscribes from the voice plane. Previously the button only toggled the local mic — receiving was always on (gated by channel membership alone). Added a protocol-level voice subscription concept: new SubscribeVoiceRequest/UnsubscribeVoiceRequest/VoiceSubscriptionResult proto messages, User.voice_subscribed field, vc_join_voice/vc_leave_voice C ABI functions, VC_EVENT_VOICE_STATE event, server-side voice_subscribed flag checked by the SFU relay recipient filter, and core-client gating of remote-stream decoder setup. All three clients rewired to subscribe+mic on Join / unsubscribe on Leave. Text chat works regardless of voice subscription. 2. Channel edit dialog now shows the channel's actual current settings. The read struct vc_channel was missing sort_order and audio fields — only the write struct vc_channel_info had them. Extended vc_channel with both (additive, no ABI break), updated the session model and list_channels marshaling to populate them, and updated all three clients' edit callers to use actual channel info instead of hardcoded defaults. 3. Channel parameter updates now automatically restart everyone's streams. Previously editing a channel's audio config persisted and broadcast a ChannelEvent::UPDATED, but no layer restarted streams — encoders/decoders are frozen at announce time. handle_channel_event now detects audio-config changes on the user's current channel and stop->starts each active local stream. The server reads the updated config on re-announce; peers wire up fresh decoders at the new ssrc. All 29 CTest tests pass; Windows DLL + C# client build clean. Apple clients not yet compile-verified (Windows environment).
This commit is contained in:
@@ -497,7 +497,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
isGuest: true,
|
||||
channelId: event.channelId,
|
||||
selfMicMuted: false, selfDeafened: false,
|
||||
serverMuted: false, serverDeafened: false)
|
||||
serverMuted: false, serverDeafened: false,
|
||||
voiceSubscribed: false)
|
||||
users[event.userId] = u
|
||||
refreshChannelTree(); refreshUserList()
|
||||
if event.channelId == currentChannelId && event.userId != selfUserId {
|
||||
@@ -540,7 +541,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
users[selfUserId] = User(id: self_.id, nickname: self_.nickname, isGuest: self_.isGuest,
|
||||
channelId: event.channelId,
|
||||
selfMicMuted: self_.selfMicMuted, selfDeafened: self_.selfDeafened,
|
||||
serverMuted: self_.serverMuted, serverDeafened: self_.serverDeafened)
|
||||
serverMuted: self_.serverMuted, serverDeafened: self_.serverDeafened,
|
||||
voiceSubscribed: self_.voiceSubscribed)
|
||||
}
|
||||
refreshChannelTree(); refreshUserList(); updateStatusLabel()
|
||||
let name = channels.first(where: { $0.id == event.channelId })?.name ?? "Channel #\(event.channelId)"
|
||||
@@ -589,10 +591,18 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
addActivity("\(u.nickname) started \(kindStr) stream")
|
||||
|
||||
case .streamStopped:
|
||||
if let u = users[event.userId], u.channelId == currentChannelId {
|
||||
if event.userId == selfUserId {
|
||||
if event.streamId == micStreamId {
|
||||
micStreamId = 0
|
||||
settingsWindowController?.resetLevel()
|
||||
}
|
||||
} else if let u = users[event.userId], u.channelId == currentChannelId {
|
||||
addActivity("\(u.nickname) stopped a stream")
|
||||
}
|
||||
|
||||
case .voiceState:
|
||||
handleVoiceState(event)
|
||||
|
||||
case .disconnected:
|
||||
handleDisconnected(event)
|
||||
|
||||
@@ -783,14 +793,27 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
|
||||
@objc private func micToggleClicked() {
|
||||
if micStreamId == 0 {
|
||||
let result = client.joinVoice()
|
||||
if result != .ok {
|
||||
addActivity("Failed to join voice: \(result)")
|
||||
}
|
||||
} else {
|
||||
stopAuxStream()
|
||||
if screenStreamId != 0 { stopScreenAudio() }
|
||||
client.setPushToTalk(false)
|
||||
client.leaveVoice()
|
||||
}
|
||||
}
|
||||
|
||||
private func handleVoiceState(_ event: VoiceCatEvent) {
|
||||
let subscribed = event.u32a != 0
|
||||
if subscribed {
|
||||
let (result, streamId) = client.startStream(StreamDescriptor(kind: .mic, deviceId: nil, label: "Microphone"))
|
||||
if result == .ok {
|
||||
micStreamId = streamId
|
||||
if let devId = selectedInputDeviceId {
|
||||
client.setInputDevice(streamId: streamId, deviceId: devId)
|
||||
}
|
||||
// Stored on the stream before the announce round-trip completes, so the core's
|
||||
// first capture-device open (ensure_audio_running) picks up the channel count.
|
||||
client.setCaptureChannels(streamId: streamId, channels: stereoMic ? 2 : 1)
|
||||
client.setInputMode(selectedInputMode)
|
||||
if selectedInputMode == .voiceActivation {
|
||||
@@ -803,14 +826,11 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
EventFeedback.shared.play(.voiceOn)
|
||||
NSAccessibility.post(element: logTextView, notification: .announcementRequested,
|
||||
userInfo: [.announcement: "Joined voice", .priority: NSAccessibilityPriorityLevel.medium])
|
||||
startAuxStream() // no-op unless the aux stream is enabled in settings
|
||||
startAuxStream()
|
||||
} else {
|
||||
addActivity("Failed to start microphone: \(result)")
|
||||
}
|
||||
} else {
|
||||
stopAuxStream()
|
||||
client.setPushToTalk(false)
|
||||
client.stopStream(micStreamId)
|
||||
micStreamId = 0
|
||||
settingsWindowController?.resetLevel()
|
||||
setVoiceJoinedState(false)
|
||||
@@ -933,6 +953,15 @@ final class MainWindowController: NSWindowController, NSWindowDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func stopScreenAudio() {
|
||||
guard screenStreamId != 0 else { return }
|
||||
stopScreenCapture()
|
||||
client.stopStream(screenStreamId)
|
||||
screenStreamId = 0
|
||||
setShareScreenButton(active: false)
|
||||
addActivity("Stopped sharing screen audio")
|
||||
}
|
||||
|
||||
/// Announce the SCREEN_AUDIO stream with the chosen selection in hand. ScreenCaptureKit
|
||||
/// capture starts once the server's StreamAnnounceResult lands (the .streamStarted event),
|
||||
/// when the effective audio config — and thus the channel count — is known. See
|
||||
@@ -1449,7 +1478,7 @@ extension MainWindowController: NSMenuDelegate {
|
||||
let info = ChannelEdit(id: ch.id, parentId: ch.parentId, name: ch.name,
|
||||
topic: ch.topic, passwordProtected: ch.passwordProtected,
|
||||
password: nil, maxUsers: ch.maxUsers,
|
||||
sortOrder: 0, audio: AudioConfig())
|
||||
sortOrder: ch.sortOrder, audio: ch.audio)
|
||||
let sheet = ChannelEditSheet(channels: channels, editing: info)
|
||||
sheet.onComplete = { [weak self] edited in
|
||||
guard let edited else { return }
|
||||
|
||||
Reference in New Issue
Block a user