22#define SLEEP_TIME 0.010f
25#define PA_SAMPLE_TYPE paFloat32
27#define SAMPLE_SILENCE (0.0f)
29#define PA_SAMPLE_TYPE paInt16
31#define SAMPLE_SILENCE (0)
33#define PA_SAMPLE_TYPE paInt8
35#define SAMPLE_SILENCE (0)
37#define PA_SAMPLE_TYPE paUInt8
38typedef unsigned char SAMPLE;
39#define SAMPLE_SILENCE (128)
40#define SAMPLE_UNSIGNED
94#ifdef STOP_PLAY_ON_EMPTY_BUFFER
172 m_system_resource(nullptr)
185 if (m_stream !=
nullptr)
205bool PortAudioPlayerDeviceDriver::configureDeviceAndStart()
222 m_outputParameters.hostApiSpecificStreamInfo =
nullptr;
225 std::string
devname =
"unknown";
228 m_outputParameters.suggestedLatency =
devinfo->defaultLowOutputLatency;
259 if (!b) {
return false; }
262 if (!b) {
return false; }
264 b = configureDeviceAndStart();
286bool PortAudioPlayerDeviceDriver::abortSound()
305 return ReturnValue::return_code::return_value_error_not_implemented_by_device;
324 if (m_err < 0) {
handleError();
return ReturnValue::return_code::return_value_error_method_failed; }
333 if (m_err < 0) {
handleError();
return ReturnValue::return_code::return_value_error_method_failed; }
static int bufferIOCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
static int bufferIOCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
size_t m_driver_frame_size
yarp::dev::ReturnValue setHWGain(double gain) override
Sets the hardware gain of the playback device (if supported by the hardware)
bool threadInit() override
Initialization method.
yarp::dev::ReturnValue stopPlayback() override
Stop the playback.
void waitUntilPlaybackStreamIsComplete() override
bool interruptDeviceAndClose() override
void run() override
Main body of the new thread.
yarp::dev::ReturnValue startPlayback() override
Start the playback.
~PortAudioPlayerDeviceDriver() override
PortAudioPlayerDeviceDriver()
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void threadRelease() override
Release method.
virtual yarp::dev::ReturnValue stopPlayback() override
Stop the playback.
yarp::dev::CircularAudioBuffer_16t * m_outputBuffer
bool configurePlayerAudioDevice(yarp::os::Searchable &config, std::string device_name)
virtual yarp::dev::ReturnValue startPlayback() override
Start the playback.
AudioDeviceDriverSettings m_audioplayer_cfg
yarp::sig::AudioBufferSize size()
A mini-server for performing network communication in the background.
T * read(bool shouldWait=true) override
Read an available object from the port.
A base class for nested structures that can be searched.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
bool stop()
Stop the thread.
bool isStopping()
Returns true if the thread is stopping (Thread::stop has been called).
bool start()
Start the new thread running.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
yarp::dev::CircularAudioBuffer< unsigned short int > CircularAudioBuffer_16t
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.