YARP
Yet Another Robot Platform
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
57{
58
59 struct scheduled_sound_type
60 {
61 double scheduled_time=0;
62 yarp::sig::Sound sound_data;
63 };
64
65public:
71
72 ~AudioPlayerWrapper() override;
73
74 bool open(yarp::os::Searchable &params) override;
75 bool close() override;
76
80 bool attachAll(const yarp::dev::PolyDriverList &p) override;
81 bool detachAll() override;
82
84 void detach();
85
86 bool threadInit() override;
87 void threadRelease() override;
88 void run() override;
89
90private:
91 yarp::dev::PolyDriver m_driver;
92
93 std::string m_rpcPortName;
94 yarp::os::Port m_rpcPort;
95 std::string m_audioInPortName;
97 std::string m_statusPortName;
98 yarp::os::Port m_statusPort;
99
100 yarp::dev::IAudioRender *m_irender = nullptr;
101 yarp::os::Stamp m_lastStateStamp;
102 yarp::dev::AudioBufferSize m_current_buffer_size;
103 yarp::dev::AudioBufferSize m_max_buffer_size;
104 std::queue<scheduled_sound_type> m_sound_buffer;
105 double m_period;
106 double m_buffer_delay;
107 bool m_isDeviceOwned = false;
108 bool m_debug_enabled = false;
109 bool m_isPlaying = false;
110
111 bool initialize_YARP(yarp::os::Searchable &config);
112 bool read(yarp::os::ConnectionReader& connection) override;
113
114};
115
116#endif // YARP_DEV_AUDIOPLAYERWRAPPER_H
contains the definition of a Vector type
AudioPlayerWrapper: A Wrapper which receives audio streams from a network port and sends it to device...
bool close() override
Close the DeviceDriver.
void attach(yarp::dev::IAudioRender *irend)
AudioPlayerWrapper & operator=(AudioPlayerWrapper &&)=delete
bool threadInit() override
Initialization method.
void run() override
Loop function.
bool attachAll(const yarp::dev::PolyDriverList &p) override
Specify which sensor this thread has to read from.
void threadRelease() override
Release method.
AudioPlayerWrapper(const AudioPlayerWrapper &)=delete
bool detachAll() override
Detach the object (you must have first called attach).
AudioPlayerWrapper(AudioPlayerWrapper &&)=delete
AudioPlayerWrapper & operator=(const AudioPlayerWrapper &)=delete
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
Interface for an object that can wrap/attach to to another.
A container for a device driver.
Definition: PolyDriver.h:23
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:63
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