diff --git a/audio1/card.go b/audio1/card.go index 9e6be77da..1fe303827 100644 --- a/audio1/card.go +++ b/audio1/card.go @@ -34,6 +34,7 @@ type CardPortExport struct { Bluetooth bool Description string Direction int + PortType int } func newCard(card *pulse.Card) *Card { @@ -161,6 +162,7 @@ func (cards CardList) string() string { Bluetooth: isBluetoothCard(cardInfo.core), Description: portInfo.Description, Direction: portInfo.Direction, + PortType: DetectPortType(cardInfo.core, &portInfo), }) } @@ -189,6 +191,7 @@ func (cards CardList) stringWithoutUnavailable() string { Bluetooth: isBluetoothCard(cardInfo.core), Description: portInfo.Description, Direction: portInfo.Direction, + PortType: DetectPortType(cardInfo.core, &portInfo), }) } diff --git a/audio1/priority_old.go b/audio1/priority_old.go index 9c7eda588..2d7fc5586 100644 --- a/audio1/priority_old.go +++ b/audio1/priority_old.go @@ -61,20 +61,20 @@ func GetPortType(cardName string, portName string) int { if contains(cardName, portName, "multichannel") { return PortTypeMultiChannel } + if contains(cardName, portName, "speaker") || + contains(cardName, portName, "input-mic") { + return PortTypeBuiltin + } if contains(cardName, portName, "linein") || contains(cardName, portName, "lineout") { return PortTypeLineIO } - if contains(cardName, portName, "bluez") || - contains(cardName, portName, "bluetooth") { - return PortTypeBluetooth - } - if contains(cardName, portName, "usb") || contains(cardName, portName, "rear-mic") || contains(cardName, portName, "front-mic") || + contains(cardName, portName, "headset") || contains(cardName, portName, "headphone") { return PortTypeHeadset } @@ -83,12 +83,10 @@ func GetPortType(cardName string, portName string) int { return PortTypeHdmi } - if contains(cardName, portName, "speaker") || - contains(cardName, portName, "input-mic") { - return PortTypeBuiltin - + if contains(cardName, portName, "bluez") || + contains(cardName, portName, "bluetooth") { + return PortTypeBluetooth } - return PortTypeUnknown } diff --git a/audio1/priority_policy.go b/audio1/priority_policy.go index 6ffe721f1..8309cf95d 100644 --- a/audio1/priority_policy.go +++ b/audio1/priority_policy.go @@ -48,17 +48,16 @@ func DetectPortType(card *pulse.Card, port *pulse.CardPortInfo) int { if hasKeyword(stringList, "multichannel") { return PortTypeMultiChannel } + if hasKeyword(stringList, "speaker") || + hasKeyword(stringList, "input-mic") { + return PortTypeBuiltin + } if hasKeyword(stringList, "linein") || hasKeyword(stringList, "lineout") { return PortTypeLineIO } - if hasKeyword(stringList, "bluez") || - hasKeyword(stringList, "bluetooth") { - return PortTypeBluetooth - } - if hasKeyword(stringList, "rear-mic") || hasKeyword(stringList, "front-mic") || hasKeyword(stringList, "headphone") || @@ -74,10 +73,9 @@ func DetectPortType(card *pulse.Card, port *pulse.CardPortInfo) int { return PortTypeHdmi } - if hasKeyword(stringList, "speaker") || - hasKeyword(stringList, "input-mic") { - return PortTypeBuiltin - + if hasKeyword(stringList, "bluez") || + hasKeyword(stringList, "bluetooth") { + return PortTypeBluetooth } return PortTypeUnknown diff --git a/audio1/priority_test.go b/audio1/priority_test.go index 50163aa69..5259b4c11 100644 --- a/audio1/priority_test.go +++ b/audio1/priority_test.go @@ -25,7 +25,7 @@ func Test_GetPortType(t *testing.T) { assert.Equal(t, GetPortType("usb.abcd.1234", "world.abcd.1234"), PortTypeHeadset) assert.Equal(t, GetPortType("hbc.abcd.1234", "usb.abcd.1234"), PortTypeHeadset) assert.Equal(t, GetPortType("hello.abcd.speaker", "world.abcd.1234"), PortTypeBuiltin) - assert.Equal(t, GetPortType("hdmi.abcd.speaker", "world.abcd.1234"), PortTypeHdmi) + assert.Equal(t, GetPortType("hdmi.abcd.speaker", "world.abcd.1234"), PortTypeBuiltin) } func Test_IsInputTypeAfter(t *testing.T) {