-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathAudioCapture.h
88 lines (69 loc) · 2.65 KB
/
AudioCapture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include <Poco/Logger.h>
#include <Poco/Util/Subsystem.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <memory>
class AudioCaptureImpl;
/**
* @brief Audio capturing proxy class/subsystem.
*
* Creates the OS-specific audio recording class and forwards the necessary calls to it.
*/
class AudioCapture : public Poco::Util::Subsystem
{
public:
using AudioDeviceMap = std::map<int, std::string>;
const char* name() const override;
void initialize(Poco::Util::Application& app) override;
void uninitialize() override;
/**
* @brief Switches to the next available audio recording device.
*/
void NextAudioDevice();
/**
* @brief Activates the audio device with the given idnex for recording.
* @param index The index, as listed by @a AudioDeviceList()
*/
void AudioDeviceIndex(int index);
/**
* @brief Returns the currently used Audio device index.
* @return The index of the current audio device, as listed by @a AudioDeviceList()
*/
int AudioDeviceIndex() const;
/**
* @brief Retrieves the current audio device name.
* @return The name of the currently selected audio recording device.
*/
std::string AudioDeviceName() const;
/**
* @brief Returns a list of currently available audio devices.
* @return A map with device index/name pairs.
*/
AudioDeviceMap AudioDeviceList();
/**
* @brief Asks the capture client to fill projectM's audio buffer for the next frame.
*/
void FillBuffer();
protected:
/**
* @brief Prints a list of available audio devices on standard output if requested by the user.
* @param deviceList The list of available audio devices.
*/
void PrintDeviceList(const AudioDeviceMap& deviceList) const;
/**
* @brief Returns the index of the initial audio device that should be used.
*
* Tries to find a device name or index specified in the user configuration and returns
* it if either was found and is inside the device list.
*
* If none was found, it returns -1, which delegates default device selection to the capture API
* implementation.
*
* @param deviceList The list of available audio devices.
* @return A device index from -1 to the number of available devices minus one.
*/
int GetInitialAudioDeviceIndex(const AudioDeviceMap& deviceList);
Poco::AutoPtr<Poco::Util::AbstractConfiguration> _config; //!< View of the "audio" configuration subkey.
AudioCaptureImpl* _impl{}; //!< The OS-specific capture implementation.
Poco::Logger& _logger{ Poco::Logger::get("AudioCapture") }; //!< The class logger.
};