PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
Audio.hpp
1#pragma once
2
3#include "PixelBullet/Audio/CommandQueue.hpp"
4#include "PixelBullet/Audio/AudioBackend.hpp"
5
6#include <atomic>
7#include <functional>
8#include <string>
9#include <thread>
10#include <memory>
11
12namespace PixelBullet
13{
14 class VirtualPath;
15
19 class Audio
20 {
21 public:
22 Audio();
23 ~Audio();
24
25 Audio(const Audio&) = delete;
26 Audio& operator=(const Audio&) = delete;
27
29 void PlaySound(const VirtualPath& filePath, bool loop = false);
30
31 private:
33 bool Init();
35 void Shutdown();
37 void AudioThreadLoop();
39 void SubmitCommand(const std::function<void()>& command);
40
41 private:
42 std::thread m_AudioThread;
43 std::atomic<bool> m_Running;
44 CommandQueue m_CommandQueue;
45 std::unique_ptr<AudioBackend> m_Backend;
46 };
47} // namespace PixelBullet
Definition Audio.hpp:20
void PlaySound(const VirtualPath &filePath, bool loop=false)
Play a sound given its file path. If loop is true the sound will restart endlessly.
Definition Audio.cpp:55
A simple thread-safe command queue.
Definition CommandQueue.hpp:13
Definition VirtualPath.hpp:11