Sound: Expose less stuff to outer world

This commit is contained in:
korenkonder
2026-02-02 09:59:44 +03:00
parent ec0c690bd1
commit 292decf255
3 changed files with 759 additions and 756 deletions
+758 -588
View File
File diff suppressed because it is too large Load Diff
-168
View File
@@ -7,7 +7,6 @@
#include "../KKdLib/default.hpp"
#include "../KKdLib/time.hpp"
#include "../KKdLib/farc.hpp"
#include "file_handler.hpp"
#include <atomic>
#include <map>
@@ -156,170 +155,6 @@ namespace sound {
}
}
enum SoundCueDataState {
SOUND_CUE_DATA_STATE_NONE = 0,
SOUND_CUE_DATA_STATE_LOAD,
SOUND_CUE_DATA_STATE_RESET,
SOUND_CUE_DATA_STATE_MAX,
};
enum WaveAudioDataFormat {
WAVE_AUDIO_DATA_FORMAT_NONE = 0,
WAVE_AUDIO_DATA_FORMAT_RIFF = 1,
WAVE_AUDIO_DATA_FORMAT_DIVA = 3,
};
struct sound_db_farc {
std::string file_path;
bool ready;
p_file_handler file_handler;
farc farc;
sound_db_farc();
~sound_db_farc();
bool load();
bool read(const char* file_path);
bool unload();
};
struct sound_db_property {
sound_db_farc* farc;
std::string file_name;
float_t volume;
size_t loop_start;
size_t loop_end;
float_t release_time;
//std::string field_28;
//int32_t field_48;
sound_db_property();
~sound_db_property();
};
struct SoundCue;
struct SoundCueVolume {
SoundCue* cue;
float_t value;
bool set;
inline SoundCueVolume(SoundCue* cue) : cue(cue), value(), set() {
}
inline void SetValue(float_t value) {
this->value = value;
set = true;
}
};
struct SoundCue {
std::atomic_uint32_t thread_state;
std::atomic_uint32_t data_state;
std::thread* thread;
std::mutex mtx;
std::condition_variable cnd;
SoundCueVolume* volume;
int32_t queue_index;
std::string name;
sound_db_property* property;
int32_t counter;
float_t release_time;
time_struct time;
std::atomic_uint32_t load_state;
sound::wasapi::SEChannel* se_channel;
SoundCue();
~SoundCue();
bool CanPlay();
void Ctrl();
int32_t Load(int32_t queue_index, const char* name, float_t volume);
void LoadData();
void Play();
void PlayProt();
void Release(bool force_release);
void ReleaseProt(bool force_release);
void Reset();
void ResetData();
void SetSEChannel(sound::wasapi::SEChannel* se_channel);
static void ThreadMain(SoundCue* cue);
};
struct WaveAudioDataFileMemoryStream {
FILE* file;
const void* data;
size_t size;
size_t position;
inline WaveAudioDataFileMemoryStream(const void* data, size_t size) : file(),
data(data), size(size), position() {
}
};
struct WaveAudioData {
WaveAudioDataFormat format;
size_t channels;
size_t sample_rate;
size_t bit_depth;
size_t samples_count;
size_t position;
size_t data_size;
bool has_loop;
size_t loop_start;
size_t loop_end;
WaveAudioData();
~WaveAudioData();
bool Read(WaveAudioDataFileMemoryStream* fms);
bool ReadData(const void* data, size_t size);
bool ReadDiva(WaveAudioDataFileMemoryStream* fms);
void Reset();
};
struct WaveAudio {
float_t* buffer;
size_t buffer_size;
WaveAudioData data;
WaveAudio();
bool Read(sound_db_farc* farc, const char* file_name);
void Reset();
};
#define SOUND_WORK_SE_QUEUE_COUNT 5
#define SOUND_WORK_STREAM_COUNT 3
#define SOUND_WORK_SE_CHANNELS_COUNT 32
#define SOUND_WORK_STREAMING_CHANNELS_COUNT 4
struct SoundWork {
std::map<std::string, sound_db_property> properties;
sound_db_farc farcs[16];
SoundCue cues[SOUND_WORK_SE_CHANNELS_COUNT];
int32_t counter;
std::vector<std::string> names_list;
bool se_queue_enable[SOUND_WORK_SE_QUEUE_COUNT];
bool stream_enable[SOUND_WORK_STREAM_COUNT];
float_t speakers_volume;
bool speakers_volume_changed;
float_t headphones_volume;
bool headphones_volume_changed;
float_t se_queue_volume[5];
float_t se_volume;
SoundWork();
virtual ~SoundWork();
sound_db_property* FindProperty(const char* name);
bool ParseProperty(sound_db_farc* snd_db_farc);
bool UnloadProperty(const char* file_path);
};
struct sound_stream_info {
float_t duration;
float_t time;
@@ -348,9 +183,7 @@ extern void sound_stream_array_reset();
extern bool sound_work_check_stream_state(int32_t index);
extern bool sound_work_cue_release(int32_t queue_index, const char* name, bool force_release = true);
extern SoundCue* sound_work_get_cue(int32_t queue_index, const char* name);
extern bool sound_work_get_cue_can_play(int32_t queue_index, const char* name);
extern sound_db_farc* sound_work_get_farc(const char* file_path);
extern bool sound_work_get_stream_info(sound_stream_info& info, int32_t index);
extern float_t sound_work_get_stream_volume(int32_t index);
extern float_t sound_work_get_headphones_volume();
@@ -378,7 +211,6 @@ extern bool sound_work_unload_farc(const char* file_path);
extern void wave_audio_storage_init();
extern void wave_audio_storage_clear();
extern WaveAudio* wave_audio_storage_get_wave_audio(const std::string& name);
extern bool wave_audio_storage_load_wave_audio(const std::string& name);
extern void wave_audio_storage_unload_wave_audio(const std::string& name);
extern void wave_audio_storage_free();
+1
View File
@@ -52,6 +52,7 @@
#include "../KKdLib/database/item_table.hpp"
#include "../KKdLib/io/path.hpp"
#include "../KKdLib/prj/algorithm.hpp"
#include "../KKdLib/farc.hpp"
#include "../KKdLib/timer.hpp"
#include "../KKdLib/sort.hpp"
#include "../KKdLib/str_utils.hpp"