1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-11-16 20:19:13 +01:00
doorlockd-mirror/doorlockd/client/wave.cpp
Ralf Ramsauer 99feb14036 Use aplay command for playing sounds
This basically reverts 5c8ca78c99.
Using libao + sndfile was a bad idea...

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
2016-04-24 22:08:21 +02:00

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();
}