1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-11-17 04:29:11 +01:00
doorlockd-mirror/doorlockd/client/wave.cpp

31 lines
438 B
C++
Raw Normal View History

#include <cstring>
#include <stdexcept>
2015-10-11 19:15:50 +02:00
#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
{
2015-10-11 19:15:50 +02:00
std::lock_guard<std::mutex> l(_playMutex);
system(_command.c_str());
}
2015-10-11 19:15:50 +02:00
void Wave::playAsync() const
{
std::thread([this] () {
play();
}).detach();
}