X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Foutput%2Fwav.c;h=fb809500c5e3b7b776c555c9fe7b9b3810cde104;hb=98654c99daf85bd2a81a9c87f517e800c31e34f2;hp=61d184ccb5ce52333ce266605b7588022287f22c;hpb=7ea75009d1977874efb686b000516c4ce1343474;p=libsigrok.git
diff --git a/src/output/wav.c b/src/output/wav.c
index 61d184cc..fb809500 100644
--- a/src/output/wav.c
+++ b/src/output/wav.c
@@ -17,8 +17,9 @@
* along with this program. If not, see .
*/
+#include
#include
-#include "libsigrok.h"
+#include
#include "libsigrok-internal.h"
#define LOG_PREFIX "output/wav"
@@ -91,28 +92,10 @@ static int init(struct sr_output *o, GHashTable *options)
struct out_context *outc;
struct sr_channel *ch;
GSList *l;
- GHashTableIter iter;
- gpointer key, value;
outc = g_malloc0(sizeof(struct out_context));
o->priv = outc;
-
- outc->scale = 0.0;
- if (options) {
- g_hash_table_iter_init(&iter, options);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- if (!strcmp(key, "scale")) {
- if (!g_variant_is_of_type(value, G_VARIANT_TYPE_DOUBLE)) {
- sr_err("Invalid type for 'scale' option.");
- return SR_ERR_ARG;
- }
- outc->scale = g_variant_get_double(value);
- } else {
- sr_err("Unknown option '%s'.", key);
- return SR_ERR_ARG;
- }
- }
- }
+ outc->scale = g_variant_get_double(g_hash_table_lookup(options, "scale"));
for (l = o->sdi->channels; l; l = l->next) {
ch = l->data;
@@ -247,6 +230,7 @@ static int check_chanbuf_size(const struct sr_output *o)
return size;
}
+
static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet,
GString **out)
{
@@ -353,16 +337,13 @@ static int cleanup(struct sr_output *o)
static struct sr_option options[] = {
{ "scale", "Scale", "Scale values by factor", NULL, NULL },
- { 0 }
+ ALL_ZERO
};
-static struct sr_option *get_options(gboolean cached)
+static const struct sr_option *get_options(void)
{
- if (cached)
- return options;
-
- options[0].def = g_variant_new_double(0);
- g_variant_ref_sink(options[0].def);
+ if (!options[0].def)
+ options[0].def = g_variant_ref_sink(g_variant_new_double(0.0));
return options;
}
@@ -370,10 +351,11 @@ static struct sr_option *get_options(gboolean cached)
SR_PRIV struct sr_output_module output_wav = {
.id = "wav",
.name = "WAV",
- .desc = "WAVE file format",
+ .desc = "Microsoft WAV file format",
+ .exts = (const char*[]){"wav", NULL},
+ .flags = 0,
.options = get_options,
.init = init,
.receive = receive,
.cleanup = cleanup,
};
-