vsdk 8.0.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

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)
 Unsubscribes from this producer audio buffer dispatch list.
 
auto lastError () const -> std::string const &
 
bool isOpened () const
 
bool isStarted () const
 
bool isRunning () const
 
bool open () noexcept
 Attempts to open the underlying resource(s) of the producer.
 
bool run () noexcept
 
bool start () noexcept
 
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 stopImpl ()
 
virtual void closeImpl ()
 
template<typename... Args>
void setLastError (char const *fmt, Args &&... args)
 
void setLastError (std::string error)
 
void dispatchBuffer (Buffer buffer, bool last)
 
template<typename T >
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)
 

Protected Attributes

std::atomic_bool _opened
 
std::atomic_bool _started
 
std::atomic_bool _running
 

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.

Constructor & Destructor Documentation

◆ ProducerModule() [1/3]

ProducerModule::ProducerModule ( )

◆ ProducerModule() [2/3]

ProducerModule::ProducerModule ( ProducerModule &&  other)

◆ ~ProducerModule()

ProducerModule::~ProducerModule ( )
pure virtualdefault

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

Unsubscribes from this producer audio buffer dispatch list.

◆ lastError()

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

◆ isOpened()

bool ProducerModule::isOpened ( ) const

◆ isStarted()

bool ProducerModule::isStarted ( ) const

◆ isRunning()

bool ProducerModule::isRunning ( ) 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
isOpened() == true

◆ run()

bool ProducerModule::run ( )
noexcept
Note
  • Blocking call
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support synchronous operations!
Precondition
isOpened() == true
Postcondition

◆ start()

bool ProducerModule::start ( )
noexcept
Note
  • Non-blocking call: producer might not be started right after this
  • Doesn't actually try to start if isStarted() == true
  • lastError() is reset at the beginning of this function
Warning
Do not override if you do not support async operations!
Precondition
isOpened() == true

◆ stop()

bool ProducerModule::stop ( )
noexcept

Attempts to stop a started producer.

Note
  • Non-blocking call: producer might still be started after this call
  • Doesn't actually try to stop if isStarted() == false
  • 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> Doesn't do anything is producer has not been opened yet 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

◆ openImpl()

void ProducerModule::openImpl ( )
protectedvirtual

Reimplemented in Vsdk::Audio::Producer::File.

◆ runImpl()

void ProducerModule::runImpl ( )
protectedvirtual

◆ startImpl()

void ProducerModule::startImpl ( )
protectedvirtual

◆ stopImpl()

void ProducerModule::stopImpl ( )
protectedvirtual

◆ closeImpl()

void ProducerModule::closeImpl ( )
protectedvirtual

◆ setLastError() [1/2]

template<typename... Args>
void Vsdk::Audio::ProducerModule::setLastError ( char const *  fmt,
Args &&...  args 
)
protected

◆ setLastError() [2/2]

void ProducerModule::setLastError ( std::string  error)
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

Member Data Documentation

◆ _opened

std::atomic_bool Vsdk::Audio::ProducerModule::_opened
protected

◆ _started

std::atomic_bool Vsdk::Audio::ProducerModule::_started
protected

◆ _running

std::atomic_bool Vsdk::Audio::ProducerModule::_running
protected