+ const auto context = session_.device_manager().context();
+ auto device = session_.device()->device();
+
+ map<string, Glib::VariantBase> options = options_;
+
+ // If the output has the capability to write files, use it.
+ // Otherwise, open the output stream.
+ const auto opt_list = output_format_->options();
+ if (opt_list.find("filename") != opt_list.end())
+ options["filename"] =
+ Glib::Variant<Glib::ustring>::create(file_name_);
+ else
+ output_stream_.open(file_name_, ios_base::binary |
+ ios_base::trunc | ios_base::out);
+
+ output_ = output_format_->create_output(device, options);
+ auto meta = context->create_meta_packet(
+ {{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
+ segment->samplerate())}});
+ output_->receive(meta);