Skip to content

Commit

Permalink
Reorder unmute sequence (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroshihorie authored Sep 12, 2024
1 parent 3eb3d39 commit df0629a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Sources/LiveKit/Track/AudioManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ public class AudioManager: Loggable {
// trigger events when state mutates
_state.onDidMutate = { [weak self] newState, oldState in
guard let self else { return }
// Return if state is equal.
guard newState != oldState else { return }

self.log("\(oldState) -> \(newState)")

#if os(iOS)
let configureFunc = newState.customConfigureFunc ?? self.defaultConfigureAudioSessionFunc
configureFunc(newState, oldState)
Expand Down
8 changes: 4 additions & 4 deletions Sources/LiveKit/Track/Track.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,16 @@ extension Track {
func _mute() async throws {
// LocalTrack only, already muted
guard self is LocalTrack, !isMuted else { return }
try await disable()
try await stop()
try await disable() // Disable track first
try await stop() // Stop track
set(muted: true, shouldSendSignal: true)
}

func _unmute() async throws {
// LocalTrack only, already un-muted
guard self is LocalTrack, isMuted else { return }
try await enable()
try await start()
try await start() // Start track first (Configure session first if local audio)
try await enable() // Enable track
set(muted: false, shouldSendSignal: true)
}
}
Expand Down

0 comments on commit df0629a

Please sign in to comment.