Documentation
¶
Index ¶
- Constants
- Variables
- func DetectPortType(card *pulse.Card, port *pulse.CardPortInfo) int
- func GetPortType(cardName string, portName string) int
- type Audio
- func (v *Audio) GetExportedMethods() dbusutil.ExportedMethods
- func (*Audio) GetInterfaceName() string
- func (a *Audio) IsPortEnabled(cardId uint32, portName string) (enabled bool, busErr *dbus.Error)
- func (a *Audio) NoRestartPulseAudio() *dbus.Error
- func (a *Audio) Reset() *dbus.Error
- func (a *Audio) SetBluetoothAudioMode(mode string) *dbus.Error
- func (a *Audio) SetPort(cardId uint32, portName string, direction int32) *dbus.Error
- func (a *Audio) SetPortEnabled(cardId uint32, portName string, enabled bool) *dbus.Error
- type BluezAudioManager
- type Card
- type CardConfig
- type CardExport
- type CardList
- type CardPortExport
- type ConfigKeeper
- func (ck *ConfigKeeper) GetCardAndPortConfig(cardName string, portName string) (*CardConfig, *PortConfig)
- func (ck *ConfigKeeper) Load() error
- func (ck *ConfigKeeper) Print()
- func (ck *ConfigKeeper) RemoveCardConfig(cardName string)
- func (ck *ConfigKeeper) Save() error
- func (ck *ConfigKeeper) SetBalance(cardName string, portName string, balance float64)
- func (ck *ConfigKeeper) SetEnabled(cardName string, portName string, enabled bool)
- func (ck *ConfigKeeper) SetIncreaseVolume(cardName string, portName string, enhance bool)
- func (ck *ConfigKeeper) SetMuteAll(mute bool)
- func (ck *ConfigKeeper) SetMuteInput(mute bool)
- func (ck *ConfigKeeper) SetMuteOutput(mute bool)
- func (ck *ConfigKeeper) SetReduceNoise(cardName string, portName string, reduce bool)
- func (ck *ConfigKeeper) SetVolume(cardName string, portName string, volume float64)
- func (ck *ConfigKeeper) UpdateCardConfig(cardConfig *CardConfig)
- type Meter
- type Module
- type MuteConfig
- type Port
- type PortConfig
- type PortToken
- type Priorities
- func (pr *Priorities) AddAvailable(cards CardList)
- func (pr *Priorities) AddInputPort(cardName string, portName string)
- func (pr *Priorities) AddOutputPort(cardName string, portName string)
- func (pr *Priorities) GetFirstInput() (string, string)
- func (pr *Priorities) GetFirstInputSkip(skipper Skipper) (string, string)
- func (pr *Priorities) GetFirstOutput() (string, string)
- func (pr *Priorities) GetFirstOutputSkip(skipper Skipper) (string, string)
- func (pr *Priorities) IsInputTypeAfter(type1 int, type2 int) bool
- func (pr *Priorities) IsOutputTypeAfter(type1 int, type2 int) bool
- func (pr *Priorities) Load(file string, cards CardList)
- func (pr *Priorities) Print()
- func (pr *Priorities) RemoveCard(cardName string)
- func (pr *Priorities) RemoveInputPort(cardName string, portName string)
- func (pr *Priorities) RemoveOutputPort(cardName string, portName string)
- func (pr *Priorities) RemoveUnavailable(cards CardList)
- func (pr *Priorities) Save(file string) error
- func (pr *Priorities) SetInputPortFirst(cardName string, portName string)
- func (pr *Priorities) SetOutputPortFirst(cardName string, portName string)
- type PriorityManager
- func (pm *PriorityManager) Init(cards CardList)
- func (pm *PriorityManager) Load() bool
- func (pm *PriorityManager) Print()
- func (pm *PriorityManager) Save()
- func (pm *PriorityManager) SetFirstInputPort(cardName string, portName string)
- func (pm *PriorityManager) SetFirstOutputPort(cardName string, portName string)
- func (pm *PriorityManager) SetPorts(cards CardList)
- func (pm *PriorityManager) SetTheFirstPort(card *pulse.Card, port *pulse.CardPortInfo)
- type PriorityPolicy
- func (pp *PriorityPolicy) AddPort(port *PriorityPort) int
- func (pp *PriorityPolicy) AddRawPort(card *pulse.Card, port *pulse.CardPortInfo) int
- func (pp *PriorityPolicy) AppendPort(port *PriorityPort)
- func (pp *PriorityPolicy) CountPort() int
- func (pp *PriorityPolicy) FindPortIndex(cardName string, portName string) int
- func (pp *PriorityPolicy) GetPreferPort(port1 *PriorityPort, port2 *PriorityPort) *PriorityPort
- func (pp *PriorityPolicy) GetPreferType(type1 int, type2 int) int
- func (pp *PriorityPolicy) GetTheFirstPort() PriorityPort
- func (pp *PriorityPolicy) GetTheFirstType() int
- func (pp *PriorityPolicy) InsertPortBeforeIndex(port *PriorityPort, index int)
- func (pp *PriorityPolicy) RemoveCard(cardName string)
- func (pp *PriorityPolicy) RemovePort(port *PriorityPort) bool
- func (pp *PriorityPolicy) RemovePortByIndex(index int) bool
- func (pp *PriorityPolicy) RemovePortByName(cardName string, portName string) bool
- func (pp *PriorityPolicy) SetPorts(ports PriorityPortList)
- func (pp *PriorityPolicy) SetTheFirstPort(cardName string, portName string) bool
- func (pp *PriorityPolicy) SetTheFirstType(portType int) bool
- type PriorityPort
- type PriorityPortList
- type PriorityTypeList
- type Profile
- type ProfileList
- type Sink
- func (s *Sink) CheckPort() *dbus.Error
- func (v *Sink) GetExportedMethods() dbusutil.ExportedMethods
- func (*Sink) GetInterfaceName() string
- func (s *Sink) GetMeter() (meter dbus.ObjectPath, busErr *dbus.Error)
- func (s *Sink) SetBalance(value float64, isPlay bool) *dbus.Error
- func (s *Sink) SetFade(value float64) *dbus.Error
- func (s *Sink) SetMute(value bool) *dbus.Error
- func (s *Sink) SetPort(name string) *dbus.Error
- func (s *Sink) SetVolume(value float64, isPlay bool) *dbus.Error
- type SinkInput
- func (v *SinkInput) GetExportedMethods() dbusutil.ExportedMethods
- func (*SinkInput) GetInterfaceName() string
- func (s *SinkInput) SetBalance(value float64, isPlay bool) *dbus.Error
- func (s *SinkInput) SetFade(value float64) *dbus.Error
- func (s *SinkInput) SetMute(value bool) *dbus.Error
- func (s *SinkInput) SetVolume(value float64, isPlay bool) *dbus.Error
- type Skipper
- type Source
- func (s *Source) CheckPort() *dbus.Error
- func (v *Source) GetExportedMethods() dbusutil.ExportedMethods
- func (*Source) GetInterfaceName() string
- func (s *Source) GetMeter() (meter dbus.ObjectPath, busErr *dbus.Error)
- func (s *Source) SetBalance(value float64, isPlay bool) *dbus.Error
- func (s *Source) SetFade(value float64) *dbus.Error
- func (s *Source) SetMute(value bool) *dbus.Error
- func (s *Source) SetPort(name string) *dbus.Error
- func (s *Source) SetVolume(value float64, isPlay bool) *dbus.Error
Constants ¶
const ( CardBuildin = 0 CardBluethooh = 1 CardUnknow = 2 PropDeviceFromFactor = "device.form_factor" PropDeviceBus = "device.bus" )
const ( PortTypeBluetooth int = iota // 蓝牙音频 PortTypeHeadset // 3.5mm 耳麦 PortTypeUsb // USB PortTypeBuiltin // 内置扬声器和话筒 PortTypeHdmi // HDMI PortTypeLineIO // 线缆输入输出 PortTypeMultiChannel // 多声道 PortTypeUnknown // 其他类型 PortTypeCount // 有效的端口类型个数 PortTypeInvalid = -1 // 表示无效的类型 )
const ( PropAppIconName = "application.icon_name" PropAppName = "application.name" PropAppProcessID = "application.process.id" PropAppProcessBinary = "application.process.binary" )
Variables ¶
var GetBluezAudioManager = createBluezAudioManagerSingleton(bluezAudioConfigFilePath)
var GetConfigKeeper = createConfigKeeperSingleton(globalConfigKeeperFile, globalConfigKeeperMuteFile)
var GetPriorityManager = createPriorityManagerSingleton(globalPrioritiesFilePath)
Functions ¶
func GetPortType ¶
Types ¶
type Audio ¶
type Audio struct { PropsMu sync.RWMutex // dbusutil-gen: equal=objectPathSliceEqual SinkInputs []dbus.ObjectPath // dbusutil-gen: equal=objectPathSliceEqual Sinks []dbus.ObjectPath // dbusutil-gen: equal=objectPathSliceEqual Sources []dbus.ObjectPath DefaultSink dbus.ObjectPath DefaultSource dbus.ObjectPath Cards string BluetoothAudioMode string // 蓝牙模式 // dbusutil-gen: equal=isStrvEqual BluetoothAudioModeOpts []string // 可用的蓝牙模式 // dbusutil-gen: ignore IncreaseVolume gsprop.Bool `prop:"access:rw"` ReduceNoise bool `prop:"access:rw"` // 最大音量 MaxUIVolume float64 // readonly // contains filtered or unexported fields }
func (*Audio) GetExportedMethods ¶
func (v *Audio) GetExportedMethods() dbusutil.ExportedMethods
func (*Audio) GetInterfaceName ¶
func (*Audio) IsPortEnabled ¶
func (*Audio) NoRestartPulseAudio ¶
func (*Audio) SetBluetoothAudioMode ¶
设置蓝牙模式
type BluezAudioManager ¶
type BluezAudioManager struct { BluezAudioConfig map[string]string // cardName => bluezMode // contains filtered or unexported fields }
蓝牙音频管理器
func (*BluezAudioManager) GetMode ¶
func (m *BluezAudioManager) GetMode(cardName string) string
获取模式,这里应该使用 *pulse.Card.Name
func (*BluezAudioManager) SetMode ¶
func (m *BluezAudioManager) SetMode(cardName string, mode string)
设置模式,这里应该使用 *pulse.Card.Name
type Card ¶
type Card struct { Id uint32 Name string ActiveProfile *Profile Profiles ProfileList Ports pulse.CardPortInfos // contains filtered or unexported fields }
type CardConfig ¶
type CardConfig struct { Name string Ports map[string]*PortConfig // Name => PortConfig }
func NewCardConfig ¶
func NewCardConfig(name string) *CardConfig
func (*CardConfig) RemovePortConfig ¶
func (card *CardConfig) RemovePortConfig(portName string)
func (*CardConfig) UpdatePortConfig ¶
func (card *CardConfig) UpdatePortConfig(portConfig *PortConfig)
type CardExport ¶
type CardExport struct { Id uint32 Name string Ports []CardPortExport }
type CardPortExport ¶
type ConfigKeeper ¶
type ConfigKeeper struct { Cards map[string]*CardConfig // Name => CardConfig Mute *MuteConfig // 全局静音 // contains filtered or unexported fields }
func NewConfigKeeper ¶
func NewConfigKeeper(path string, mutePath string) *ConfigKeeper
func (*ConfigKeeper) GetCardAndPortConfig ¶
func (ck *ConfigKeeper) GetCardAndPortConfig(cardName string, portName string) (*CardConfig, *PortConfig)
func (*ConfigKeeper) Load ¶
func (ck *ConfigKeeper) Load() error
func (*ConfigKeeper) Print ¶
func (ck *ConfigKeeper) Print()
func (*ConfigKeeper) RemoveCardConfig ¶
func (ck *ConfigKeeper) RemoveCardConfig(cardName string)
func (*ConfigKeeper) Save ¶
func (ck *ConfigKeeper) Save() error
func (*ConfigKeeper) SetBalance ¶
func (ck *ConfigKeeper) SetBalance(cardName string, portName string, balance float64)
func (*ConfigKeeper) SetEnabled ¶
func (ck *ConfigKeeper) SetEnabled(cardName string, portName string, enabled bool)
func (*ConfigKeeper) SetIncreaseVolume ¶
func (ck *ConfigKeeper) SetIncreaseVolume(cardName string, portName string, enhance bool)
func (*ConfigKeeper) SetMuteAll ¶
func (ck *ConfigKeeper) SetMuteAll(mute bool)
func (*ConfigKeeper) SetMuteInput ¶
func (ck *ConfigKeeper) SetMuteInput(mute bool)
func (*ConfigKeeper) SetMuteOutput ¶
func (ck *ConfigKeeper) SetMuteOutput(mute bool)
func (*ConfigKeeper) SetReduceNoise ¶
func (ck *ConfigKeeper) SetReduceNoise(cardName string, portName string, reduce bool)
func (*ConfigKeeper) SetVolume ¶
func (ck *ConfigKeeper) SetVolume(cardName string, portName string, volume float64)
func (*ConfigKeeper) UpdateCardConfig ¶
func (ck *ConfigKeeper) UpdateCardConfig(cardConfig *CardConfig)
type Meter ¶
func (*Meter) GetExportedMethods ¶
func (v *Meter) GetExportedMethods() dbusutil.ExportedMethods
func (*Meter) GetInterfaceName ¶
type Module ¶
type Module struct { *loader.ModuleBase // contains filtered or unexported fields }
func (*Module) GetDependencies ¶
type MuteConfig ¶
func NewMuteConfig ¶
func NewMuteConfig() *MuteConfig
type PortConfig ¶
type PortConfig struct { Name string Enabled bool Volume float64 IncreaseVolume bool Balance float64 ReduceNoise bool Mute bool // 静音改为全局,此配置废弃 }
func NewPortConfig ¶
func NewPortConfig(name string) *PortConfig
type Priorities ¶
type Priorities struct { OutputTypePriority []int OutputInstancePriority []*PortToken InputTypePriority []int InputInstancePriority []*PortToken }
func NewPriorities ¶
func NewPriorities() *Priorities
func (*Priorities) AddAvailable ¶
func (pr *Priorities) AddAvailable(cards CardList)
func (*Priorities) AddInputPort ¶
func (pr *Priorities) AddInputPort(cardName string, portName string)
func (*Priorities) AddOutputPort ¶
func (pr *Priorities) AddOutputPort(cardName string, portName string)
func (*Priorities) GetFirstInput ¶
func (pr *Priorities) GetFirstInput() (string, string)
func (*Priorities) GetFirstInputSkip ¶
func (pr *Priorities) GetFirstInputSkip(skipper Skipper) (string, string)
func (*Priorities) GetFirstOutput ¶
func (pr *Priorities) GetFirstOutput() (string, string)
func (*Priorities) GetFirstOutputSkip ¶
func (pr *Priorities) GetFirstOutputSkip(skipper Skipper) (string, string)
func (*Priorities) IsInputTypeAfter ¶
func (pr *Priorities) IsInputTypeAfter(type1 int, type2 int) bool
这个判断的是 type2 是否在 type1 之后
func (*Priorities) IsOutputTypeAfter ¶
func (pr *Priorities) IsOutputTypeAfter(type1 int, type2 int) bool
这个判断的是 type2 是否在 type1 之后
func (*Priorities) Load ¶
func (pr *Priorities) Load(file string, cards CardList)
func (*Priorities) Print ¶
func (pr *Priorities) Print()
func (*Priorities) RemoveCard ¶
func (pr *Priorities) RemoveCard(cardName string)
func (*Priorities) RemoveInputPort ¶
func (pr *Priorities) RemoveInputPort(cardName string, portName string)
func (*Priorities) RemoveOutputPort ¶
func (pr *Priorities) RemoveOutputPort(cardName string, portName string)
func (*Priorities) RemoveUnavailable ¶
func (pr *Priorities) RemoveUnavailable(cards CardList)
func (*Priorities) Save ¶
func (pr *Priorities) Save(file string) error
func (*Priorities) SetInputPortFirst ¶
func (pr *Priorities) SetInputPortFirst(cardName string, portName string)
func (*Priorities) SetOutputPortFirst ¶
func (pr *Priorities) SetOutputPortFirst(cardName string, portName string)
type PriorityManager ¶
type PriorityManager struct { Output *PriorityPolicy Input *PriorityPolicy // contains filtered or unexported fields }
优先级策略组,包含输入和输出
func (*PriorityManager) SetFirstInputPort ¶
func (pm *PriorityManager) SetFirstInputPort(cardName string, portName string)
设置优先级最高的输入端口 注意:cardName和portName有好几种,不要传错了 应当使用 pulse.Card.Name 和 pulse.CardPortInfo.Name 形似:"alsa_card.pci-0000_00_1f.3" 和 "hdmi-output-0" 而不是: "HDA Intel PCH" 和 "HDMI / DisplayPort"
func (*PriorityManager) SetFirstOutputPort ¶
func (pm *PriorityManager) SetFirstOutputPort(cardName string, portName string)
设置优先级最高的输出端口 注意:cardName和portName有好几种,不要传错了 应当使用 pulse.Card.Name 和 pulse.CardPortInfo.Name 形似:"alsa_card.pci-0000_00_1f.3" 和 "hdmi-output-0" 而不是: "HDA Intel PCH" 和 "HDMI / DisplayPort"
func (*PriorityManager) SetPorts ¶
func (pm *PriorityManager) SetPorts(cards CardList)
设置有效端口 这是因为从配置文件读出来的数据是上次运行时保存的,两次运行之间(例如关机状态下)可能插拔了设备 因此需要删除无效端口,添加新的有效端口
func (*PriorityManager) SetTheFirstPort ¶
func (pm *PriorityManager) SetTheFirstPort(card *pulse.Card, port *pulse.CardPortInfo)
设置优先级最高的端口(自动识别输入输出)
type PriorityPolicy ¶
type PriorityPolicy struct { Ports PriorityPortList Types PriorityTypeList }
管理一组实例和类型的优先级
func (*PriorityPolicy) AddPort ¶
func (pp *PriorityPolicy) AddPort(port *PriorityPort) int
添加一个端口,返回插入的位置索引
func (*PriorityPolicy) AddRawPort ¶
func (pp *PriorityPolicy) AddRawPort(card *pulse.Card, port *pulse.CardPortInfo) int
添加一个原始端口,返回插入的位置索引
func (*PriorityPolicy) AppendPort ¶
func (pp *PriorityPolicy) AppendPort(port *PriorityPort)
在末尾添加一个端口
func (*PriorityPolicy) FindPortIndex ¶
func (pp *PriorityPolicy) FindPortIndex(cardName string, portName string) int
查找一个端口的index(这个index仅仅指在优先级列表中的index,和PulseAudio中的index无关)
func (*PriorityPolicy) GetPreferPort ¶
func (pp *PriorityPolicy) GetPreferPort(port1 *PriorityPort, port2 *PriorityPort) *PriorityPort
比较端口实例的优先级
func (*PriorityPolicy) GetPreferType ¶
func (pp *PriorityPolicy) GetPreferType(type1 int, type2 int) int
比较端口类型的优先级
func (*PriorityPolicy) GetTheFirstPort ¶
func (pp *PriorityPolicy) GetTheFirstPort() PriorityPort
获取优先级最高的端口
func (*PriorityPolicy) InsertPortBeforeIndex ¶
func (pp *PriorityPolicy) InsertPortBeforeIndex(port *PriorityPort, index int)
在指定位置之前插入一个端口,index <= 0 则插入到开头,index >= len 则添加到末尾
func (*PriorityPolicy) RemoveCard ¶
func (pp *PriorityPolicy) RemoveCard(cardName string)
删除一个声卡上的所有端口
func (*PriorityPolicy) RemovePort ¶
func (pp *PriorityPolicy) RemovePort(port *PriorityPort) bool
删除一个端口
func (*PriorityPolicy) RemovePortByIndex ¶
func (pp *PriorityPolicy) RemovePortByIndex(index int) bool
通过index删除一个端口
func (*PriorityPolicy) RemovePortByName ¶
func (pp *PriorityPolicy) RemovePortByName(cardName string, portName string) bool
通过名称删除一个端口
func (*PriorityPolicy) SetPorts ¶
func (pp *PriorityPolicy) SetPorts(ports PriorityPortList)
设置有效端口 这是因为从配置文件读出来的数据是上次运行时保存的,两次运行之间(例如关机状态下)可能插拔了设备 因此需要删除无效端口,添加新的有效端口
func (*PriorityPolicy) SetTheFirstPort ¶
func (pp *PriorityPolicy) SetTheFirstPort(cardName string, portName string) bool
将指定端口的优先级设为最高,副作用:将该端口类型的优先级设为最高,将同类端口的优先级提高
func (*PriorityPolicy) SetTheFirstType ¶
func (pp *PriorityPolicy) SetTheFirstType(portType int) bool
将指定类型的优先级设为最高,此函数不会提高该类型的端口的优先级
type PriorityPort ¶
type PriorityPort struct { CardName string PortName string PortType int // 部分声卡需要在Property里判断类型,只有CardName和PortName不足以用来判断PortType,因此添加此项 }
优先级中使用的端口(注意:用于表示端口的结构体有好几个,不要弄混)
type ProfileList ¶
type ProfileList []*Profile
type Sink ¶
type Sink struct { PropsMu sync.RWMutex Name string Description string // 默认音量值 BaseVolume float64 // 是否静音 Mute bool // 当前音量 Volume float64 // 左右声道平衡值 Balance float64 // 是否支持左右声道调整 SupportBalance bool // 前后声道平衡值 Fade float64 // 是否支持前后声道调整 SupportFade bool // dbusutil-gen: equal=portsEqual // 支持的输出端口 Ports []Port // 当前使用的输出端口 ActivePort Port // 声卡的索引 Card uint32 // contains filtered or unexported fields }
func (*Sink) GetExportedMethods ¶
func (v *Sink) GetExportedMethods() dbusutil.ExportedMethods
func (*Sink) GetInterfaceName ¶
type SinkInput ¶
type SinkInput struct { PropsMu sync.RWMutex // Name process name Name string Icon string Mute bool Volume float64 Balance float64 SupportBalance bool Fade float64 SupportFade bool SinkIndex uint32 // contains filtered or unexported fields }
func (*SinkInput) GetExportedMethods ¶
func (v *SinkInput) GetExportedMethods() dbusutil.ExportedMethods
func (*SinkInput) GetInterfaceName ¶
func (*SinkInput) SetBalance ¶
type Source ¶
type Source struct { PropsMu sync.RWMutex Name string Description string // 默认的输入音量 BaseVolume float64 Mute bool Volume float64 Balance float64 SupportBalance bool Fade float64 SupportFade bool // dbusutil-gen: equal=portsEqual Ports []Port ActivePort Port // 声卡的索引 Card uint32 // contains filtered or unexported fields }
func (*Source) GetExportedMethods ¶
func (v *Source) GetExportedMethods() dbusutil.ExportedMethods
func (*Source) GetInterfaceName ¶
Source Files
¶
- alsa.go
- audio.go
- audio_config.go
- audio_dbusutil.go
- audio_events.go
- bluez_audio.go
- card.go
- card_profile_workaround.go
- config.go
- config_keeper.go
- exported_methods_auto.go
- meter.go
- module.go
- port.go
- priority_manager.go
- priority_old.go
- priority_policy.go
- profile.go
- sink.go
- sinkinput.go
- source.go
- sync_config.go
- util.go