Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
proxy_sound_manager.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2023 DS
4
5#pragma once
6
7#include "sound_manager.h"
8
9namespace sound {
10
11/*
12 * The public ISoundManager interface
13 */
14
15class ProxySoundManager final : public ISoundManager
16{
18 // sound names from loadSoundData and loadSoundFile
19 std::unordered_set<std::string> m_known_sound_names;
20
22 {
24 }
25
26 enum class MsgResult { Ok, Empty, Stopped};
28
29public:
31 std::unique_ptr<SoundFallbackPathProvider> fallback_path_provider) :
32 m_sound_manager(smg, std::move(fallback_path_provider))
33 {
35 }
36
37 ~ProxySoundManager() override;
38
39 /* Interface */
40
41 void step(f32 dtime) override;
42 void pauseAll() override;
43 void resumeAll() override;
44
45 void updateListener(const v3f &pos_, const v3f &vel_, const v3f &at_, const v3f &up_) override;
46 void setListenerGain(f32 gain) override;
47
48 bool loadSoundFile(const std::string &name, const std::string &filepath) override;
49 bool loadSoundData(const std::string &name, std::string &&filedata) override;
50 void addSoundToGroup(const std::string &sound_name, const std::string &group_name) override;
51
52 void playSound(sound_handle_t id, const SoundSpec &spec) override;
53 void playSoundAt(sound_handle_t id, const SoundSpec &spec, const v3f &pos_,
54 const v3f &vel_) override;
55 void stopSound(sound_handle_t sound) override;
56 void fadeSound(sound_handle_t soundid, f32 step, f32 target_gain) override;
57 void updateSoundPosVel(sound_handle_t sound, const v3f &pos_, const v3f &vel_) override;
58};
59
60} // namespace sound
Definition sound.h:46
void push_back(const T &t)
Definition container.h:130
bool start()
Definition thread.cpp:109
Definition sound_manager.h:35
MutexedQueue< SoundManagerMsgToMgr > m_queue_to_mgr
Definition sound_manager.h:72
Definition proxy_sound_manager.h:16
void send(SoundManagerMsgToMgr msg)
Definition proxy_sound_manager.h:21
bool loadSoundData(const std::string &name, std::string &&filedata) override
Same as loadSoundFile, but reads the OggVorbis file from memory.
Definition proxy_sound_manager.cpp:104
~ProxySoundManager() override
Definition proxy_sound_manager.cpp:30
void pauseAll() override
Pause all sound playback.
Definition proxy_sound_manager.cpp:66
void resumeAll() override
Resume sound playback after pause.
Definition proxy_sound_manager.cpp:71
void addSoundToGroup(const std::string &sound_name, const std::string &group_name) override
Adds sound with name sound_name to group group_name.
Definition proxy_sound_manager.cpp:116
void playSoundAt(sound_handle_t id, const SoundSpec &spec, const v3f &pos_, const v3f &vel_) override
Same as playSound, but at a position.
Definition proxy_sound_manager.cpp:129
void updateListener(const v3f &pos_, const v3f &vel_, const v3f &at_, const v3f &up_) override
Definition proxy_sound_manager.cpp:76
MsgResult
Definition proxy_sound_manager.h:26
void setListenerGain(f32 gain) override
Definition proxy_sound_manager.cpp:82
bool loadSoundFile(const std::string &name, const std::string &filepath) override
Adds a sound to load from a file (only OggVorbis).
Definition proxy_sound_manager.cpp:87
std::unordered_set< std::string > m_known_sound_names
Definition proxy_sound_manager.h:19
void playSound(sound_handle_t id, const SoundSpec &spec) override
Plays a random sound from a sound group (position-less).
Definition proxy_sound_manager.cpp:122
void step(f32 dtime) override
Removes finished sounds, steps streamed sounds, and does similar tasks.
Definition proxy_sound_manager.cpp:51
void stopSound(sound_handle_t sound) override
Request the sound to be stopped.
Definition proxy_sound_manager.cpp:137
MsgResult handleMsg(SoundManagerMsgToProxy &&msg)
Definition proxy_sound_manager.cpp:11
void fadeSound(sound_handle_t soundid, f32 step, f32 target_gain) override
Definition proxy_sound_manager.cpp:142
OpenALSoundManager m_sound_manager
Definition proxy_sound_manager.h:17
ProxySoundManager(SoundManagerSingleton *smg, std::unique_ptr< SoundFallbackPathProvider > fallback_path_provider)
Definition proxy_sound_manager.h:30
void updateSoundPosVel(sound_handle_t sound, const v3f &pos_, const v3f &vel_) override
Update position and velocity of positional sound.
Definition proxy_sound_manager.cpp:147
Class for the openal device and context.
Definition sound_singleton.h:20
int sound_handle_t
Definition client.h:62
core::vector3df v3f
Definition irr_v3d.h:11
Definition al_extensions.cpp:11
std::variant< std::monostate, sound_manager_messages_to_proxy::ReportRemovedSound, sound_manager_messages_to_proxy::Stopped > SoundManagerMsgToProxy
Definition sound_manager_messages.h:61
std::variant< std::monostate, sound_manager_messages_to_mgr::PauseAll, sound_manager_messages_to_mgr::ResumeAll, sound_manager_messages_to_mgr::UpdateListener, sound_manager_messages_to_mgr::SetListenerGain, sound_manager_messages_to_mgr::LoadSoundFile, sound_manager_messages_to_mgr::LoadSoundData, sound_manager_messages_to_mgr::AddSoundToGroup, sound_manager_messages_to_mgr::PlaySound, sound_manager_messages_to_mgr::PlaySoundAt, sound_manager_messages_to_mgr::StopSound, sound_manager_messages_to_mgr::FadeSound, sound_manager_messages_to_mgr::UpdateSoundPosVel, sound_manager_messages_to_mgr::PleaseStop > SoundManagerMsgToMgr
Definition sound_manager_messages.h:33
Describes the sound information for playback.
Definition sound.h:20