载入中...
搜索中...
未找到
Audio.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Module.h"
6#include "common/Data.h"
7
8#include <AL/alc.h>
9
10#include <atomic>
11#include <condition_variable>
12#include <mutex>
13#include <thread>
14#include <vector>
15
16namespace eve {
17namespace sound {
18class SoundData;
19class Decoder;
20} // namespace sound
21namespace audio {
22
23class Source;
24
30public:
32
34 Audio();
36 ~Audio() override;
37
42 Source *newSource(sound::SoundData *data);
44 Source *newSourceFromDecoder(sound::Decoder *decoder, std::string type);
46 Source *newSourceFromData(Data *data, std::string type);
47
49 void play(Source *s);
51 void stop(Source *s);
53 void stopAll();
55 [[nodiscard]] int getSourceCount();
57 void pause(Source *s);
58
60 void setVolume(float v);
62 float getVolume() const;
63
65 void setPosition(float x, float y, float z);
67 void setVelocity(float x, float y, float z);
69 void setOrientation(float fx, float fy, float fz, float ux, float uy, float uz);
70
72 void pump();
73
75 void registerStream(Source *s);
77 void unregisterStream(Source *s);
79 void unregisterSource(Source *s);
81 void notifyWorker();
82
83private:
84 void workerMain();
85
86 ALCdevice *device = nullptr;
87 ALCcontext *context = nullptr;
88 float masterVolume = 1.f;
89
90 std::mutex mutex;
91 std::condition_variable cv;
92 std::atomic<bool> running{true};
93 std::thread worker;
94 std::vector<Source *> streamSources;
95 std::vector<Source *> allSources;
96};
97
98} // namespace audio
99} // namespace eve
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
OwnedAudio audio
const std::string & s
std::mutex mutex
#define EVENGINE_API_BACKENDS
Definition Export.h:108
vkb::Device & device
float v
const VegetationPresetContext & context
Data public API.
Definition Data.h:8
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
OpenAL audio module: device management, master listener state, and Source factory....
Definition Audio.h:29
A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control ex...
Definition Source.h:30
Streaming audio decoder (medialoader-backed). Owns the raw encoded bytes and decodes incrementally vi...
Definition Decoder.h:22
Raw PCM audio buffer with format metadata (samples/rate/bit depth/channels).
Definition SoundData.h:15
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16