X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fsession.c;h=0940617c12582076376a1999cd1ccc50e2464d03;hb=965261008009e41e9f89efe416ed1ae5d23aadaf;hp=16fdfffa4bf945872bb3f8004346f76018cae4a6;hpb=00f0016cc361008cd9eb2e52fd2a01f333c0e3cd;p=libsigrok.git diff --git a/src/session.c b/src/session.c index 16fdfffa..0940617c 100644 --- a/src/session.c +++ b/src/session.c @@ -1071,6 +1071,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. * @@ -1450,8 +1486,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; @@ -1522,7 +1557,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; @@ -1567,7 +1602,6 @@ void sr_packet_free(struct sr_datafeed_packet *packet) sr_err("Unknown packet type %d", packet->type); } g_free(packet); - } /** @} */