From c8a196603a86280e155fcac5332211b381354e40 Mon Sep 17 00:00:00 2001 From: Binozo Date: Tue, 26 Dec 2023 14:03:48 +0100 Subject: [PATCH] made public IsReady device api --- pkg/tinyalsa/device.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/tinyalsa/device.go b/pkg/tinyalsa/device.go index 14e1e21..9c1ddc7 100644 --- a/pkg/tinyalsa/device.go +++ b/pkg/tinyalsa/device.go @@ -54,6 +54,16 @@ func (d *AlsaDevice) GetInfo() DeviceInfo { } } +// IsReady returns if the device is ready +func (d *AlsaDevice) IsReady(format int) (bool, error) { + pcmDevice, err := tinyapi.PcmOpen(d.Card, d.Device, format, d.DeviceConfig) + if err != nil { + return false, err + } + defer pcmDevice.Close() + return pcmDevice.IsReady(), nil +} + // WaitUntilReady waits until the device is ready or the timeout expired // If successful, nil will be returned. Otherwise, an error func (d *AlsaDevice) WaitUntilReady(format int, timeout time.Duration) error {