This fixes parts of bug #570.
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,
shared_ptr<Device> device, map<string, Glib::VariantBase> options) :
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),
_device(device),
_options(options)
/** Create an output using this format.
* @param device Device to output for.
* @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>());
protected:
Output(shared_ptr<OutputFormat> format, shared_ptr<Device> device);
Output(shared_ptr<OutputFormat> format,
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();
const shared_ptr<OutputFormat> _format;
const shared_ptr<Device> _device;
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 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,
const struct sr_datafeed_packet *packet, GString **out);
SR_API int sr_output_free(const struct sr_output *o);
*/
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
* state between calls into its callback functions.
* @since 0.4.0
*/
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;
const struct sr_option *mod_opts;
op = g_malloc(sizeof(struct sr_output));
op->module = omod;
op->sdi = sdi;
+ op->filename = g_strdup(filename);
new_opts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)g_variant_unref);
ret = SR_OK;
if (o->module->cleanup)
ret = o->module->cleanup((struct sr_output *)o);
+ g_free((char *)o->filename);
g_free((gpointer)o);
return ret;