X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=input%2Fwav.c;h=1c3f050a050434ea040f64b7b1c974d520377bc1;hb=64fe661b87c119079516b9ba7b395bdd8af14994;hp=c5b573caeb99af93b650356ec3da12a77f92e72c;hpb=1d36b4d27f737dfcd6e232bc9d9538bd64bf1afb;p=libsigrok.git diff --git a/input/wav.c b/input/wav.c index c5b573ca..1c3f050a 100644 --- a/input/wav.c +++ b/input/wav.c @@ -1,5 +1,5 @@ /* - * This file is part of the sigrok project. + * This file is part of the libsigrok project. * * Copyright (C) 2013 Bert Vermeulen * @@ -25,14 +25,7 @@ #include "libsigrok.h" #include "libsigrok-internal.h" -/* Message logging helpers with driver-specific prefix string. */ -#define DRIVER_LOG_DOMAIN "input/wav: " -#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) -#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) -#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) -#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) -#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) -#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) +#define LOG_PREFIX "input/wav" #define CHUNK_SIZE 4096 @@ -92,9 +85,9 @@ static int format_match(const char *filename) static int init(struct sr_input *in, const char *filename) { - struct sr_probe *probe; + struct sr_channel *ch; struct context *ctx; - char buf[40], probename[8]; + char buf[40], channelname[8]; int i; if (get_wav_header(filename, buf) != SR_OK) @@ -120,10 +113,10 @@ static int init(struct sr_input *in, const char *filename) } for (i = 0; i < ctx->num_channels; i++) { - snprintf(probename, 8, "CH%d", i + 1); - if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, probename))) + snprintf(channelname, 8, "CH%d", i + 1); + if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, channelname))) return SR_ERR; - in->sdi->probes = g_slist_append(in->sdi->probes, probe); + in->sdi->channels = g_slist_append(in->sdi->channels, ch); } return SR_OK; @@ -144,13 +137,15 @@ static int loadfile(struct sr_input *in, const char *filename) ctx = in->sdi->priv; /* Send header packet to the session bus. */ - std_session_send_df_header(in->sdi, DRIVER_LOG_DOMAIN); + std_session_send_df_header(in->sdi, LOG_PREFIX); packet.type = SR_DF_META; packet.payload = &meta; - src = sr_config_make(SR_CONF_SAMPLERATE, (const void *)&ctx->samplerate); + src = sr_config_new(SR_CONF_SAMPLERATE, + g_variant_new_uint64(ctx->samplerate)); meta.config = g_slist_append(NULL, src); sr_session_send(in->sdi, &packet); + sr_config_free(src); if ((fd = open(filename, O_RDONLY)) == -1) return SR_ERR; @@ -183,7 +178,7 @@ static int loadfile(struct sr_input *in, const char *filename) } packet.type = SR_DF_ANALOG; packet.payload = &analog; - analog.probes = in->sdi->probes; + analog.channels = in->sdi->channels; analog.num_samples = chunk_samples; analog.mq = 0; analog.unit = 0;