Skip to content

Commit dbbc25e

Browse files
committed
fix: fix a crash
判断 defaultSink 是否为 nil
1 parent 8120367 commit dbbc25e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

audio1/audio_events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func (a *Audio) handleCardChanged(idx uint32) {
327327
}
328328

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

0 commit comments

Comments
 (0)