- srd_session *session;
- srd_decoder_inst *prev_di = nullptr;
-
- // Prevent any other decode threads from accessing libsigrokdecode
- lock_guard<mutex> srd_lock(global_srd_mutex_);
-
- // Create the session
- srd_session_new(&session);
- assert(session);
-
- // Create the decoders
- for (const shared_ptr<decode::Decoder> &dec : stack_) {
- srd_decoder_inst *const di = dec->create_decoder_inst(session);
-
- if (!di) {
- error_message_ = tr("Failed to create decoder instance");
- srd_session_destroy(session);
- return;
- }
-
- if (prev_di)
- srd_inst_stack(session, prev_di, di);
-
- prev_di = di;
- }
-
- // Start the session
- srd_session_metadata_set(session, SRD_CONF_SAMPLERATE,
- g_variant_new_uint64(samplerate_));
-
- srd_pd_output_callback_add(session, SRD_OUTPUT_ANN,
- DecodeSignal::annotation_callback, this);
-
- srd_session_start(session);