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

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

#include <ProducerModule.hpp>

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

Public Types

enum class  State {
  Closed , Opened , Running , Started ,
  Paused , Idle
}
using StateChangedCallback = std::function<void(State)>
using Iterator = Vsdk::Utils::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 state () const -> State
bool isOpened () const
bool isRunning () const
bool isStarted () const
bool isPaused () const
bool isIdle () const
bool isClosed () const
void open ()
 Attempts to open the underlying resource(s) of the producer.
void run ()
void start ()
void pause ()
 Attempts to pause a started producer.
void resume ()
 Attempts to resume a paused producer.
void stop ()
 Attempts to stop a started producer.
void close ()
void setStateChangedCallback (StateChangedCallback c)

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 setState (State s)
void dispatchBuffer (Buffer buffer, bool last)
template<typename T>
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)

Detailed Description

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

Member Typedef Documentation

◆ StateChangedCallback

◆ Iterator

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.

◆ 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()

void ProducerModule::open ( )

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

Note
  • Blocking call
Postcondition
state() == State::Opened
Exceptions
Vsdk::Exceptionif error occurs

◆ run()

void ProducerModule::run ( )
Note
  • Blocking call, no asynchronous work should be performed
Warning
Do not override if you do not support synchronous operations!
Precondition
state() == State::Opened
Postcondition
state() == State::Opened
Exceptions
Vsdk::Exceptionif error occurs

◆ start()

void ProducerModule::start ( )
Note
  • Non-blocking call: producer might not be started right after this
Warning
Do not override if you do not support async operations!
Precondition
state() == State::Opened
Exceptions
Vsdk::Exceptionif error occurs

◆ pause()

void ProducerModule::pause ( )

Attempts to pause a started producer.

Note
  • Non-blocking call: producer might not be paused right after this
Warning
Do not override if you do not support pausing!
Exceptions
Vsdk::Exceptionif error occurs

◆ resume()

void ProducerModule::resume ( )

Attempts to resume a paused producer.

Note
  • Non-blocking call: producer might not be resumed right after this
Warning
Do not override if you do not support resuming!
Exceptions
Vsdk::Exceptionif error occurs

◆ stop()

void ProducerModule::stop ( )

Attempts to stop a started producer.

Note
  • Non-blocking call: producer state might not be Idle after this
Warning
Do not override if you do not support async operations!
Exceptions
Vsdk::Exceptionif error occurs

◆ close()

void ProducerModule::close ( )
Note
  • Blocking call: producer should wait for proper closing
Warning
  • Attempting to close a running producer will fail
  • Attempting to close a started producer will first try to close it
Postcondition
state() == State::Closed
Exceptions
Vsdk::Exceptionif error occurs

◆ openImpl()

void ProducerModule::openImpl ( )
protectedvirtual

◆ runImpl()

void ProducerModule::runImpl ( )
protectedvirtual

◆ startImpl()

◆ pauseImpl()

void ProducerModule::pauseImpl ( )
protectedvirtual

◆ resumeImpl()

void ProducerModule::resumeImpl ( )
protectedvirtual

◆ stopImpl()

◆ closeImpl()

void ProducerModule::closeImpl ( )
protectedvirtual

◆ setStateChangedCallback()

void ProducerModule::setStateChangedCallback ( StateChangedCallback c)

◆ setState()

void ProducerModule::setState ( State s)
protected

◆ 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