mirror of
https://github.com/JaCzekanski/Avocado.git
synced 2024-06-02 19:27:41 -04:00
27 lines
527 B
C++
27 lines
527 B
C++
#pragma once
|
|
#include <cstdint>
|
|
#include <deque>
|
|
#include <iterator>
|
|
#include <mutex>
|
|
|
|
namespace Sound {
|
|
extern std::deque<uint16_t> buffer;
|
|
extern std::mutex audioMutex;
|
|
|
|
void init();
|
|
void play();
|
|
void stop();
|
|
void close();
|
|
void clearBuffer();
|
|
|
|
template <typename Iterator>
|
|
void appendBuffer(const Iterator& start, const Iterator& end) {
|
|
std::unique_lock<std::mutex> lock(audioMutex);
|
|
|
|
if (buffer.size() > 512 * 32) {
|
|
buffer.clear();
|
|
}
|
|
buffer.insert(buffer.end(), start, end);
|
|
}
|
|
}; // namespace Sound
|