MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / pw_init

Method pw_init

source/MaaKWinControlUnit/Screencap/PipeWireScreencap.cpp:793–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791// ===========================================================================
792
793bool PipeWireScreencap::pw_init()
794{
795 // Create pw_thread_loop (standard event loop with integrated bg thread)
796 pw_thread_loop_ = pw_thread_loop_new("MaaScreencap", nullptr);
797 if (!pw_thread_loop_) {
798 LogError << "Failed to create PipeWire thread loop";
799 return false;
800 }
801
802 pw_loop_ = pw_thread_loop_get_loop(pw_thread_loop_);
803
804 pw_context_ = pw_context_new(pw_loop_, nullptr, 0);
805 if (!pw_context_) {
806 LogError << "Failed to create PipeWire context";
807 close_internal();
808 return false;
809 }
810
811 if (pipewire_fd_ < 0) {
812 LogError << "Invalid PipeWire FD (missing OpenPipeWireRemote?)";
813 close_internal();
814 return false;
815 }
816
817 // Connect to KWin's private PipeWire instance via the portal FD
818 pw_core_ = pw_context_connect_fd(pw_context_, pipewire_fd_, nullptr, 0);
819 if (!pw_core_) {
820 LogError << "Failed to connect via portal PipeWire FD";
821 close_internal();
822 return false;
823 }
824
825 // pw_context_connect_fd takes ownership of pipewire_fd_
826 pipewire_fd_ = -1;
827
828 // Register core event listener for error detection (e.g. EPIPE on disconnect).
829 static const struct pw_core_events core_events = {
830 .version = PW_VERSION_CORE_EVENTS,
831 .error = pw_on_core_error,
832 };
833 pw_core_add_listener(pw_core_, &core_hook_, &core_events, this);
834
835 return true;
836}
837
838bool PipeWireScreencap::pw_create_stream()
839{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected