"alsatimer_get_devnode";
"alsatimer_get_device_id_list";
"alsatimer_get_device_info";
+ "alsatimer_get_device_status";
"alsatimer_device_id_get_type";
"alsatimer_device_id_new";
// SPDX-License-Identifier: LGPL-3.0-or-later
-#include "device-status.h"
-
-#include <sound/asound.h>
+#include "privates.h"
struct _ALSATimerDeviceStatusPrivate {
struct snd_timer_gstatus status;
{
return;
}
+
+void timer_device_status_refer_private(ALSATimerDeviceStatus *self,
+ struct snd_timer_gstatus **status)
+{
+ ALSATimerDeviceStatusPrivate *priv =
+ alsatimer_device_status_get_instance_private(self);
+
+ *status = &priv->status;
+}
#define __ALSA_GOBJECT_ALSATIMER_PRIVATES__H__
#include "device-info.h"
+#include "device-status.h"
#include <sound/asound.h>
void timer_device_info_refer_private(ALSATimerDeviceInfo *self,
struct snd_timer_ginfo **info);
+void timer_device_status_refer_private(ALSATimerDeviceStatus *self,
+ struct snd_timer_gstatus **status);
+
G_END_DECLS
#endif
close(fd);
}
+
+/**
+ * alsatimer_get_device_status:
+ * @device_id: A #ALSATimerDeviceId to identify the timer device.
+ * @device_status: (out): The status of timer device.
+ * @error: A #GError.
+ */
+void alsatimer_get_device_status(ALSATimerDeviceId *device_id,
+ ALSATimerDeviceStatus **device_status,
+ GError **error)
+{
+ char *devnode;
+ struct snd_timer_gstatus *status;
+ int fd;
+
+ g_return_if_fail(device_id != NULL);
+
+ alsatimer_get_devnode(&devnode, error);
+ if (*error != NULL)
+ return;
+
+ fd = open(devnode, O_RDONLY);
+ g_free(devnode);
+ if (fd < 0) {
+ generate_error(error, errno);
+ return;
+ }
+
+ *device_status = g_object_new(ALSATIMER_TYPE_DEVICE_STATUS, NULL);
+ timer_device_status_refer_private(*device_status, &status);
+
+ status->tid = *device_id;
+ if (ioctl(fd, SNDRV_TIMER_IOCTL_GSTATUS, status) < 0) {
+ generate_error(error, errno);
+ g_object_unref(*device_status);
+ }
+
+ close(fd);
+}
#include <timer/device-id.h>
#include <timer/device-info.h>
+#include <timer/device-status.h>
#include <timer/alsatimer-enums.h>
void alsatimer_get_device_info(ALSATimerDeviceId *device_id,
ALSATimerDeviceInfo **device_info,
GError **error);
+
+void alsatimer_get_device_status(ALSATimerDeviceId *device_id,
+ ALSATimerDeviceStatus **device_status,
+ GError **error);
+
G_END_DECLS
#endif