Skip to content

Commit dd586bd

Browse files
authored
Merge pull request #69 from tphakala/expose-internal-device-properties
Expose internal device properties from audio backend
2 parents cf63d8f + 61e90e8 commit dd586bd

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

device.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,46 @@ func (dev *Device) SampleRate() uint32 {
101101
return uint32(dev.cptr().sampleRate)
102102
}
103103

104+
// CaptureInternalSampleRate returns the sample rate negotiated with the audio
105+
// backend for capture. This may differ from SampleRate() when the backend
106+
// cannot honor the requested rate, for example when ALSA's dsnoop plugin locks
107+
// the hardware at a fixed rate and resamples in software.
108+
func (dev *Device) CaptureInternalSampleRate() uint32 {
109+
return uint32(dev.cptr().capture.internalSampleRate)
110+
}
111+
112+
// PlaybackInternalSampleRate returns the sample rate negotiated with the audio
113+
// backend for playback.
114+
func (dev *Device) PlaybackInternalSampleRate() uint32 {
115+
return uint32(dev.cptr().playback.internalSampleRate)
116+
}
117+
118+
// CaptureInternalFormat returns the sample format negotiated with the audio
119+
// backend for capture. This may differ from CaptureFormat() when the backend
120+
// performs format conversion internally.
121+
func (dev *Device) CaptureInternalFormat() FormatType {
122+
return FormatType(dev.cptr().capture.internalFormat)
123+
}
124+
125+
// PlaybackInternalFormat returns the sample format negotiated with the audio
126+
// backend for playback.
127+
func (dev *Device) PlaybackInternalFormat() FormatType {
128+
return FormatType(dev.cptr().playback.internalFormat)
129+
}
130+
131+
// CaptureInternalChannels returns the channel count negotiated with the audio
132+
// backend for capture. This may differ from CaptureChannels() when the backend
133+
// performs channel conversion internally.
134+
func (dev *Device) CaptureInternalChannels() uint32 {
135+
return uint32(dev.cptr().capture.internalChannels)
136+
}
137+
138+
// PlaybackInternalChannels returns the channel count negotiated with the audio
139+
// backend for playback.
140+
func (dev *Device) PlaybackInternalChannels() uint32 {
141+
return uint32(dev.cptr().playback.internalChannels)
142+
}
143+
104144
// Start activates the device.
105145
// For playback devices this begins playback. For capture devices it begins recording.
106146
//

0 commit comments

Comments
 (0)