Audacity 3.2.0
Classes | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
internal::x11::RunLoop Class Reference

#include <RunLoop.h>

Inheritance diagram for internal::x11::RunLoop:
[legend]
Collaboration diagram for internal::x11::RunLoop:
[legend]

Classes

struct  EventHandler
 
struct  TimerHandler
 

Public Member Functions

 RunLoop (::Display *display)
 
virtual ~RunLoop ()
 
Steinberg::tresult PLUGIN_API registerEventHandler (Steinberg::Linux::IEventHandler *handler, Steinberg::Linux::FileDescriptor fd) override
 
Steinberg::tresult PLUGIN_API unregisterEventHandler (Steinberg::Linux::IEventHandler *handler) override
 
Steinberg::tresult PLUGIN_API registerTimer (Steinberg::Linux::ITimerHandler *handler, Steinberg::Linux::TimerInterval milliseconds) override
 
Steinberg::tresult PLUGIN_API unregisterTimer (Steinberg::Linux::ITimerHandler *handler) override
 

Static Private Member Functions

static gboolean OnEvent (GIOChannel *source, GIOCondition condition, gpointer data)
 
static gboolean OnTimer (gpointer data)
 

Private Attributes

std::vector< std::unique_ptr< EventHandler > > mEventHandlers
 
std::vector< std::unique_ptr< TimerHandler > > mTimerHandlers
 
Display * mDisplay { nullptr }
 

Detailed Description

Definition at line 29 of file RunLoop.h.

Constructor & Destructor Documentation

◆ RunLoop()

RunLoop::RunLoop ( ::Display *  display)

Definition at line 60 of file RunLoop.cpp.

61 : mDisplay(display)
62{
63 FUNKNOWN_CTOR;
64}
Display * mDisplay
Definition: RunLoop.h:37

◆ ~RunLoop()

RunLoop::~RunLoop ( )
virtual

Definition at line 66 of file RunLoop.cpp.

67{
68 FUNKNOWN_DTOR;
69}

Member Function Documentation

◆ OnEvent()

gboolean RunLoop::OnEvent ( GIOChannel *  source,
GIOCondition  condition,
gpointer  data 
)
staticprivate

Definition at line 46 of file RunLoop.cpp.

47{
48 auto handler = static_cast<Steinberg::Linux::IEventHandler*>(data);
49 handler->onFDIsSet(g_io_channel_unix_get_fd(source));
50 return G_SOURCE_REMOVE;
51}

References audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler.

Referenced by registerEventHandler().

Here is the caller graph for this function:

◆ OnTimer()

gboolean RunLoop::OnTimer ( gpointer  data)
staticprivate

Definition at line 53 of file RunLoop.cpp.

54{
55 auto handler = static_cast<Steinberg::Linux::ITimerHandler*>(data);
56 handler->onTimer();
57 return G_SOURCE_CONTINUE;
58}

References audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler.

Referenced by registerTimer().

Here is the caller graph for this function:

◆ registerEventHandler()

Steinberg::tresult RunLoop::registerEventHandler ( Steinberg::Linux::IEventHandler *  handler,
Steinberg::Linux::FileDescriptor  fd 
)
override

Definition at line 71 of file RunLoop.cpp.

74{
75 using namespace Steinberg;
76
77 if(handler == nullptr)
78 return kInvalidArgument;
79
80 if(XConnectionNumber(mDisplay) == fd)
81 return kResultOk;
82
83 auto eventHandler = std::make_unique<EventHandler>();
84 eventHandler->handler = handler;
85
86 if(auto channel = g_io_channel_unix_new(fd))
87 {
88 eventHandler->channel = channel;
89 eventHandler->id = g_io_add_watch(
90 channel,
91 (GIOCondition)(G_IO_IN | G_IO_OUT | G_IO_ERR | G_IO_HUP),
94 );
95 mEventHandlers.emplace_back(std::move(eventHandler));
96 return kResultTrue;
97 }
98 return kResultFalse;
99}
std::vector< std::unique_ptr< EventHandler > > mEventHandlers
Definition: RunLoop.h:32
static gboolean OnEvent(GIOChannel *source, GIOCondition condition, gpointer data)
Definition: RunLoop.cpp:46

References audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, mDisplay, mEventHandlers, and OnEvent().

Here is the call graph for this function:

◆ registerTimer()

Steinberg::tresult RunLoop::registerTimer ( Steinberg::Linux::ITimerHandler *  handler,
Steinberg::Linux::TimerInterval  milliseconds 
)
override

Definition at line 117 of file RunLoop.cpp.

119{
120 using namespace Steinberg;
121
122 if(!handler || milliseconds == 0)
123 return kInvalidArgument;
124
125 auto timerHandler = std::make_unique<TimerHandler>();
126 timerHandler->handler = handler;
127 timerHandler->id = g_timeout_add(milliseconds, &RunLoop::OnTimer, handler);
128
129 mTimerHandlers.emplace_back(std::move(timerHandler));
130
131 return Steinberg::kResultOk;
132}
std::vector< std::unique_ptr< TimerHandler > > mTimerHandlers
Definition: RunLoop.h:35
static gboolean OnTimer(gpointer data)
Definition: RunLoop.cpp:53

References audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, mTimerHandlers, and OnTimer().

Here is the call graph for this function:

◆ unregisterEventHandler()

Steinberg::tresult RunLoop::unregisterEventHandler ( Steinberg::Linux::IEventHandler *  handler)
override

Definition at line 101 of file RunLoop.cpp.

103{
104 using namespace Steinberg;
105
106 for(auto it = mEventHandlers.begin(), end = mEventHandlers.end(); it != end; ++it)
107 {
108 if((*it)->handler.get() == handler)
109 {
110 mEventHandlers.erase(it);
111 return kResultTrue;
112 }
113 }
114 return kResultFalse;
115}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end(), audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, and mEventHandlers.

Here is the call graph for this function:

◆ unregisterTimer()

Steinberg::tresult RunLoop::unregisterTimer ( Steinberg::Linux::ITimerHandler *  handler)
override

Definition at line 134 of file RunLoop.cpp.

135{
136 using namespace Steinberg;
137
138 for(auto it = mTimerHandlers.begin(), end = mTimerHandlers.end(); it != end; ++it)
139 {
140 if((*it)->handler.get() == handler)
141 {
142 mTimerHandlers.erase(it);
143 return kResultTrue;
144 }
145 }
146 return kResultFalse;
147}

References details::end(), audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::handler, and mTimerHandlers.

Here is the call graph for this function:

Member Data Documentation

◆ mDisplay

Display* internal::x11::RunLoop::mDisplay { nullptr }
private

Definition at line 37 of file RunLoop.h.

Referenced by registerEventHandler().

◆ mEventHandlers

std::vector<std::unique_ptr<EventHandler> > internal::x11::RunLoop::mEventHandlers
private

Definition at line 34 of file RunLoop.h.

Referenced by registerEventHandler(), and unregisterEventHandler().

◆ mTimerHandlers

std::vector<std::unique_ptr<TimerHandler> > internal::x11::RunLoop::mTimerHandlers
private

Definition at line 35 of file RunLoop.h.

Referenced by registerTimer(), and unregisterTimer().


The documentation for this class was generated from the following files: