]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: instance-params: rewrite public API to return gboolean according to GNOME...
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 31 May 2022 01:41:31 +0000 (10:41 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Tue, 31 May 2022 02:31:59 +0000 (11:31 +0900)
In GNOME convention, the throw function to report error at GError argument
should return gboolean value to report the overall operation finishes
successfully or not.

This commit rewrite such public APIs with loss of backward compatibility.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/instance-params.c
src/timer/instance-params.h

index 3b27cb455c8a2439b3df5464e60da76a7ab663bf..e76ffd1ad7f7a6b0b7d4fd41b00e5465f609036a 100644 (file)
@@ -132,8 +132,10 @@ ALSATimerInstanceParams *alsatimer_instance_params_new()
  *
  * Set the list of [enum@EventType] to filter events. This parameter is effective only for target
  * instance with [enum@EventDataType:TIMESTAMP].
+ *
+ * Returns: %TRUE when the overall operation finishes successfully, else %FALSE.
  */
-void alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
+gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
                                             const ALSATimerEventType *entries,
                                             gsize entry_count, GError **error)
 {
@@ -141,17 +143,17 @@ void alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
     unsigned int filter;
     int i;
 
-    g_return_if_fail(ALSATIMER_IS_INSTANCE_PARAMS(self));
+    g_return_val_if_fail(ALSATIMER_IS_INSTANCE_PARAMS(self), FALSE);
     priv = alsatimer_instance_params_get_instance_private(self);
 
-    g_return_if_fail(entries != NULL);
-    g_return_if_fail(error == NULL || *error == NULL);
+    g_return_val_if_fail(entries != NULL, FALSE);
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
 
     priv->params.filter = 0;
 
     // Clear the event filter.
     if (entries == NULL || entry_count == 0)
-        return;
+        return TRUE;
 
     filter = 0;
     for (i = 0; i < entry_count; ++i) {
@@ -160,12 +162,13 @@ void alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
             (val > SNDRV_TIMER_EVENT_RESUME &&
              val < SNDRV_TIMER_EVENT_MSTART) ||
             val > SNDRV_TIMER_EVENT_MRESUME) {
-            g_return_if_reached();
+            g_return_val_if_reached(FALSE);
         }
         filter |= (1u << val);
     }
 
     priv->params.filter = filter;
+    return TRUE;
 }
 
 /**
@@ -177,8 +180,10 @@ void alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
  *
  * Get the list of ALSATimerEventType to filter events. This parameter is effective only for target
  * instance with [enum@EventDataType:TIMESTAMP].
+ *
+ * Returns: %TRUE when the overall operation finishes successfully, else %FALSE.
  */
-void alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
+gboolean alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
                                             ALSATimerEventType **entries,
                                             gsize *entry_count, GError **error)
 {
@@ -189,12 +194,12 @@ void alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
     unsigned int index;
     int i;
 
-    g_return_if_fail(ALSATIMER_IS_INSTANCE_PARAMS(self));
+    g_return_val_if_fail(ALSATIMER_IS_INSTANCE_PARAMS(self), FALSE);
     priv = alsatimer_instance_params_get_instance_private(self);
 
-    g_return_if_fail(entries != NULL);
-    g_return_if_fail(entry_count != NULL);
-    g_return_if_fail(error == NULL || *error == NULL);
+    g_return_val_if_fail(entries != NULL, FALSE);
+    g_return_val_if_fail(entry_count != NULL, FALSE);
+    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
 
     count = 0;
     filter = priv->params.filter;
@@ -204,7 +209,7 @@ void alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
     }
 
     if (count == 0)
-        return;
+        return TRUE;
 
     list = g_malloc0_n(count, sizeof(*list));
 
@@ -221,6 +226,7 @@ void alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
 
     *entries = list;
     *entry_count = count;
+    return TRUE;
 }
 
 void timer_instance_params_refer_private(ALSATimerInstanceParams *self,
index fc4e00d0ecd7329545e2cf528d03e1af6b1d3e25..5ba060ab54ec6c5705aecbf88b50abd696ce255c 100644 (file)
@@ -17,11 +17,11 @@ struct _ALSATimerInstanceParamsClass {
 
 ALSATimerInstanceParams *alsatimer_instance_params_new();
 
-void alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
+gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self,
                                             const ALSATimerEventType *entries,
                                             gsize entry_count, GError **error);
 
-void alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
+gboolean alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self,
                                             ALSATimerEventType **entries,
                                             gsize *entry_count, GError **error);