Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ func NewVirtioSoundDeviceHostInputStreamConfiguration() (*VirtioSoundDeviceHostI
return config, nil
}

// VirtioSoundDeviceOutputStreamConfiguration defines a PCM output stream whose
// audio is suppressed by the host. Virtualization keeps the stream clocked while
// discarding the samples when no sink is configured.
type VirtioSoundDeviceOutputStreamConfiguration struct {
*pointer

*baseVirtioSoundDeviceStreamConfiguration
}

var _ VirtioSoundDeviceStreamConfiguration = (*VirtioSoundDeviceOutputStreamConfiguration)(nil)

// NewVirtioSoundDeviceOutputStreamConfiguration creates a new sound device
// output stream configuration without a host audio sink.
//
// This is only supported on macOS 12 and newer, error will be returned
// on older versions.
func NewVirtioSoundDeviceOutputStreamConfiguration() (*VirtioSoundDeviceOutputStreamConfiguration, error) {
if err := macOSAvailable(12); err != nil {
return nil, err
}
config := &VirtioSoundDeviceOutputStreamConfiguration{
pointer: objc.NewPointer(
C.newVZVirtioSoundDeviceOutputStreamConfiguration(),
),
}
objc.SetFinalizer(config, func(self *VirtioSoundDeviceOutputStreamConfiguration) {
objc.Release(self)
})
return config, nil
}

// VirtioSoundDeviceHostOutputStreamConfiguration is a struct that
// defines a Virtio host sound device output stream configuration.
//
Expand Down
4 changes: 4 additions & 0 deletions osversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func TestAvailableVersion(t *testing.T) {
_, err := NewVirtioSoundDeviceHostInputStreamConfiguration()
return err
},
"NewVirtioSoundDeviceOutputStreamConfiguration": func() error {
_, err := NewVirtioSoundDeviceOutputStreamConfiguration()
return err
},
"NewVirtioSoundDeviceHostOutputStreamConfiguration": func() error {
_, err := NewVirtioSoundDeviceHostOutputStreamConfiguration()
return err
Expand Down