]> sigrok.org Git - libsigrok.git/blobdiff - output/text/text.c
Rename 'struct sr_probe' to 'struct sr_channel' everywhere.
[libsigrok.git] / output / text / text.c
index a2b8b20ec0962ee2baf11e000d5e549c2ecb57e9..54350b88ffcc5de394108eb4f56cff824d5b15f3 100644 (file)
 #include "libsigrok-internal.h"
 #include "text.h"
 
-/* Message logging helpers with subsystem-specific prefix string. */
-#define LOG_PREFIX "output/text: "
-#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
-#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
-#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
-#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
-#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
-#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
+#define LOG_PREFIX "output/text"
 
 SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
 {
@@ -81,7 +74,7 @@ SR_PRIV void flush_linebufs(struct context *ctx, uint8_t *outbuf)
 SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
 {
        struct context *ctx;
-       struct sr_probe *probe;
+       struct sr_channel *probe;
        GSList *l;
        GVariant *gvar;
        uint64_t samplerate;
@@ -99,6 +92,8 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
 
        for (l = o->sdi->probes; l; l = l->next) {
                probe = l->data;
+               if (probe->type != SR_PROBE_LOGIC)
+                       continue;
                if (!probe->enabled)
                        continue;
                ctx->probenames = g_slist_append(ctx->probenames, probe->name);
@@ -129,8 +124,8 @@ SR_PRIV int init(struct sr_output *o, int default_spl, enum outputmode mode)
 
        snprintf(ctx->header, 511, "%s\n", PACKAGE_STRING);
        num_probes = g_slist_length(o->sdi->probes);
-       if (sr_config_get(o->sdi->driver, SR_CONF_SAMPLERATE, &gvar,
-                       o->sdi) == SR_OK) {
+       if (sr_config_get(o->sdi->driver, o->sdi, NULL, SR_CONF_SAMPLERATE,
+                       &gvar) == SR_OK) {
                samplerate = g_variant_get_uint64(gvar);
                g_variant_unref(gvar);
                if (!(samplerate_s = sr_samplerate_string(samplerate))) {
@@ -171,6 +166,31 @@ err:
        return ret;
 }
 
+SR_PRIV int text_cleanup(struct sr_output *o)
+{
+       struct context *ctx;
+
+       if (!o)
+               return SR_ERR_ARG;
+
+       ctx = o->internal;
+
+       g_free(ctx->header);
+       g_free(ctx->linebuf);
+       g_free(ctx->linevalues);
+
+       if (ctx->prevsample)
+               g_free(ctx->prevsample);
+
+       g_slist_free(ctx->probenames);
+
+       g_free(ctx);
+
+       o->internal = NULL;
+
+       return SR_OK;
+}
+
 SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
                  uint64_t *length_out)
 {
@@ -195,8 +215,6 @@ SR_PRIV int event(struct sr_output *o, int event_type, uint8_t **data_out,
                flush_linebufs(ctx, outbuf);
                *data_out = outbuf;
                *length_out = strlen((const char *)outbuf);
-               g_free(o->internal);
-               o->internal = NULL;
                break;
        default:
                *data_out = NULL;