mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-10 16:18:35 +03:00
Small changes in formatting
This commit is contained in:
+27
-35
@@ -217,7 +217,7 @@ int32_t OggFile::GetRate() {
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
if (info)
|
||||
return info->rate;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool OggFile::HasLoop() {
|
||||
@@ -249,9 +249,8 @@ bool OggFile::OpenFile(const char* path, double_t time_seek) {
|
||||
goto Reset;
|
||||
}
|
||||
|
||||
char** user_comments = comments->user_comments;
|
||||
while (*user_comments) {
|
||||
std::string user_comment = *user_comments++;
|
||||
for (char** user_comments = comments->user_comments; *user_comments; user_comments++) {
|
||||
std::string user_comment(*user_comments);
|
||||
for (char& c : user_comment)
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c += 0x20;
|
||||
@@ -314,9 +313,8 @@ void OggFile::ThreadMain(OggFile* of) {
|
||||
of->thread_state = 0;
|
||||
}
|
||||
|
||||
OggFileHandler::OggFileHandler(size_t index) : load_time_seek(), channel_pairs_count(),
|
||||
duration(), time(), channel_pairs_count_dup(), duration_dup(), time_dup(),
|
||||
channel_pair_volume_pan(), master_volume(), channel_pair_volume(), req_time(), loop() {
|
||||
OggFileHandler::OggFileHandler(size_t index) : load_time_seek(), file_info(), playback_info(),
|
||||
channel_pair_volume_pan(), master_volume(), channel_pair_volume(), req_time(), loop() {
|
||||
this->index = index;
|
||||
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
@@ -375,7 +373,7 @@ void OggFileHandler::Ctrl() {
|
||||
if (streaming_channel) {
|
||||
switch (_playback_state) {
|
||||
case OGG_FILE_HANDLER_PLAYBACK_STATE_LOAD:
|
||||
if (sound_wasapi_system->pClockAdjustment)
|
||||
if (sound_wasapi_system->pClockAdjustment) // Added
|
||||
sound_wasapi_system->pClockAdjustment->SetSampleRate((float_t)rate);
|
||||
|
||||
streaming_channel->SetMasterVolume(1.0f);
|
||||
@@ -389,22 +387,16 @@ void OggFileHandler::Ctrl() {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t _channel_pairs_count = 0;
|
||||
double_t _duration = 0.0;
|
||||
double_t _time = 0.0;
|
||||
OggFileHandlerInfo _info = {};
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
_channel_pairs_count = channel_pairs_count;
|
||||
_duration = duration;
|
||||
_time = time;
|
||||
_info = file_info;
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
channel_pairs_count_dup = _channel_pairs_count;
|
||||
duration_dup = _duration;
|
||||
time_dup = _time;
|
||||
std::unique_lock<std::mutex> u_lock(playback_mtx);
|
||||
playback_info = _info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,13 +415,13 @@ void OggFileHandler::FillBuffer(sound_buffer_data* buffer, size_t samples_count)
|
||||
}
|
||||
|
||||
int32_t OggFileHandler::GetChannelPairsCount() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return channel_pairs_count_dup;
|
||||
std::unique_lock<std::mutex> u_lock(playback_mtx);
|
||||
return (int32_t)playback_info.channel_pairs_count;
|
||||
}
|
||||
|
||||
float_t OggFileHandler::GetDuration() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return (float_t)duration_dup;
|
||||
std::unique_lock<std::mutex> u_lock(playback_mtx);
|
||||
return (float_t)playback_info.duration;
|
||||
}
|
||||
|
||||
OggFileHandlerFileState OggFileHandler::GetFileState() {
|
||||
@@ -441,16 +433,16 @@ OggFileHandlerPauseState OggFileHandler::GetPauseState() {
|
||||
}
|
||||
|
||||
float_t OggFileHandler::GetTime() {
|
||||
std::unique_lock<std::mutex> u_lock(dup_mtx);
|
||||
return (float_t)time_dup;
|
||||
std::unique_lock<std::mutex> u_lock(playback_mtx);
|
||||
return (float_t)playback_info.time;
|
||||
}
|
||||
|
||||
void OggFileHandler::OpenFile() {
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
if (file.OpenFile(path.c_str(), load_time_seek)) {
|
||||
channel_pairs_count = file.GetChannelPairsCount();
|
||||
duration = file.GetDuration();
|
||||
time = 0.0;
|
||||
file_info.channel_pairs_count = file.GetChannelPairsCount();
|
||||
file_info.duration = file.GetDuration();
|
||||
file_info.time = 0.0;
|
||||
rate = file.GetRate();
|
||||
loop = file.HasLoop();
|
||||
}
|
||||
@@ -518,8 +510,8 @@ void OggFileHandler::ReadBufferProt(sound_buffer_data* buffer, size_t samples_co
|
||||
bool process = false;
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
time = req_time;
|
||||
process = req_time < duration;
|
||||
file_info.time = req_time;
|
||||
process = req_time < file_info.duration;
|
||||
}
|
||||
|
||||
if (process || loop)
|
||||
@@ -532,9 +524,9 @@ void OggFileHandler::Reset(bool reset) {
|
||||
if (reset) {
|
||||
SetFileState(OGG_FILE_HANDLER_FILE_STATE_STOPPING);
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
channel_pairs_count = 0;
|
||||
duration = 0.0;
|
||||
time = 0.0;
|
||||
file_info.channel_pairs_count = 0;
|
||||
file_info.duration = 0.0;
|
||||
file_info.time = 0.0;
|
||||
}
|
||||
|
||||
file.Reset();
|
||||
@@ -591,9 +583,9 @@ void OggFileHandler::SetPath(const std::string& path) {
|
||||
{
|
||||
std::unique_lock<std::mutex> u_lock(file_mtx);
|
||||
this->path.assign(path);
|
||||
channel_pairs_count = 0;
|
||||
duration = 0.0;
|
||||
time = 0.0;
|
||||
file_info.channel_pairs_count = 0;
|
||||
file_info.duration = 0.0;
|
||||
file_info.time = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,12 @@ struct OggFile {
|
||||
static void ThreadMain(OggFile* of);
|
||||
};
|
||||
|
||||
struct OggFileHandlerInfo {
|
||||
int64_t channel_pairs_count;
|
||||
double_t duration;
|
||||
double_t time;
|
||||
};
|
||||
|
||||
struct OggFileHandler {
|
||||
std::mutex mtx;
|
||||
std::atomic_uint32_t thread_state;
|
||||
@@ -109,13 +115,9 @@ struct OggFileHandler {
|
||||
std::mutex file_mtx;
|
||||
std::string path;
|
||||
float_t load_time_seek;
|
||||
int32_t channel_pairs_count;
|
||||
double_t duration;
|
||||
double_t time;
|
||||
std::mutex dup_mtx;
|
||||
int32_t channel_pairs_count_dup;
|
||||
double_t duration_dup;
|
||||
double_t time_dup;
|
||||
OggFileHandlerInfo file_info;
|
||||
std::mutex playback_mtx;
|
||||
OggFileHandlerInfo playback_info;
|
||||
std::mutex volume_mtx;
|
||||
int32_t channel_pair_volume_pan[4][2][4];
|
||||
int32_t master_volume;
|
||||
|
||||
+12
-14
@@ -108,9 +108,8 @@ static size_t ima_decode(int16_t* dst, size_t dst_size, uint8_t* data, size_t sa
|
||||
|
||||
namespace sound {
|
||||
namespace wasapi {
|
||||
System::System() : wave_format(), pEnumerator(), pDevice(), pAudioClient(),
|
||||
samples_count(), pRenderClient(), pClockAdjustment(), hEvent(),
|
||||
channels(), sample_rate(), bit_depth(), mixer(), thread(), format() {
|
||||
System::System() : wave_format(), pEnumerator(), pDevice(), pAudioClient(), samples_count(),
|
||||
pRenderClient(), pClockAdjustment(), hEvent(), config(), mixer(), thread(), format() {
|
||||
|
||||
}
|
||||
|
||||
@@ -187,9 +186,9 @@ namespace sound {
|
||||
return;
|
||||
}
|
||||
|
||||
this->channels = channels;
|
||||
this->sample_rate = sample_rate;
|
||||
this->bit_depth = bit_depth;
|
||||
this->config.channels = channels;
|
||||
this->config.sample_rate = sample_rate;
|
||||
this->config.bit_depth = bit_depth;
|
||||
|
||||
mixer = new Mixer(this);
|
||||
if (!mixer)
|
||||
@@ -264,7 +263,7 @@ namespace sound {
|
||||
pAudioClient->Start();
|
||||
}
|
||||
|
||||
if (SUCCEEDED(pAudioClient->GetService(__uuidof(IAudioClockAdjustment), (void**)&pClockAdjustment)))
|
||||
if (SUCCEEDED(pAudioClient->GetService(__uuidof(IAudioClockAdjustment), (void**)&pClockAdjustment))) // Added
|
||||
pClockAdjustment->SetSampleRate((float_t)44100);
|
||||
}
|
||||
|
||||
@@ -279,7 +278,7 @@ namespace sound {
|
||||
if (pAudioClient)
|
||||
pAudioClient->Stop();
|
||||
|
||||
if (pClockAdjustment) {
|
||||
if (pClockAdjustment) { // Added
|
||||
pClockAdjustment->Release();
|
||||
pClockAdjustment = 0;
|
||||
}
|
||||
@@ -378,7 +377,7 @@ namespace sound {
|
||||
switch (format) {
|
||||
case AUDIO_FORMAT_I16: {
|
||||
int16_t* _buffer = (int16_t*)buffer;
|
||||
switch (system->channels) {
|
||||
switch (system->config.channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z * (float_t)0x7FFF;
|
||||
@@ -401,7 +400,7 @@ namespace sound {
|
||||
} break;
|
||||
case AUDIO_FORMAT_I24: {
|
||||
int8_t* _buffer = (int8_t*)buffer;
|
||||
switch (system->channels) {
|
||||
switch (system->config.channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z * (float_t)0x7FFFFF;
|
||||
@@ -436,7 +435,7 @@ namespace sound {
|
||||
} break;
|
||||
case AUDIO_FORMAT_I32: {
|
||||
int32_t* _buffer = (int32_t*)buffer;
|
||||
switch (system->channels) {
|
||||
switch (system->config.channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++) {
|
||||
vec2 hph = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z;
|
||||
@@ -463,7 +462,7 @@ namespace sound {
|
||||
} break;
|
||||
case AUDIO_FORMAT_F32: {
|
||||
float_t* _buffer = (float_t*)buffer;
|
||||
switch (system->channels) {
|
||||
switch (system->config.channels) {
|
||||
case 2:
|
||||
for (size_t i = samples_count; i; i--, _mix_buffer++, _buffer += 2)
|
||||
*(vec2*)_buffer = *(vec2*)&_mix_buffer->hph_l * *(vec2*)&spk_hph_volume.z;
|
||||
@@ -812,8 +811,7 @@ namespace sound {
|
||||
callback_data = 0;
|
||||
}
|
||||
|
||||
bool StreamingChannel::SetCallback(void(*func)(sound_buffer_data* buffer,
|
||||
size_t samples_count, void* data), void* data) {
|
||||
bool StreamingChannel::SetCallback(CallbackFunc func, void* data) {
|
||||
std::unique_lock<std::mutex> u_lock(mtx);
|
||||
ResetData();
|
||||
callback_func = func;
|
||||
|
||||
+15
-8
@@ -41,21 +41,26 @@ namespace sound {
|
||||
struct StreamingChannel;
|
||||
|
||||
struct System {
|
||||
struct Config {
|
||||
int64_t channels;
|
||||
int64_t sample_rate;
|
||||
int64_t bit_depth;
|
||||
};
|
||||
|
||||
WAVEFORMATEXTENSIBLE wave_format;
|
||||
IMMDeviceEnumerator* pEnumerator;
|
||||
IMMDevice* pDevice;
|
||||
IAudioClient* pAudioClient;
|
||||
uint32_t samples_count;
|
||||
IAudioRenderClient* pRenderClient;
|
||||
IAudioClockAdjustment* pClockAdjustment;
|
||||
HANDLE hEvent;
|
||||
int32_t channels;
|
||||
int32_t sample_rate;
|
||||
int32_t bit_depth;
|
||||
Config config;
|
||||
Mixer* mixer;
|
||||
std::thread* thread;
|
||||
std::atomic_uint32_t thread_state;
|
||||
AudioFormat format;
|
||||
|
||||
AudioFormat format; // Added
|
||||
IAudioClockAdjustment* pClockAdjustment; // Added
|
||||
|
||||
System();
|
||||
virtual ~System();
|
||||
@@ -122,6 +127,9 @@ namespace sound {
|
||||
};
|
||||
|
||||
struct StreamingChannel {
|
||||
typedef void(*CallbackFunc)(sound_buffer_data* buffer,
|
||||
size_t samples_count, void* data);
|
||||
|
||||
Mixer* mixer;
|
||||
sound_buffer_data* buffer;
|
||||
size_t buffer_size;
|
||||
@@ -130,7 +138,7 @@ namespace sound {
|
||||
std::mutex mtx;
|
||||
float_t master_volume;
|
||||
float_t channels_volume[4];
|
||||
void(*callback_func)(sound_buffer_data* buffer, size_t samples_count, void* data);
|
||||
CallbackFunc callback_func;
|
||||
void* callback_data;
|
||||
|
||||
StreamingChannel();
|
||||
@@ -140,8 +148,7 @@ namespace sound {
|
||||
bool Init(Mixer* mixer, size_t samples_count);
|
||||
void Reset();
|
||||
void ResetData();
|
||||
bool SetCallback(void(*func)(sound_buffer_data* buffer,
|
||||
size_t samples_count, void* data), void* data);
|
||||
bool SetCallback(CallbackFunc func, void* data);
|
||||
void SetChannelsVolume(int32_t mask, float_t value);
|
||||
void SetMasterVolume(float_t value);
|
||||
};
|
||||
|
||||
@@ -299,7 +299,7 @@ field_index(), edit_effect_index(), slidertouch_counter(), change_field_branch_s
|
||||
field_2D080(), field_2D084(), life_gauge_bonus(), life_gauge_total_bonus(), field_2D090(), no_clear(),
|
||||
disp_lyrics_now(), field_2D093(), field_2D094(), field_2D095(), field_2D096(), success(), title_image_state(),
|
||||
field_2D09C(), use_osage_play_data(), pv_end_fadeout(), rival_percentage(), field_2D0A8(), field_2D0AC(),
|
||||
field_2D0B0(), field_2D0BC(), next_stage(), has_frame_texture(), field_2D0BF(), field_2D0C0(), field_2D0C4(),
|
||||
field_2D0B0(), field_2D0BC(), next_stage(), has_frame_texture(), field_2D0BF(), movie_index(), field_2D0C4(),
|
||||
field_2D7E8(), field_2D7EC(), field_2D808(), field_2D80C(), edit_effect(), camera_auth_3d_uid(),
|
||||
se_index(), task_effect_init(), field_2D87C(), current_field(), field_2D8A0(), field_2D8A4(),
|
||||
campv_index(), field_2D954(), field_2DAC8(), field_2DACC(), height_adjust(), field_2DB2C(), field_2DB34() {
|
||||
@@ -852,7 +852,7 @@ field_4(), state(), field_C(), pv_id(), field_14(), modules(), items() {
|
||||
data.field_2D0BC = false;
|
||||
data.next_stage = false;
|
||||
data.has_frame_texture = false;
|
||||
data.field_2D0C0 = -1;
|
||||
data.movie_index = -1;
|
||||
data.no_fail = true;
|
||||
data.task_effect_init = false;
|
||||
|
||||
@@ -4105,7 +4105,7 @@ void pv_game::reset() {
|
||||
data.field_2D0BC = false;
|
||||
data.next_stage = false;
|
||||
data.has_frame_texture = false;
|
||||
data.field_2D0C0 = -1;
|
||||
data.movie_index = -1;
|
||||
|
||||
data.field_2CE98 = 0;
|
||||
|
||||
@@ -4669,7 +4669,7 @@ bool pv_game::unload() {
|
||||
data.notes_passed = 0;
|
||||
data.field_2CFF0 = 0;
|
||||
data.field_2CFE0 = 0;
|
||||
data.field_2D0C0 = -1;
|
||||
data.movie_index = -1;
|
||||
|
||||
light_param_data_storage_data_reset();
|
||||
|
||||
@@ -4885,7 +4885,7 @@ void pv_game::sub_140106640() {
|
||||
data.field_2D0BC = false;
|
||||
data.next_stage = false;
|
||||
data.has_frame_texture = false;
|
||||
data.field_2D0C0 = -1;
|
||||
data.movie_index = -1;
|
||||
|
||||
for (int32_t& i : data.total_hit_count)
|
||||
i = 0;
|
||||
|
||||
@@ -247,7 +247,7 @@ struct pv_game_data {
|
||||
bool next_stage;
|
||||
bool has_frame_texture;
|
||||
int8_t field_2D0BF;
|
||||
int32_t field_2D0C0;
|
||||
int32_t movie_index;
|
||||
int32_t field_2D0C4;
|
||||
pv_game_chara chara[ROB_CHARA_COUNT];
|
||||
std::vector<uint32_t> motion_set_ids;
|
||||
|
||||
@@ -1712,7 +1712,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time,
|
||||
/*if (pv_game_get()->loaded && v408 && app::TaskWork::check_task_ready(task_movie_get(0))) {
|
||||
v410 = task_movie_get(0);
|
||||
task_movie_get(0)->sub_14041EF10();
|
||||
pv_game_get()->data.field_2D0C0 = 0;
|
||||
pv_game_get()->data.movie_index = 0;
|
||||
sub_14041F1D0(curr_time);
|
||||
}*/
|
||||
} break;
|
||||
@@ -1726,7 +1726,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time,
|
||||
continue;
|
||||
|
||||
int32_t v415 = 0;
|
||||
if (pv_game_get()->data.field_2D0C0 == i) {
|
||||
if (pv_game_get()->data.movie_index == i) {
|
||||
if (pv_game->data.field_2D8A0)
|
||||
switch (v412) {
|
||||
case 1:
|
||||
@@ -1981,7 +1981,7 @@ bool pv_game_pv_data::dsc_ctrl(float_t delta_time, int64_t curr_time,
|
||||
|
||||
if (v486 != -1 && app::TaskWork::check_task_ready(task_movie_get(v486))) {
|
||||
task_movie_get(v486)->sub_14041EF10((__int64)v492);
|
||||
pv_game_get()->data.field_2D0C0 = v486;
|
||||
pv_game_get()->data.movie_index = v486;
|
||||
//sub_14041F210(curr_time);
|
||||
if (!pv_game->data.field_2D8A0)
|
||||
v487 = 0;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace app {
|
||||
|
||||
TaskWindow();
|
||||
~TaskWindow();
|
||||
|
||||
virtual void window() = 0;
|
||||
|
||||
void hide_window();
|
||||
|
||||
Reference in New Issue
Block a user