mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-11-01 06:57:04 +01:00
99feb14036
This basically reverts 5c8ca78c99
.
Using libao + sndfile was a bad idea...
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
31 lines
438 B
C++
31 lines
438 B
C++
#include <cstring>
|
|
#include <stdexcept>
|
|
#include <thread>
|
|
|
|
#include "wave.h"
|
|
|
|
std::mutex Wave::_playMutex = {};
|
|
|
|
Wave::Wave(const std::string &filename):
|
|
_filename(filename),
|
|
_command("aplay " + _filename)
|
|
{
|
|
}
|
|
|
|
Wave::~Wave()
|
|
{
|
|
}
|
|
|
|
void Wave::play() const
|
|
{
|
|
std::lock_guard<std::mutex> l(_playMutex);
|
|
system(_command.c_str());
|
|
}
|
|
|
|
void Wave::playAsync() const
|
|
{
|
|
std::thread([this] () {
|
|
play();
|
|
}).detach();
|
|
}
|