]> sigrok.org Git - libsigrok.git/blobdiff - src/session.c
Doxygen: Properly mark a few symbols as private.
[libsigrok.git] / src / session.c
index 0620b222b2cafa37b596d9011be2964d1320887b..7e4bfbb3144012eefe7a1ca28099367a36e1cbc0 100644 (file)
@@ -53,7 +53,6 @@ struct datafeed_callback {
 
 /** Custom GLib event source for generic descriptor I/O.
  * @see https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
- * @internal
  */
 struct fd_source {
        GSource base;
@@ -1071,6 +1070,42 @@ static void datafeed_dump(const struct sr_datafeed_packet *packet)
        }
 }
 
+/**
+ * Helper to send a meta datafeed package (SR_DF_META) to the session bus.
+ *
+ * @param sdi The device instance to send the package from. Must not be NULL.
+ * @param key The config key to send to the session bus.
+ * @param var The value to send to the session bus.
+ *
+ * @retval SR_OK Success.
+ * @retval SR_ERR_ARG Invalid argument.
+ *
+ * @private
+ */
+SR_PRIV int sr_session_send_meta(const struct sr_dev_inst *sdi,
+               uint32_t key, GVariant *var)
+{
+       struct sr_config *cfg;
+       struct sr_datafeed_packet packet;
+       struct sr_datafeed_meta meta;
+       int ret;
+
+       cfg = sr_config_new(key, var);
+
+       memset(&meta, 0, sizeof(meta));
+
+       packet.type = SR_DF_META;
+       packet.payload = &meta;
+
+       meta.config = g_slist_append(NULL, cfg);
+
+       ret = sr_session_send(sdi, &packet);
+       g_slist_free(meta.config);
+       sr_config_free(cfg);
+
+       return ret;
+}
+
 /**
  * Send a packet to whatever is listening on the datafeed bus.
  *
@@ -1294,7 +1329,7 @@ SR_PRIV int sr_session_source_add_channel(struct sr_session *session,
        /* We should be using g_io_create_watch(), but can't without
         * changing the driver API, as the callback signature is different.
         */
-#ifdef G_OS_WIN32
+#ifdef _WIN32
        g_io_channel_win32_make_pollfd(channel, events, &pollfd);
 #else
        pollfd.fd = g_io_channel_unix_get_fd(channel);
@@ -1450,8 +1485,7 @@ static void copy_src(struct sr_config *src, struct sr_datafeed_meta *meta_copy)
                                           g_memdup(src, sizeof(struct sr_config)));
 }
 
-/** @private */
-SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
+SR_API int sr_packet_copy(const struct sr_datafeed_packet *packet,
                struct sr_datafeed_packet **copy)
 {
        const struct sr_datafeed_meta *meta;
@@ -1489,8 +1523,10 @@ SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
                logic_copy->length = logic->length;
                logic_copy->unitsize = logic->unitsize;
                logic_copy->data = g_malloc(logic->length * logic->unitsize);
-               if (!logic_copy->data)
+               if (!logic_copy->data) {
+                       g_free(logic_copy);
                        return SR_ERR;
+               }
                memcpy(logic_copy->data, logic->data, logic->length * logic->unitsize);
                (*copy)->payload = logic_copy;
                break;
@@ -1520,7 +1556,7 @@ SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
        return SR_OK;
 }
 
-void sr_packet_free(struct sr_datafeed_packet *packet)
+SR_API void sr_packet_free(struct sr_datafeed_packet *packet)
 {
        const struct sr_datafeed_meta *meta;
        const struct sr_datafeed_logic *logic;
@@ -1565,7 +1601,6 @@ void sr_packet_free(struct sr_datafeed_packet *packet)
                sr_err("Unknown packet type %d", packet->type);
        }
        g_free(packet);
-
 }
 
 /** @} */