YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
AudioPlayerDeviceBase.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <vector>
7
10#include <yarp/dev/api.h>
12#include <mutex>
13
14#ifndef YARP_DEV_AUDIOPLAYERDEVICETEMPLATE_H
15#define YARP_DEV_AUDIOPLAYERDEVICETEMPLATE_H
16
17namespace yarp::dev {
18
19
21{
22 public:
23 size_t numSamples = 0;
24 size_t numChannels = 0;
25 size_t frequency = 0;
26 size_t bytesPerSample = 2;
27};
28
50{
51protected:
52 bool m_enable_buffer_autoclear = false;
53 bool m_playback_enabled = false;
54 std::recursive_mutex m_mutex;
55 yarp::dev::CircularAudioBuffer_16t* m_outputBuffer = nullptr;
57 double m_sw_gain = 1.0;
58 double m_hw_gain = 1.0;
59 bool m_audiobase_debug = false;
60 enum { RENDER_APPEND = 0, RENDER_IMMEDIATE = 1 } m_renderMode= RENDER_APPEND;
61
62public:
63 virtual yarp::dev::ReturnValue renderSound(const yarp::sig::Sound& sound) override;
64 virtual yarp::dev::ReturnValue startPlayback() override;
65 virtual yarp::dev::ReturnValue stopPlayback() override;
66 virtual yarp::dev::ReturnValue isPlaying(bool& playback_enabled) override;
67 virtual yarp::dev::ReturnValue getPlaybackAudioBufferMaxSize(yarp::sig::AudioBufferSize& size) override;
68 virtual yarp::dev::ReturnValue getPlaybackAudioBufferCurrentSize(yarp::sig::AudioBufferSize& size) override;
69 virtual yarp::dev::ReturnValue resetPlaybackAudioBuffer() override;
70 virtual yarp::dev::ReturnValue setSWGain(double gain) override;
71
72 virtual ~AudioPlayerDeviceBase();
73
74protected:
75 virtual bool configureDeviceAndStart() = 0;
76 virtual bool interruptDeviceAndClose() = 0;
77 virtual void waitUntilPlaybackStreamIsComplete();
78 virtual bool immediateSound(const yarp::sig::Sound& sound);
79 virtual bool appendSound(const yarp::sig::Sound& sound);
80
81 bool configurePlayerAudioDevice(yarp::os::Searchable& config, std::string device_name);
82};
83
84} // namespace yarp::dev
85
86#endif
AudioPlayerDeviceBase : a base class for all audio player devices
virtual bool configureDeviceAndStart()=0
virtual bool interruptDeviceAndClose()=0
AudioDeviceDriverSettings m_audioplayer_cfg
Interface for rendering a YARP-format sound and controlling its reproduction ona device.
A base class for nested structures that can be searched.
Definition Searchable.h:31
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:25
For streams capable of holding different kinds of content, check what they actually have.
#define YARP_dev_API
Definition api.h:18