X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fsession.c;h=5e48f4a5aeee5b1aafaf5ea1e2d595d407f6a2c0;hb=6762401d2b992a7b10585653ab07ccf1a336fe05;hp=b3fdfb54a2451b0ac506b0f82b452fda30ad6807;hpb=3bae09ab9fc3681e0ae3d2f16e862c831d43efc3;p=libsigrok.git diff --git a/src/session.c b/src/session.c index b3fdfb54..5e48f4a5 100644 --- a/src/session.c +++ b/src/session.c @@ -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; @@ -158,7 +157,9 @@ static void fd_source_finalize(GSource *source) * @param session The session the event source belongs to. * @param key The key used to identify this source. * @param fd The file descriptor or HANDLE. + * @param events Events. * @param timeout_ms The timeout interval in ms, or -1 to wait indefinitely. + * * @return A new event source object, or NULL on failure. */ static GSource *fd_source_new(struct sr_session *session, void *key, @@ -1071,6 +1072,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. *