#include <audio/service/portaudioservice.h>
Public Member Functions | |
PortAudioService (ServiceConfiguration *configuration) | |
~PortAudioService ()=default | |
void | registerObjectCreators (rtti::Factory &factory) override |
bool | init (nap::utility::ErrorState &errorState) override |
void | shutdown () override |
void | preShutdown () override |
NodeManager & | getNodeManager () |
bool | getAllowChannelCountFailure () |
unsigned int | getHostApiCount () |
const PaHostApiInfo & | getHostApiInfo (unsigned int hostApiIndex) |
std::vector< const PaHostApiInfo * > | getHostApis () |
std::string | getHostApiName (unsigned int hostApiIndex) |
unsigned int | getDeviceCount (unsigned int hostApiIndex) |
const PaDeviceInfo & | getDeviceInfo (unsigned int hostApiIndex, unsigned int localDeviceIndex) |
const PaDeviceInfo & | getDeviceInfo (unsigned int deviceIndex) |
std::vector< const PaDeviceInfo * > | getDevices (unsigned int hostApiIndex) |
void | printDevices () |
std::string | getDeviceName (unsigned int hostApiIndex, unsigned int localDeviceIndex) |
int | getInputDeviceIndex (int hostApiIndex, const std::string &device) |
int | getOutputDeviceIndex (int hostApiIndex, const std::string &device) |
int | getDeviceIndex (int hostApiIndex, int hostApiDeviceIndex) |
int | getHostApiIndex (const std::string &hostApi) |
int | getCurrentHostApiIndex () const |
int | getCurrentInputDeviceIndex () const |
int | getCurrentOutputDeviceIndex () const |
int | getCurrentBufferSize () const |
bool | openStream (const PortAudioServiceConfiguration::DeviceSettings &settings, utility::ErrorState &errorState) |
const PortAudioServiceConfiguration::DeviceSettings & | getDeviceSettings () const |
bool | closeStream (utility::ErrorState &errorState) |
bool | start (utility::ErrorState &errorState) |
bool | stop (utility::ErrorState &errorState) |
bool | isOpened () |
bool | isActive () |
const std::string & | getErrorMessage () const |
![]() | |
UNPREFIXED_MODULE_NAME_INPUTCASE | Service (ServiceConfiguration *configuration) |
virtual void | getDependentServices (std::vector< rtti::TypeInfo > &dependencies) override |
virtual void | update (double deltaTime) override |
Service (ServiceConfiguration *configuration) | |
virtual | ~Service () |
Core & | getCore () |
const Core & | getCore () const |
std::string | getTypeName () const |
const Module & | getModule () const |
Service (Service &)=delete | |
Service & | operator= (const Service &)=delete |
Service (Service &&)=delete | |
Service & | operator= (Service &&)=delete |
Additional Inherited Members | |
![]() | |
virtual void | getDependentServices (std::vector< rtti::TypeInfo > &dependencies) |
virtual void | created () |
virtual void | preUpdate (double deltaTime) |
virtual void | update (double deltaTime) |
virtual void | postUpdate (double deltaTime) |
virtual void | preResourcesLoaded () |
virtual void | postResourcesLoaded () |
template<typename SERVICE_CONFIG > | |
SERVICE_CONFIG * | getConfiguration () |
template<typename SERVICE_CONFIG > | |
const SERVICE_CONFIG * | getConfiguration () const |
std::string | getIniFilePath () const |
std::string | getIniFilePath (const std::string &appendix) const |
Service that provides audio input and output processing directly for hardware audio devices. Provides static methods to poll the current system for available audio devices using portaudio.
PortAudioService | ( | ServiceConfiguration * | configuration | ) |
|
default |
bool closeStream | ( | utility::ErrorState & | errorState | ) |
Closes the current stream. Assumes that it has been opened successfully.
bool getAllowChannelCountFailure | ( | ) |
int getCurrentBufferSize | ( | ) | const |
int getCurrentHostApiIndex | ( | ) | const |
int getCurrentInputDeviceIndex | ( | ) | const |
int getCurrentOutputDeviceIndex | ( | ) | const |
unsigned int getDeviceCount | ( | unsigned int | hostApiIndex | ) |
hostApiIndex | the number of the host api |
int getDeviceIndex | ( | int | hostApiIndex, |
int | hostApiDeviceIndex | ||
) |
Returns the device index for a device specified by a local index in the list of devices for a specific host API. Returns -1 if the specified device was not found.
const PaDeviceInfo& getDeviceInfo | ( | unsigned int | deviceIndex | ) |
Returns information of an audio device in a PaDeviceInfo struct defined by portaudio.
deviceIndex | the index of the device. |
const PaDeviceInfo& getDeviceInfo | ( | unsigned int | hostApiIndex, |
unsigned int | localDeviceIndex | ||
) |
Returns information of an audio device in a PaDeviceInfo struct defined by portaudio.
hostApiIndex | the number of the host api |
localDeviceIndex | the number of the device counting from 0 to the number of devices belonging to this host api. |
std::string getDeviceName | ( | unsigned int | hostApiIndex, |
unsigned int | localDeviceIndex | ||
) |
hostApiIndex | the number of the host api |
localDeviceIndex | the number of the devie within the host api |
std::vector<const PaDeviceInfo*> getDevices | ( | unsigned int | hostApiIndex | ) |
Returns information on all the available devices for a given host API
hostApiIndex | the number of the host api |
const PortAudioServiceConfiguration::DeviceSettings& getDeviceSettings | ( | ) | const |
Returns const ref to current device settings used by service
const std::string& getErrorMessage | ( | ) | const |
unsigned int getHostApiCount | ( | ) |
int getHostApiIndex | ( | const std::string & | hostApi | ) |
Seatch for the index of a host API by name. Uses case insensitive search.
const PaHostApiInfo& getHostApiInfo | ( | unsigned int | hostApiIndex | ) |
Returns information about a given host api
hostApiIndex |
std::string getHostApiName | ( | unsigned int | hostApiIndex | ) |
std::vector<const PaHostApiInfo*> getHostApis | ( | ) |
int getInputDeviceIndex | ( | int | hostApiIndex, |
const std::string & | device | ||
) |
Lookups the index for an input device with a certain name on a host API.
hostApiIndex | index of the host API |
device | name of the input device |
NodeManager& getNodeManager | ( | ) |
int getOutputDeviceIndex | ( | int | hostApiIndex, |
const std::string & | device | ||
) |
Lookups the index for an output device with a certain name on a host API.
hostApiIndex | index of the host API |
device | name of the output device |
|
overridevirtual |
Initializes portaudio.
Reimplemented from Service.
bool isActive | ( | ) |
bool isOpened | ( | ) |
bool openStream | ( | const PortAudioServiceConfiguration::DeviceSettings & | settings, |
utility::ErrorState & | errorState | ||
) |
Stores the device settings and tries to open audio stream with given device settings, return true on succes The meesage from the errorState will be stored and can be retrieved using AudioService::getErrorMessage()
settings | const ref to DeviceSettings struct |
errorState | contains any errors |
|
overridevirtual |
Called before shutting down the services. Stops the running audio stream if any.
Reimplemented from Service.
void printDevices | ( | ) |
Prints the number and name of all available audio devices to the console
|
overridevirtual |
Register specific object creators
Reimplemented from Service.
|
overridevirtual |
Called on shutdown of the service. Closes portaudio stream and shuts down portaudio.
Reimplemented from Service.
bool start | ( | utility::ErrorState & | errorState | ) |
Restart the audio stream after it has been stopped by calling stop(). Logs errors in the errorState. Assumes the stream has been opened succesfully.
bool stop | ( | utility::ErrorState & | errorState | ) |
Stops the audio stream, waits for any running audio callback before returning. Logs errors in the errorState. Assumes the stream has been opened succesfully.