- if (sr_session_save_init(SigSession::_sr_session, _file_name.c_str(),
- data->samplerate(), channels) != SR_OK) {
- _error = tr("Error while saving.");
+ try {
+ const auto context = session_.device_manager().context();
+ auto device = session_.device()->device();
+
+ map<string, Glib::VariantBase> options = options_;
+
+ if (!output_format_->test_flag(OutputFlag::INTERNAL_IO_HANDLING))
+ output_stream_.open(file_name_, ios_base::binary |
+ ios_base::trunc | ios_base::out);
+
+ output_ = output_format_->create_output(file_name_, device, options);
+ auto meta = context->create_meta_packet(
+ {{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
+ segment->samplerate())}});
+ output_->receive(meta);
+ } catch (Error error) {
+ error_ = tr("Error while saving.");