YARP
Yet Another Robot Platform
PortAudioPlayerDeviceDriver.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 PortAudioPlayerDeviceDriverh
7 #define PortAudioPlayerDeviceDriverh
8 
9 #include <yarp/os/ManagedBytes.h>
10 #include <yarp/os/Thread.h>
11 
12 #include <yarp/dev/DeviceDriver.h>
15 #include <portaudio.h>
16 #include <mutex>
17 
39  public yarp::os::Thread
40 {
41 private:
42  PaStreamParameters m_outputParameters;
43  PaStream* m_stream;
44  PaError m_err;
45 
46 public:
53 
54 private:
55  bool abortSound();
56  bool configureDeviceAndStart() override;
57 
58 public: //DeviceDriver
59  bool open(yarp::os::Searchable& config) override;
60  bool close() override;
61 
62 public: //AudioRecorderDeviceBase(IAudioGrabberSound)
63  void waitUntilPlaybackStreamIsComplete() override;
64  bool setHWGain(double gain) override;
65  bool interruptDeviceAndClose() override;
66  bool startPlayback() override;
67  bool stopPlayback() override;
68 
69 public: //Thread
70  void threadRelease() override;
71  bool threadInit() override;
72  void run() override;
73 
74 protected:
76 
79  void handleError();
80 };
81 
82 #endif
portaudioPlayer: A device driver for an audio playback device wrapped by PortAudio library.
bool threadInit() override
Initialization method.
PortAudioPlayerDeviceDriver(PortAudioPlayerDeviceDriver &&)=delete
PortAudioPlayerDeviceDriver & operator=(PortAudioPlayerDeviceDriver &&)=delete
bool stopPlayback() override
Stop the playback.
void run() override
Main body of the new thread.
PortAudioPlayerDeviceDriver & operator=(const PortAudioPlayerDeviceDriver &)=delete
PortAudioPlayerDeviceDriver(const PortAudioPlayerDeviceDriver &)=delete
bool setHWGain(double gain) override
Sets the hardware gain of the playback device (if supported by the hardware)
bool close() override
Close the DeviceDriver.
bool startPlayback() override
Start the playback.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void threadRelease() override
Release method.
AudioPlayerDeviceBase : a base class for all audio player devices
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a thread of execution.
Definition: Thread.h:22