vdr-plugin-softhddevice-drm-gles 1.6.8-daba64b
cStateMachine Class Reference

State Machine Implementation. More...

#include <statemachine.h>

Public Member Functions

 cStateMachine (cSoftHdDevice *)
 Create the state machine.
 
void OnEventReceived (const Event &)
 Event handler for playback state transitions.
 
State GetState (void) const
 
void SetState (State state)
 
void ChangeState (State)
 Sets the new state and triggers actions, which are necessary when leaving the old and entering the new state.
 

Private Attributes

cSoftHdDevicem_pDevice
 pointer to the device
 
std::mutex m_mutex
 state machine mutex
 
std::atomic< Statem_state = DETACHED
 current state
 

Detailed Description

State Machine Implementation.

Events can be pushed directly to the state machine (OnEventReceived()) or can be pushed through the event handler queue. Pushing directly may block the calling thread until OnEventReceiced() returns. Pushing the event to the event handler queue avoids this locking but does not guarantee, that the event is processed immediately.

The user may choose, which solution fits best for the present use case.

Definition at line 141 of file statemachine.h.

Constructor & Destructor Documentation

◆ cStateMachine()

cStateMachine::cStateMachine ( cSoftHdDevice device)

Create the state machine.

Parameters
devicepointer to cSoftHdDevice object

Definition at line 32 of file statemachine.cpp.

Member Function Documentation

◆ ChangeState()

void cStateMachine::ChangeState ( State  newState)

Sets the new state and triggers actions, which are necessary when leaving the old and entering the new state.

Parameters
newStatetarget state

Definition at line 43 of file statemachine.cpp.

References cSoftHdDevice::EnterState(), cSoftHdDevice::LeaveState(), LOGDEBUG, m_pDevice, m_state, and StateToString().

Referenced by OnEventReceived().

◆ GetState()

State cStateMachine::GetState ( void  ) const
inline

Definition at line 146 of file statemachine.h.

References m_state.

◆ OnEventReceived()

void cStateMachine::OnEventReceived ( const Event event)

Event handler for playback state transitions.

Processes events (Play, Pause, Stop, TrickSpeed, StillPicture) and performs the appropriate state transitions based on the current state. The method halts both display and decoding threads before processing the event and resumes them afterwards to ensure thread-safe state transitions.

Parameters
eventThe event to process (variant type containing specific event data)

Definition at line 66 of file statemachine.cpp.

References BUFFERING, ChangeState(), DETACHED, EventToString(), cSoftHdDevice::HaltOpenGlThread(), cSoftHdDevice::HaltVideoThreads(), cSoftHdDevice::HandleDisplayModeChange(), cSoftHdDevice::HandleStillPicture(), cSoftHdDevice::InitAudio(), cSoftHdDevice::IsDetachForced(), LOGDEBUG, LOGERROR, LOGWARNING, m_mutex, m_pDevice, m_state, cSoftHdDevice::PausePlayback(), PLAY, cSoftHdDevice::ResetVideoFilter(), cSoftHdDevice::ResumeFromPause(), cSoftHdDevice::ResumeOpenGlThread(), cSoftHdDevice::ResumePlayback(), cSoftHdDevice::ResumeVideoThreads(), cSoftHdDevice::SchedulePlaybackStart(), cSoftHdDevice::ScheduleResyncAtPtsMs(), cSoftHdDevice::SetDetachForced(), cSoftHdDevice::SetTrickSpeed(), StateToString(), STOP, and TRICK_SPEED.

Referenced by cEventHandler::Action().

◆ SetState()

void cStateMachine::SetState ( State  state)
inline

Definition at line 147 of file statemachine.h.

References m_state.

Member Data Documentation

◆ m_mutex

std::mutex cStateMachine::m_mutex
private

state machine mutex

Definition at line 152 of file statemachine.h.

Referenced by OnEventReceived().

◆ m_pDevice

cSoftHdDevice* cStateMachine::m_pDevice
private

pointer to the device

Definition at line 151 of file statemachine.h.

Referenced by ChangeState(), and OnEventReceived().

◆ m_state

std::atomic<State> cStateMachine::m_state = DETACHED
private

current state

Definition at line 153 of file statemachine.h.

Referenced by ChangeState(), GetState(), OnEventReceived(), and SetState().


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