From 4d3f2aadbf3bd32372d715e3911a8945dbc0d705 Mon Sep 17 00:00:00 2001 From: H0neyBadger Date: Wed, 23 Dec 2020 18:43:22 +0100 Subject: [PATCH] Improve Switch Registration Logs and Audio Level (#409) --- switch/src/host.cpp | 11 +++++++++-- switch/src/io.cpp | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/switch/src/host.cpp b/switch/src/host.cpp index 200f74d..2315975 100644 --- a/switch/src/host.cpp +++ b/switch/src/host.cpp @@ -118,13 +118,20 @@ int Host::Register(std::string pin) else { CHIAKI_LOGE(this->log, "Undefined PS4 system version (please run discover first)"); + throw Exception("Undefined PS4 system version (please run discover first)"); } this->regist_info.pin = atoi(pin.c_str()); this->regist_info.host = this->host_addr.c_str(); this->regist_info.broadcast = false; - CHIAKI_LOGI(this->log, "Registering to host `%s` `%s` with PSN AccountID `%s` pin `%s`", - this->host_name.c_str(), this->host_addr.c_str(), psn_account_id.c_str(), pin.c_str()); + + if(this->system_version >= 7000000) + CHIAKI_LOGI(this->log, "Registering to host `%s` `%s` with PSN AccountID `%s` pin `%s`", + this->host_name.c_str(), this->host_addr.c_str(), account_id.c_str(), pin.c_str()); + else + CHIAKI_LOGI(this->log, "Registering to host `%s` `%s` with PSN OnlineID `%s` pin `%s`", + this->host_name.c_str(), this->host_addr.c_str(), online_id.c_str(), pin.c_str()); + chiaki_regist_start(&this->regist, this->log, &this->regist_info, RegistEventCB, this); return HOST_REGISTER_OK; } diff --git a/switch/src/io.cpp b/switch/src/io.cpp index 3b02f83..3e15bd0 100644 --- a/switch/src/io.cpp +++ b/switch/src/io.cpp @@ -243,8 +243,25 @@ void IO::InitAudioCB(unsigned int channels, unsigned int rate) void IO::AudioCB(int16_t * buf, size_t samples_count) { - //int az = SDL_GetQueuedAudioSize(host->audio_device_id); - // len the number of bytes (not samples!) to which (data) points + for(int x=0; x < samples_count*2; x++) + { + // boost audio volume + int sample = buf[x]*1.80; + // Hard clipping (audio compression) + // truncate value that overflow/underflow int16 + if(sample > INT16_MAX) + { + buf[x] = INT16_MAX; + CHIAKI_LOGD(this->log, "Audio Hard clipping INT16_MAX < %d", sample); + } + else if(sample < INT16_MIN) + { + buf[x] = INT16_MIN; + CHIAKI_LOGD(this->log, "Audio Hard clipping INT16_MIN > %d", sample); + } + else + buf[x] = (int16_t) sample; + } int success = SDL_QueueAudio(this->sdl_audio_device_id, buf, sizeof(int16_t)*samples_count*2); if(success != 0) CHIAKI_LOGE(this->log, "SDL_QueueAudio failed: %s\n", SDL_GetError());