Skip to content

Commit

Permalink
fix: fix a crash
Browse files Browse the repository at this point in the history
判断 defaultSink 是否为 nil
  • Loading branch information
zsien committed Apr 30, 2024
1 parent 8120367 commit dbbc25e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion audio1/audio_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (a *Audio) handleCardChanged(idx uint32) {
}

// 如果发生变化的是当前输出所用的声卡,且是蓝牙声卡
if idx == a.defaultSink.Card && isBluetoothCard(card.core) {
if a.defaultSink != nil && idx == a.defaultSink.Card && isBluetoothCard(card.core) {
if strings.Contains(strings.ToLower(card.ActiveProfile.Name), bluezModeA2dp) {
a.setPropBluetoothAudioMode(bluezModeA2dp)
} else if strings.Contains(strings.ToLower(card.ActiveProfile.Name), bluezModeHeadset) {
Expand Down

0 comments on commit dbbc25e

Please sign in to comment.