1
#include "audio_dev.hpp"
6
const std::size_t settings::low = std::numeric_limits<std::size_t>::min();
7
const std::size_t settings::high = std::numeric_limits<std::size_t>::max();
10
std::string none = "none";
13
record::devlist_t record::devices() {
14
devlist_t l(record_plugin::begin(), record_plugin::end());
15
l.push_back(devinfo(none, "No device. Will not receive any audio data."));
19
record::record(settings& s): m_handle() {
20
if (s.device() == none) return;
21
if (record_plugin::empty()) throw std::runtime_error("No recording devices installed");
22
if (s.device().empty()) {
23
// Try all normal devices
24
for (record_plugin::iterator it = record_plugin::begin(); it != record_plugin::end(); ++it) {
25
if (it->special()) continue;
27
s.debug(">>> Recording from " + it->name());
29
s.set_device(it->name());
31
} catch (std::exception& e) {
32
s.debug(std::string("-!- ") + e.what());
35
throw std::runtime_error("No recording devices could be used");
37
s.debug(">>> Using recording device " + s.device());
39
m_handle = record_plugin::find(s.device())(s);
40
} catch (record_plugin::invalid_key_error&) {
41
throw std::runtime_error("Recording device " + s.device() + " not found");
46
record::~record() { delete m_handle; }