Add filename field to sr_output and make it accessible
This fixes parts of bug #570.
This commit is contained in:
parent
176c7219bb
commit
81b3ce374c
|
@ -1565,10 +1565,28 @@ shared_ptr<Output> OutputFormat::create_output(
|
||||||
Output::Deleter());
|
Output::Deleter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_ptr<Output> OutputFormat::create_output(string filename,
|
||||||
|
shared_ptr<Device> device, map<string, Glib::VariantBase> options)
|
||||||
|
{
|
||||||
|
return shared_ptr<Output>(
|
||||||
|
new Output(filename, shared_from_this(), device, options),
|
||||||
|
Output::Deleter());
|
||||||
|
}
|
||||||
|
|
||||||
Output::Output(shared_ptr<OutputFormat> format,
|
Output::Output(shared_ptr<OutputFormat> format,
|
||||||
shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
|
shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
|
||||||
UserOwned(sr_output_new(format->_structure,
|
UserOwned(sr_output_new(format->_structure,
|
||||||
map_to_hash_variant(options), device->_structure)),
|
map_to_hash_variant(options), device->_structure, NULL)),
|
||||||
|
_format(format),
|
||||||
|
_device(device),
|
||||||
|
_options(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Output::Output(string filename, shared_ptr<OutputFormat> format,
|
||||||
|
shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
|
||||||
|
UserOwned(sr_output_new(format->_structure,
|
||||||
|
map_to_hash_variant(options), device->_structure, filename.c_str())),
|
||||||
_format(format),
|
_format(format),
|
||||||
_device(device),
|
_device(device),
|
||||||
_options(options)
|
_options(options)
|
||||||
|
|
|
@ -957,7 +957,16 @@ public:
|
||||||
/** Create an output using this format.
|
/** Create an output using this format.
|
||||||
* @param device Device to output for.
|
* @param device Device to output for.
|
||||||
* @param options Mapping of (option name, value) pairs. */
|
* @param options Mapping of (option name, value) pairs. */
|
||||||
shared_ptr<Output> create_output(shared_ptr<Device> device,
|
shared_ptr<Output> create_output(
|
||||||
|
shared_ptr<Device> device,
|
||||||
|
map<string, Glib::VariantBase> options =
|
||||||
|
map<string, Glib::VariantBase>());
|
||||||
|
/** Create an output using this format.
|
||||||
|
* @param filename Name of destination file.
|
||||||
|
* @param device Device to output for.
|
||||||
|
* @param options Mapping of (option name, value) pairs. */
|
||||||
|
shared_ptr<Output> create_output(string filename,
|
||||||
|
shared_ptr<Device> device,
|
||||||
map<string, Glib::VariantBase> options =
|
map<string, Glib::VariantBase> options =
|
||||||
map<string, Glib::VariantBase>());
|
map<string, Glib::VariantBase>());
|
||||||
protected:
|
protected:
|
||||||
|
@ -978,6 +987,8 @@ protected:
|
||||||
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
|
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
|
||||||
Output(shared_ptr<OutputFormat> format,
|
Output(shared_ptr<OutputFormat> format,
|
||||||
shared_ptr<Device> device, map<string, Glib::VariantBase> options);
|
shared_ptr<Device> device, map<string, Glib::VariantBase> options);
|
||||||
|
Output(string filename, shared_ptr<OutputFormat> format,
|
||||||
|
shared_ptr<Device> device, map<string, Glib::VariantBase> options);
|
||||||
~Output();
|
~Output();
|
||||||
const shared_ptr<OutputFormat> _format;
|
const shared_ptr<OutputFormat> _format;
|
||||||
const shared_ptr<Device> _device;
|
const shared_ptr<Device> _device;
|
||||||
|
|
|
@ -177,7 +177,8 @@ SR_API const struct sr_output_module *sr_output_find(char *id);
|
||||||
SR_API const struct sr_option **sr_output_options_get(const struct sr_output_module *omod);
|
SR_API const struct sr_option **sr_output_options_get(const struct sr_output_module *omod);
|
||||||
SR_API void sr_output_options_free(const struct sr_option **opts);
|
SR_API void sr_output_options_free(const struct sr_option **opts);
|
||||||
SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod,
|
SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod,
|
||||||
GHashTable *params, const struct sr_dev_inst *sdi);
|
GHashTable *params, const struct sr_dev_inst *sdi,
|
||||||
|
const char *filename);
|
||||||
SR_API int sr_output_send(const struct sr_output *o,
|
SR_API int sr_output_send(const struct sr_output *o,
|
||||||
const struct sr_datafeed_packet *packet, GString **out);
|
const struct sr_datafeed_packet *packet, GString **out);
|
||||||
SR_API int sr_output_free(const struct sr_output *o);
|
SR_API int sr_output_free(const struct sr_output *o);
|
||||||
|
|
|
@ -368,6 +368,11 @@ struct sr_output {
|
||||||
*/
|
*/
|
||||||
const struct sr_dev_inst *sdi;
|
const struct sr_dev_inst *sdi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the file that the data should be written to.
|
||||||
|
*/
|
||||||
|
const char *filename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic pointer which can be used by the module to keep internal
|
* A generic pointer which can be used by the module to keep internal
|
||||||
* state between calls into its callback functions.
|
* state between calls into its callback functions.
|
||||||
|
|
|
@ -245,7 +245,8 @@ SR_API void sr_output_options_free(const struct sr_option **options)
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod,
|
SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod,
|
||||||
GHashTable *options, const struct sr_dev_inst *sdi)
|
GHashTable *options, const struct sr_dev_inst *sdi,
|
||||||
|
const char *filename)
|
||||||
{
|
{
|
||||||
struct sr_output *op;
|
struct sr_output *op;
|
||||||
const struct sr_option *mod_opts;
|
const struct sr_option *mod_opts;
|
||||||
|
@ -258,6 +259,7 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod
|
||||||
op = g_malloc(sizeof(struct sr_output));
|
op = g_malloc(sizeof(struct sr_output));
|
||||||
op->module = omod;
|
op->module = omod;
|
||||||
op->sdi = sdi;
|
op->sdi = sdi;
|
||||||
|
op->filename = g_strdup(filename);
|
||||||
|
|
||||||
new_opts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
|
new_opts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
|
||||||
(GDestroyNotify)g_variant_unref);
|
(GDestroyNotify)g_variant_unref);
|
||||||
|
@ -335,6 +337,7 @@ SR_API int sr_output_free(const struct sr_output *o)
|
||||||
ret = SR_OK;
|
ret = SR_OK;
|
||||||
if (o->module->cleanup)
|
if (o->module->cleanup)
|
||||||
ret = o->module->cleanup((struct sr_output *)o);
|
ret = o->module->cleanup((struct sr_output *)o);
|
||||||
|
g_free((char *)o->filename);
|
||||||
g_free((gpointer)o);
|
g_free((gpointer)o);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue