YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
AudioPlayerWrapper.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef YARP_DEV_AUDIOPLAYERWRAPPER_H
7#define YARP_DEV_AUDIOPLAYERWRAPPER_H
8
9 //#include <list>
10#include <vector>
11#include <queue>
12#include <iostream>
13#include <string>
14#include <sstream>
15
16#include <yarp/os/Network.h>
17#include <yarp/os/Port.h>
19#include <yarp/os/Bottle.h>
20#include <yarp/os/Time.h>
21#include <yarp/os/Property.h>
22
25#include <yarp/os/Stamp.h>
26
27#include <yarp/sig/Vector.h>
28
30#include <yarp/dev/PolyDriver.h>
33#include <yarp/dev/api.h>
34
36
54{
55
56 struct scheduled_sound_type
57 {
58 double scheduled_time=0;
59 yarp::sig::Sound sound_data;
60 };
61
62public:
68
69 ~AudioPlayerWrapper() override;
70
71 bool open(yarp::os::Searchable &params) override;
72 bool close() override;
73
77 bool attach(yarp::dev::PolyDriver *driver) override;
78 bool detach() override;
79
80 bool threadInit() override;
81 void afterStart(bool success) override;
82 void threadRelease() override;
83 void run() override;
84
85private:
86 yarp::os::Port m_rpcPort;
88 yarp::os::Port m_statusPort;
89
90 yarp::dev::IAudioRender *m_irender = nullptr;
91 yarp::os::Stamp m_lastStateStamp;
92 yarp::sig::AudioBufferSize m_current_buffer_size;
93 yarp::sig::AudioBufferSize m_max_buffer_size;
94 std::queue<scheduled_sound_type> m_sound_buffer;
95
96 bool m_isPlaying = false;
97
98 bool read(yarp::os::ConnectionReader& connection) override;
99
100};
101
102#endif // YARP_DEV_AUDIOPLAYERWRAPPER_H
contains the definition of a Vector type
This class is the parameters parser for class AudioPlayerWrapper.
AudioPlayerWrapper: A Wrapper which receives audio streams from a network port and sends it to device...
bool close() override
Close the DeviceDriver.
AudioPlayerWrapper & operator=(AudioPlayerWrapper &&)=delete
bool threadInit() override
Initialization method.
void run() override
Loop function.
void threadRelease() override
Release method.
AudioPlayerWrapper(const AudioPlayerWrapper &)=delete
AudioPlayerWrapper(AudioPlayerWrapper &&)=delete
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).
AudioPlayerWrapper & operator=(const AudioPlayerWrapper &)=delete
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
bool attach(yarp::dev::PolyDriver *driver) override
Specify which sensor this thread has to read from.
Interface implemented by all device drivers.
Interface for rendering a YARP-format sound and controlling its reproduction ona device.
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An abstraction for a periodic thread.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25