]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: use (inout) annotation to retrieve the status of instance
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 15 Jun 2020 02:41:48 +0000 (11:41 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Mon, 15 Jun 2020 08:30:38 +0000 (17:30 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/user-instance.c
src/timer/user-instance.h

index 158d071879432bfd16af9d89de85078f4f3496b8..9c92ebc2a546dad2295490d86e39dbac6c39833f 100644 (file)
@@ -301,7 +301,7 @@ void alsatimer_user_instance_set_params(ALSATimerUserInstance *self,
 /**
  * alsatimer_user_instance_get_status:
  * @self: A #ALSATimerUserInstance.
- * @instance_status: (out): A #ALSATimerInstanceStatus.
+ * @instance_status: (inout): A #ALSATimerInstanceStatus.
  * @error: A #GError.
  *
  * Get the latest status of instance.
@@ -310,8 +310,8 @@ void alsatimer_user_instance_set_params(ALSATimerUserInstance *self,
  * SNDRV_TIMER_IOCTL_STATUS command for ALSA timer character device.
  */
 void alsatimer_user_instance_get_status(ALSATimerUserInstance *self,
-                                    ALSATimerInstanceStatus **instance_status,
-                                    GError **error)
+                                ALSATimerInstanceStatus *const *instance_status,
+                                GError **error)
 {
     ALSATimerUserInstancePrivate *priv;
     struct snd_timer_status *status;
@@ -319,13 +319,11 @@ void alsatimer_user_instance_get_status(ALSATimerUserInstance *self,
     g_return_if_fail(ALSATIMER_IS_USER_INSTANCE(self));
     priv = alsatimer_user_instance_get_instance_private(self);
 
-    *instance_status = g_object_new(ALSATIMER_TYPE_INSTANCE_STATUS, NULL);
+    g_return_if_fail(ALSATIMER_IS_INSTANCE_STATUS(*instance_status));
     timer_instance_status_refer_private(*instance_status, &status);
 
-    if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_STATUS, status) < 0) {
+    if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_STATUS, status) < 0)
         generate_error(error, errno);
-        g_object_unref(*instance_status);
-    }
 }
 
 static gboolean timer_user_instance_check_src(GSource *gsrc)
index 7ceab6fa5ae522750698cfce34e3bd056e8b2cd0..1ea4478f5593527601713162d06d2114e652dc96 100644 (file)
@@ -99,8 +99,8 @@ void alsatimer_user_instance_set_params(ALSATimerUserInstance *self,
                                 GError **error);
 
 void alsatimer_user_instance_get_status(ALSATimerUserInstance *self,
-                                    ALSATimerInstanceStatus **instance_status,
-                                    GError **error);
+                                ALSATimerInstanceStatus *const *instance_status,
+                                GError **error);
 
 void alsatimer_user_instance_create_source(ALSATimerUserInstance *self,
                                          GSource **gsrc, GError **error);