2016-12-13 13:26:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
|
|
|
|
#include "common.hpp"
|
2017-01-11 02:07:28 +00:00
|
|
|
#include "settings.hpp"
|
2016-12-13 13:26:09 +00:00
|
|
|
#include "errors.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
namespace alsa {
|
|
|
|
DEFINE_ERROR(alsa_exception);
|
|
|
|
DEFINE_CHILD_ERROR(mixer_error, alsa_exception);
|
|
|
|
DEFINE_CHILD_ERROR(control_error, alsa_exception);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void throw_exception(string&& message, int error_code) {
|
|
|
|
const char* snd_error = snd_strerror(error_code);
|
|
|
|
if (snd_error != nullptr)
|
|
|
|
message += ": " + string{snd_error};
|
|
|
|
throw T(message.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|