output: Modules can keep track of option resources without wrapper help.

This commit is contained in:
Bert Vermeulen 2014-08-02 19:20:00 +02:00
parent 7ea75009d1
commit 950043c30e
6 changed files with 24 additions and 27 deletions

View File

@ -209,7 +209,7 @@ struct sr_output_module {
* If cached is TRUE, no new GVariants are created for the def and
* values fields; instead, the current values are returned.
*/
struct sr_option *(*options) (gboolean cached);
struct sr_option *(*options) (void);
/**
* This function is called once, at the beginning of an output stream.

View File

@ -260,13 +260,12 @@ static struct sr_option options[] = {
{ 0 }
};
static struct sr_option *get_options(gboolean cached)
static struct sr_option *get_options(void)
{
if (cached)
return options;
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
if (!options[0].def) {
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
}
return options;
}

View File

@ -246,13 +246,12 @@ static struct sr_option options[] = {
{ 0 }
};
static struct sr_option *get_options(gboolean cached)
static struct sr_option *get_options(void)
{
if (cached)
return options;
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
if (!options[0].def) {
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
}
return options;
}

View File

@ -261,13 +261,12 @@ static struct sr_option options[] = {
{ 0 }
};
static struct sr_option *get_options(gboolean cached)
static struct sr_option *get_options(void)
{
if (cached)
return options;
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
if (!options[0].def) {
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
g_variant_ref_sink(options[0].def);
}
return options;
}

View File

@ -166,7 +166,7 @@ SR_API const struct sr_option *sr_output_options_get(const struct sr_output_modu
if (!o || !o->options)
return NULL;
return o->options(FALSE);
return o->options();
}
/**
@ -182,7 +182,7 @@ SR_API void sr_output_options_free(const struct sr_output_module *o)
if (!o || !o->options)
return;
for (opt = o->options(TRUE); opt->id; opt++) {
for (opt = o->options(); opt->id; opt++) {
if (opt->def) {
g_variant_unref(opt->def);
opt->def = NULL;
@ -216,6 +216,7 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *o,
op = g_malloc(sizeof(struct sr_output));
op->module = o;
op->sdi = sdi;
if (op->module->init && op->module->init(op, options) != SR_OK) {
g_free(op);
op = NULL;

View File

@ -356,13 +356,12 @@ static struct sr_option options[] = {
{ 0 }
};
static struct sr_option *get_options(gboolean cached)
static 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_new_double(0);
g_variant_ref_sink(options[0].def);
}
return options;
}