#pragma once #include #include #include #include namespace libremidi { class observer_pipewire final : public observer_api , private pipewire_helpers , private error_handler { public: struct : observer_configuration , pipewire_observer_configuration { } configuration; explicit observer_pipewire(observer_configuration&& conf, pipewire_observer_configuration&& apiconf) : configuration{std::move(conf), std::move(apiconf)} { create_context(*this); // FIXME notify_in_constructor // FIXME port rename callback #if 0 // Initialize PipeWire client if (configuration.context) { this->client = configuration.context; set_callbacks(); } else #endif { this->add_callbacks(configuration); this->start_thread(); } } libremidi::API get_current_api() const noexcept override { return libremidi::API::PIPEWIRE; } std::vector get_input_ports() const noexcept override { return get_ports(*this->global_context); } std::vector get_output_ports() const noexcept override { return get_ports(*this->global_context); } ~observer_pipewire() { stop_thread(); destroy_context(); #if 0 if (client && !configuration.context) { // If we own the client, deactivate it pipewire_deactivate(this->client); pipewire_client_close(this->client); this->client = nullptr; } #endif } std::unordered_set seen_input_ports; std::unordered_set seen_output_ports; }; }