From 182d672c15ab2c0e4ffb66f219ce7a02f56d1374 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 6 Mar 2019 20:03:22 -0700 Subject: [PATCH] Add ifdef around cubeb for android. Address a few review comments --- src/audio_core/CMakeLists.txt | 8 ++------ src/citra_qt/configuration/configure_audio.cpp | 5 ++++- src/core/frontend/mic.cpp | 5 ++--- src/core/hle/service/mic_u.cpp | 17 ++++++----------- src/core/settings.cpp | 4 ++++ 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index fc298323fb..caddd0a3ac 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -2,10 +2,6 @@ add_library(audio_core STATIC audio_types.h codec.cpp codec.h - cubeb_input.cpp - cubeb_input.h - cubeb_sink.cpp - cubeb_sink.h dsp_interface.cpp dsp_interface.h hle/adts.h @@ -34,7 +30,7 @@ add_library(audio_core STATIC time_stretch.h $<$:sdl2_sink.cpp sdl2_sink.h> - $<$:cubeb_sink.cpp cubeb_sink.h> + $<$:cubeb_sink.cpp cubeb_sink.h cubeb_input.cpp cubeb_input.h> $<$:hle/ffmpeg_decoder.cpp hle/ffmpeg_decoder.h hle/ffmpeg_dl.cpp hle/ffmpeg_dl.h> $<$:hle/wmf_decoder.cpp hle/wmf_decoder.h hle/wmf_decoder_utils.cpp hle/wmf_decoder_utils.h> ) @@ -65,6 +61,6 @@ endif() if(ENABLE_CUBEB) target_link_libraries(audio_core PRIVATE cubeb) - add_definitions(-DHAVE_CUBEB=1) + target_compile_definitions(audio_core PUBLIC HAVE_CUBEB) endif() diff --git a/src/citra_qt/configuration/configure_audio.cpp b/src/citra_qt/configuration/configure_audio.cpp index e84c2f14d5..e9d700c9b9 100644 --- a/src/citra_qt/configuration/configure_audio.cpp +++ b/src/citra_qt/configuration/configure_audio.cpp @@ -4,7 +4,9 @@ #include #include +#ifdef HAVE_CUBEB #include "audio_core/cubeb_input.h" +#endif #include "audio_core/sink.h" #include "audio_core/sink_details.h" #include "citra_qt/configuration/configure_audio.h" @@ -32,10 +34,11 @@ ConfigureAudio::ConfigureAudio(QWidget* parent) ui->input_device_combo_box->clear(); ui->input_device_combo_box->addItem(tr("Default")); +#ifdef HAVE_CUBEB for (const auto& device : AudioCore::ListCubebInputDevices()) { ui->input_device_combo_box->addItem(QString::fromStdString(device)); } - +#endif connect(ui->input_type_combo_box, qOverload(&QComboBox::currentIndexChanged), this, &ConfigureAudio::updateAudioInputDevices); diff --git a/src/core/frontend/mic.cpp b/src/core/frontend/mic.cpp index 84f090cb2a..8f2b4846a0 100644 --- a/src/core/frontend/mic.cpp +++ b/src/core/frontend/mic.cpp @@ -8,9 +8,8 @@ namespace Frontend::Mic { -constexpr std::array NOISE_SAMPLE_8_BIT = { - 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0xFF, 0xFF, 0xFF, 0x8E, 0xFF, - 0xF4, 0xE1, 0xBF, 0x9A, 0x71, 0x58, 0x5B, 0x5F, 0x62, 0xC2, 0x25, 0x05, 0x01, 0x01, 0x01, 0x01}; +constexpr std::array NOISE_SAMPLE_8_BIT = {0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xF5, 0xFF, 0xFF, 0xFF, 0xFF, 0x8E, 0xFF}; constexpr std::array NOISE_SAMPLE_16_BIT = { 0x64, 0x61, 0x74, 0x61, 0x56, 0xD7, 0x00, 0x00, 0x48, 0xF7, 0x86, 0x05, 0x77, 0x1A, 0xF4, 0x1F, diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index 0ac6a13400..7098446766 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -47,13 +47,8 @@ constexpr u32 GetSampleRateInHz(SampleRate sample_rate) { } } -// The following buffer write rates were found by hardware test on o3ds and n3ds. -// The 3ds writes to the sharedmem roughly every 15 samples -constexpr u64 BufferUpdateRate8180 = BASE_CLOCK_RATE_ARM11 / 511; -constexpr u64 BufferUpdateRate10910 = BASE_CLOCK_RATE_ARM11 / 681; -constexpr u64 BufferUpdateRate16360 = BASE_CLOCK_RATE_ARM11 / 1022; -constexpr u64 BufferUpdateRate32730 = BASE_CLOCK_RATE_ARM11 / 2045; - +// The 3ds hardware was tested to write to the sharedmem every 15 samples regardless of sample_rate. +// So we can just divide the sample rate by 16 and that'll give the correct timing for the event constexpr u64 GetBufferUpdateRate(SampleRate sample_rate) { return GetSampleRateInHz(sample_rate) / 16; } @@ -183,7 +178,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); LOG_TRACE(Service_MIC, - "StartSampling called, encoding={}, sample_rate={}, " + "called, encoding={}, sample_rate={}, " "audio_buffer_offset={}, audio_buffer_size={}, audio_buffer_loop={}", static_cast(encoding), static_cast(sample_rate), audio_buffer_offset, audio_buffer_size, audio_buffer_loop); @@ -196,7 +191,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_TRACE(Service_MIC, "AdjustSampling sample_rate={}", static_cast(sample_rate)); + LOG_TRACE(Service_MIC, "sample_rate={}", static_cast(sample_rate)); } void StopSampling(Kernel::HLERequestContext& ctx) { @@ -206,7 +201,7 @@ struct MIC_U::Impl { rb.Push(RESULT_SUCCESS); mic->StopSampling(); timing.RemoveEvent(buffer_write_event); - LOG_TRACE(Service_MIC, "StopSampling called"); + LOG_TRACE(Service_MIC, "called"); } void IsSampling(Kernel::HLERequestContext& ctx) { @@ -265,7 +260,7 @@ struct MIC_U::Impl { rb.Push(RESULT_SUCCESS); bool mic_power = mic->GetPower(); rb.Push(mic_power); - LOG_TRACE(Service_MIC, "GetPower called"); + LOG_TRACE(Service_MIC, "called"); } void SetIirFilterMic(Kernel::HLERequestContext& ctx) { diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 39a56e5672..9574e7bde9 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -3,7 +3,9 @@ // Refer to the license.txt file included. #include +#if HAVE_CUBEB #include "audio_core/cubeb_input.h" +#endif #include "audio_core/dsp_interface.h" #include "core/core.h" #include "core/frontend/emu_window.h" @@ -66,7 +68,9 @@ void Apply() { Frontend::Mic::RegisterMic(std::make_shared()); break; case Settings::MicInputType::Real: +#if HAVE_CUBEB Frontend::Mic::RegisterMic(std::make_shared()); +#endif break; case Settings::MicInputType::Static: Frontend::Mic::RegisterMic(std::make_shared());