audio

package
v0.0.0-...-520a03a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CardBuildin   = 0
	CardBluethooh = 1
	CardUnknow    = 2

	PropDeviceFromFactor = "device.form_factor"
	PropDeviceBus        = "device.bus"
)
View Source
const (
	PortTypeBluetooth = iota
	PortTypeHeadset
	PortTypeSpeaker
	PortTypeHdmi
	PortTypeMultiChannel

	PortTypeCount // 类型数量
)
View Source
const (
	PropAppIconName      = "application.icon_name"
	PropAppName          = "application.name"
	PropAppProcessID     = "application.process.id"
	PropAppProcessBinary = "application.process.binary"
)

Variables

This section is empty.

Functions

func GetPortType

func GetPortType(cardName string, portName string) int

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
	CardsWithoutUnavailable string
	// dbusutil-gen: ignore
	IncreaseVolume gsprop.Bool `prop:"access:rw"`
	// dbusutil-gen: ignore
	ReduceNoise gsprop.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) GetInterfaceName() string

func (*Audio) IsPortEnabled

func (a *Audio) IsPortEnabled(cardId uint32, portName string) (enabled bool, busErr *dbus.Error)

func (*Audio) NoRestartPulseAudio

func (a *Audio) NoRestartPulseAudio() *dbus.Error

func (*Audio) Reset

func (a *Audio) Reset() *dbus.Error

func (*Audio) SetPort

func (a *Audio) SetPort(cardId uint32, portName string, direction int32) *dbus.Error

SetPort activate the port for the special card. The available sinks and sources will also change with the profile changing.

func (*Audio) SetPortEnabled

func (a *Audio) SetPortEnabled(cardId uint32, portName string, enabled bool) *dbus.Error

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 CardList

type CardList []*Card

type CardPortExport

type CardPortExport struct {
	Name        string
	Description string
	Direction   int
}

type ConfigKeeper

type ConfigKeeper struct {
	ConfigMap map[string]*CardConfig // Name => CardConfig
}

func NewConfigKeeper

func NewConfigKeeper() *ConfigKeeper

func (*ConfigKeeper) GetCardAndPortConfig

func (ck *ConfigKeeper) GetCardAndPortConfig(cardName string, portName string) (*CardConfig, *PortConfig)

func (*ConfigKeeper) Load

func (ck *ConfigKeeper) Load(file string) error

func (*ConfigKeeper) Print

func (ck *ConfigKeeper) Print()

func (*ConfigKeeper) RemoveCardConfig

func (ck *ConfigKeeper) RemoveCardConfig(cardName string)

func (*ConfigKeeper) Save

func (ck *ConfigKeeper) Save(file string) 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) SetMute

func (ck *ConfigKeeper) SetMute(cardName string, portName string, 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

type Meter struct {
	PropsMu sync.RWMutex
	Volume  float64
	// contains filtered or unexported fields
}

func (*Meter) GetExportedMethods

func (v *Meter) GetExportedMethods() dbusutil.ExportedMethods

func (*Meter) GetInterfaceName

func (*Meter) GetInterfaceName() string

func (*Meter) Tick

func (m *Meter) Tick() *dbus.Error

type Module

type Module struct {
	*loader.ModuleBase
	// contains filtered or unexported fields
}

func NewModule

func NewModule(logger *log.Logger) *Module

func (*Module) GetDependencies

func (*Module) GetDependencies() []string

func (*Module) Start

func (m *Module) Start() error

func (*Module) Stop

func (m *Module) Stop() error

func (*Module) WaitEnable

func (m *Module) WaitEnable()

type Port

type Port struct {
	Name        string
	Description string
	Available   byte // Unknow:0, No:1, Yes:2
}

func (*Port) String

func (p *Port) String() string

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 PortToken

type PortToken struct {
	CardName string
	PortName string
}

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 Profile

type Profile struct {
	Name        string
	Description string

	// The higher this value is, the more useful this profile is as a default.
	Priority uint32

	// 如果值是 0, 表示这个配置不可用,无法被激活
	// 如果值不为 0, 也不能保证此配置是可用的,它仅仅意味着不能肯定它是不可用的
	Available int
}

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

func (*Sink) GetInterfaceName() string

func (*Sink) GetMeter

func (s *Sink) GetMeter() (meter dbus.ObjectPath, busErr *dbus.Error)

func (*Sink) SetBalance

func (s *Sink) SetBalance(value float64, isPlay bool) *dbus.Error

设置左右声道平衡值

v: 声道平衡值

isPlay: 是否播放声音反馈

func (*Sink) SetFade

func (s *Sink) SetFade(value float64) *dbus.Error

设置前后声道平衡值

v: 声道平衡值

isPlay: 是否播放声音反馈

func (*Sink) SetMute

func (s *Sink) SetMute(value bool) *dbus.Error

是否静音

func (*Sink) SetPort

func (s *Sink) SetPort(name string) *dbus.Error

设置此设备的当前使用端口

func (*Sink) SetVolume

func (s *Sink) SetVolume(value float64, isPlay bool) *dbus.Error

设置音量大小

v: 音量大小

isPlay: 是否播放声音反馈

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) GetInterfaceName() string

func (*SinkInput) SetBalance

func (s *SinkInput) SetBalance(value float64, isPlay bool) *dbus.Error

func (*SinkInput) SetFade

func (s *SinkInput) SetFade(value float64) *dbus.Error

func (*SinkInput) SetMute

func (s *SinkInput) SetMute(value bool) *dbus.Error

func (*SinkInput) SetVolume

func (s *SinkInput) SetVolume(value float64, isPlay bool) *dbus.Error

type Skipper

type Skipper func(cardName string, portName string) bool

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

func (*Source) GetInterfaceName() string

func (*Source) GetMeter

func (s *Source) GetMeter() (meter dbus.ObjectPath, busErr *dbus.Error)

func (*Source) SetBalance

func (s *Source) SetBalance(value float64, isPlay bool) *dbus.Error

func (*Source) SetFade

func (s *Source) SetFade(value float64) *dbus.Error

func (*Source) SetMute

func (s *Source) SetMute(value bool) *dbus.Error

func (*Source) SetPort

func (s *Source) SetPort(name string) *dbus.Error

func (*Source) SetVolume

func (s *Source) SetVolume(value float64, isPlay bool) *dbus.Error

如何反馈输入音量?

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL