output: Modules can keep track of option resources without wrapper help.
This commit is contained in:
parent
7ea75009d1
commit
950043c30e
|
@ -209,7 +209,7 @@ struct sr_output_module {
|
||||||
* If cached is TRUE, no new GVariants are created for the def and
|
* If cached is TRUE, no new GVariants are created for the def and
|
||||||
* values fields; instead, the current values are returned.
|
* 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.
|
* This function is called once, at the beginning of an output stream.
|
||||||
|
|
|
@ -260,13 +260,12 @@ static struct sr_option options[] = {
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sr_option *get_options(gboolean cached)
|
static struct sr_option *get_options(void)
|
||||||
{
|
{
|
||||||
if (cached)
|
if (!options[0].def) {
|
||||||
return options;
|
|
||||||
|
|
||||||
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
||||||
g_variant_ref_sink(options[0].def);
|
g_variant_ref_sink(options[0].def);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,13 +246,12 @@ static struct sr_option options[] = {
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sr_option *get_options(gboolean cached)
|
static struct sr_option *get_options(void)
|
||||||
{
|
{
|
||||||
if (cached)
|
if (!options[0].def) {
|
||||||
return options;
|
|
||||||
|
|
||||||
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
||||||
g_variant_ref_sink(options[0].def);
|
g_variant_ref_sink(options[0].def);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,13 +261,12 @@ static struct sr_option options[] = {
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sr_option *get_options(gboolean cached)
|
static struct sr_option *get_options(void)
|
||||||
{
|
{
|
||||||
if (cached)
|
if (!options[0].def) {
|
||||||
return options;
|
|
||||||
|
|
||||||
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
options[0].def = g_variant_new_uint32(DEFAULT_SAMPLES_PER_LINE);
|
||||||
g_variant_ref_sink(options[0].def);
|
g_variant_ref_sink(options[0].def);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ SR_API const struct sr_option *sr_output_options_get(const struct sr_output_modu
|
||||||
if (!o || !o->options)
|
if (!o || !o->options)
|
||||||
return NULL;
|
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)
|
if (!o || !o->options)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (opt = o->options(TRUE); opt->id; opt++) {
|
for (opt = o->options(); opt->id; opt++) {
|
||||||
if (opt->def) {
|
if (opt->def) {
|
||||||
g_variant_unref(opt->def);
|
g_variant_unref(opt->def);
|
||||||
opt->def = NULL;
|
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 = g_malloc(sizeof(struct sr_output));
|
||||||
op->module = o;
|
op->module = o;
|
||||||
op->sdi = sdi;
|
op->sdi = sdi;
|
||||||
|
|
||||||
if (op->module->init && op->module->init(op, options) != SR_OK) {
|
if (op->module->init && op->module->init(op, options) != SR_OK) {
|
||||||
g_free(op);
|
g_free(op);
|
||||||
op = NULL;
|
op = NULL;
|
||||||
|
|
|
@ -356,13 +356,12 @@ static struct sr_option options[] = {
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct sr_option *get_options(gboolean cached)
|
static struct sr_option *get_options(void)
|
||||||
{
|
{
|
||||||
if (cached)
|
if (!options[0].def) {
|
||||||
return options;
|
|
||||||
|
|
||||||
options[0].def = g_variant_new_double(0);
|
options[0].def = g_variant_new_double(0);
|
||||||
g_variant_ref_sink(options[0].def);
|
g_variant_ref_sink(options[0].def);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue