6#define _USE_MATH_DEFINES
46 driver->
view(m_irender);
49 if (
nullptr == m_irender)
79 bool ok = command.
read(connection);
97 else if (command.
get(0).
asString() ==
"sw_audio_gain")
111 else if (command.
get(0).
asString() ==
"hw_audio_gain")
163 std::string rpcPortName =
m_name +
"/rpc:i";
176 if (!m_rpcPort.
open(rpcPortName))
184 yCInfo(
AUDIOPLAYERWRAPPER) <<
"Increase this value to robustify the real-time audio stream (it will increase latency too)";
192 m_audioInPort.
close();
196 m_statusPort.
close();
223 scheduled_sound_type
ss;
234 m_sound_buffer.push(
ss);
237 if (!m_sound_buffer.empty() &&
current_time > m_sound_buffer.front().scheduled_time)
239 m_irender->
renderSound(m_sound_buffer.front().sound_data);
240 m_sound_buffer.pop();
261 m_statusPort.
write(status);
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_ERR
double m_playback_network_buffer_size
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool close() override
Close the DeviceDriver.
~AudioPlayerWrapper() override
bool threadInit() override
Initialization method.
void run() override
Loop function.
void threadRelease() override
Release method.
void afterStart(bool success) override
Called just after a new thread starts (or fails to start), this is executed by the same thread that c...
bool detach() override
Detach the object (you must have first called attach).
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
bool attach(yarp::dev::PolyDriver *driver) override
Specify which sensor this thread has to read from.
bool view(T *&x)
Get an interface to the device driver.
virtual yarp::dev::ReturnValue getPlaybackAudioBufferCurrentSize(yarp::sig::AudioBufferSize &size)=0
virtual yarp::dev::ReturnValue startPlayback()=0
Start the playback.
virtual yarp::dev::ReturnValue renderSound(const yarp::sig::Sound &sound)=0
Render a sound using a device (i.e.
virtual yarp::dev::ReturnValue stopPlayback()=0
Stop the playback.
virtual yarp::dev::ReturnValue setHWGain(double gain)=0
Sets the hardware gain of the playback device (if supported by the hardware)
virtual yarp::dev::ReturnValue isPlaying(bool &playback_enabled)=0
Check if the playback has been enabled (e.g.
virtual yarp::dev::ReturnValue setSWGain(double gain)=0
Sets a software gain for the played audio.
virtual yarp::dev::ReturnValue getPlaybackAudioBufferMaxSize(yarp::sig::AudioBufferSize &size)=0
virtual yarp::dev::ReturnValue resetPlaybackAudioBuffer()=0
A container for a device driver.
bool isValid() const
Check if device is valid.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
T * read(bool shouldWait=true) override
Read an available object from the port.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
An abstraction for a periodic thread.
bool setPeriod(double period)
Set the (new) period of the thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void setReader(PortReader &reader) override
Set an external reader for port data.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::string asString() const
Get string value.
AudioPlayerStatus: A class used to describe the status of an audio player device.
size_t max_buffer_size
the max_size of the audio buffer [samples]
bool enabled
true if the playback is currently enabled
size_t current_buffer_size
the size of the audio buffer [samples]
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
double getDuration() const
Get the duration of sound in seconds.
size_t getSamples() const
Get the number of samples contained in the sound.
std::string current_time()
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.