vsdk 8.1.0
 
Loading...
Searching...
No Matches
Vsdk::Audio::ProducerModuleabstract

Base class for Pipeline modules that aquire and dispatch audio buffers (like Producer::File) More...

#include <Pipeline.hpp>

Inheritance diagram for Vsdk::Audio::ProducerModule:
Vsdk::Audio::ProducerModuleImpl< BufferModule > Vsdk::Audio::ProducerModuleImpl< BufferForwarder > Vsdk::Audio::ProducerModuleImpl< File > Vsdk::Audio::ProducerModuleImpl< T > Vsdk::Tts::Channel Vsdk::Audio::BufferModule Vsdk::Audio::Producer::BufferForwarder Vsdk::Audio::Producer::File

Public Types

enum class  State {
  Closed , Opened , Running , Started ,
  Paused , Idle
}
 
using Iterator = details::Iterator< decltype(_subscribers)>
 Iterator pointing to a subscriber of this producer.
 

Public Member Functions

 ProducerModule ()
 
 ProducerModule (ProducerModule &&)
 
ProducerModuleoperator= (ProducerModule &&)
 
virtual ~ProducerModule ()=0
 
 ProducerModule (ProducerModule const &)=delete
 
ProducerModuleoperator= (ProducerModule const &)=delete
 
auto subscribeFirst (AudioCallback c) -> Iterator
 Subscribes as first in the list of audio buffer receivers for this producer.
 
auto subscribeLast (AudioCallback c) -> Iterator
 Subscribes as last in the list of audio buffer receivers for this producer.
 
void unsubscribe (Iterator it) noexcept
 Unsubscribes from this producer audio buffer dispatch list.
 
auto lastError () const -> std::string
 
auto state () const -> State
 
bool isOpened () const
 
bool isRunning () const
 
bool isStarted () const
 
bool isPaused () const
 
bool isIdle () const
 
bool isClosed () const
 
bool open () noexcept
 Attempts to open the underlying resource(s) of the producer.
 
bool run () noexcept
 
bool start () noexcept
 
bool pause () noexcept
 Attempts to pause a started producer.
 
bool resume () noexcept
 Attempts to resume a paused producer.
 
bool stop () noexcept
 Attempts to stop a started producer.
 
bool close () noexcept
 

Protected Member Functions

virtual void openImpl ()
 
virtual void runImpl ()
 
virtual void startImpl ()
 
virtual void pauseImpl ()
 
virtual void resumeImpl ()
 
virtual void stopImpl ()
 
virtual void closeImpl ()
 
void dispatchBuffer (Buffer buffer, bool last)
 
template<typename T >
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)
 

Protected Attributes

std::atomic< State_state
 

Detailed Description

Base class for Pipeline modules that aquire and dispatch audio buffers (like Producer::File)

Member Typedef Documentation

◆ Iterator

using Vsdk::Audio::ProducerModule::Iterator = details::Iterator<decltype(_subscribers)>

Iterator pointing to a subscriber of this producer.

Member Enumeration Documentation

◆ State

Enumerator
Closed 

Ready to be open()-ed.

Opened 

Ready to call run() or start()

Running 

Inside of run()

Started 

start() (or resume()) has been called and work is in progress

Paused 

pause() has been called

Idle 

Either stop() has been called or audio production is over, new work can be launched.

Constructor & Destructor Documentation

◆ ProducerModule() [1/3]

ProducerModule::ProducerModule ( )

◆ ProducerModule() [2/3]

ProducerModule::ProducerModule ( ProducerModule &&  other)

◆ ~ProducerModule()

ProducerModule::~ProducerModule ( )
pure virtual

◆ ProducerModule() [3/3]

Vsdk::Audio::ProducerModule::ProducerModule ( ProducerModule const &  )
delete

Member Function Documentation

◆ operator=() [1/2]

ProducerModule & ProducerModule::operator= ( ProducerModule &&  other)

◆ operator=() [2/2]

ProducerModule & Vsdk::Audio::ProducerModule::operator= ( ProducerModule const &  )
delete

◆ subscribeFirst()

auto ProducerModule::subscribeFirst ( AudioCallback  c) -> Iterator

Subscribes as first in the list of audio buffer receivers for this producer.

◆ subscribeLast()

auto ProducerModule::subscribeLast ( AudioCallback  c) -> Iterator

Subscribes as last in the list of audio buffer receivers for this producer.

◆ unsubscribe()

void ProducerModule::unsubscribe ( Iterator  it)
noexcept

Unsubscribes from this producer audio buffer dispatch list.

◆ lastError()

auto ProducerModule::lastError ( ) const -> std::string

◆ state()

auto ProducerModule::state ( ) const -> State

◆ isOpened()

bool ProducerModule::isOpened ( ) const

◆ isRunning()

bool ProducerModule::isRunning ( ) const

◆ isStarted()

bool ProducerModule::isStarted ( ) const

◆ isPaused()

bool ProducerModule::isPaused ( ) const

◆ isIdle()

bool ProducerModule::isIdle ( ) const

◆ isClosed()

bool ProducerModule::isClosed ( ) const

◆ open()

bool ProducerModule::open ( )
noexcept

Attempts to open the underlying resource(s) of the producer.

Note
  • Blocking call
  • lastError() is reset at the beginning of this function
Postcondition
state() == State::Opened

◆ run()

bool ProducerModule::run ( )
noexcept
Note
  • Blocking call, no asynchronous work should be performed
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support synchronous operations!
Precondition
state() == State::Opened
Postcondition
state() == State::Opened

◆ start()

bool ProducerModule::start ( )
noexcept
Note
  • Non-blocking call: producer might not be started right after this
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support async operations!
Precondition
state() == State::Opened

◆ pause()

bool ProducerModule::pause ( )
noexcept

Attempts to pause a started producer.

Note
  • Non-blocking call: producer might not be paused right after this
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support pausing!

◆ resume()

bool ProducerModule::resume ( )
noexcept

Attempts to resume a paused producer.

Note
  • Non-blocking call: producer might not be resumed right after this
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support resuming!

◆ stop()

bool ProducerModule::stop ( )
noexcept

Attempts to stop a started producer.

Note
  • Non-blocking call: producer state might not be Idle after this
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support async operations!

◆ close()

bool ProducerModule::close ( )
noexcept
Note
<lu> Blocking call: producer should wait for proper closing lastError() is reset at the beginning of this function
Warning
  • Attempting to close a running producer will fail
  • Attempting to close a started producer will first try to close it </lu>
Postcondition
state() == State::Closed

◆ openImpl()

void ProducerModule::openImpl ( )
protectedvirtual

◆ runImpl()

void ProducerModule::runImpl ( )
protectedvirtual

◆ startImpl()

void ProducerModule::startImpl ( )
protectedvirtual

◆ pauseImpl()

void ProducerModule::pauseImpl ( )
protectedvirtual

◆ resumeImpl()

void ProducerModule::resumeImpl ( )
protectedvirtual

◆ stopImpl()

void ProducerModule::stopImpl ( )
protectedvirtual

◆ closeImpl()

void ProducerModule::closeImpl ( )
protectedvirtual

◆ dispatchBuffer()

void ProducerModule::dispatchBuffer ( Buffer  buffer,
bool  last 
)
protected

◆ dispatchAudio()

template<typename T >
void Vsdk::Audio::ProducerModule::dispatchAudio ( T &&  data,
int  sampleRate,
int  channelCount,
bool  isLast 
)
protected

Member Data Documentation

◆ _state

std::atomic<State> Vsdk::Audio::ProducerModule::_state
protected