diff --git a/src/audio_core/cubeb_input.cpp b/src/audio_core/cubeb_input.cpp index 9e83125e73..65085053dd 100644 --- a/src/audio_core/cubeb_input.cpp +++ b/src/audio_core/cubeb_input.cpp @@ -49,16 +49,12 @@ void CubebInput::StartSampling(const Frontend::Mic::Parameters& params) { LOG_ERROR(Audio, "Application requested unsupported unsigned pcm format. Falling back to signed"); } - if (params.sample_size != 16) { - LOG_ERROR(Audio, - "Application requested unsupported 8 bit pcm format. Falling back to 16 bits"); - } + + impl->sample_size_in_bytes = params.sample_size / 8; parameters = params; is_sampling = true; - impl->sample_size_in_bytes = 2; - cubeb_devid input_device = nullptr; cubeb_stream_params input_params; input_params.channels = 1; @@ -76,12 +72,14 @@ void CubebInput::StartSampling(const Frontend::Mic::Parameters& params) { nullptr, nullptr, latency_frames, Impl::DataCallback, Impl::StateCallback, impl.get()) != CUBEB_OK) { LOG_CRITICAL(Audio, "Error creating cubeb input stream"); + is_sampling = false; + return; } - cubeb_stream_start(impl->stream); - int ret = cubeb_stream_set_volume(impl->stream, 1.0); - if (ret == CUBEB_ERROR_NOT_SUPPORTED) { - LOG_WARNING(Audio, "Unabled to set volume for cubeb input"); + if (cubeb_stream_start(impl->stream) != CUBEB_OK) { + LOG_CRITICAL(Audio, "Error starting cubeb input stream"); + is_sampling = false; + return; } } @@ -113,8 +111,18 @@ long CubebInput::Impl::DataCallback(cubeb_stream* stream, void* user_data, const return 0; } - const u8* data = reinterpret_cast(input_buffer); - std::vector samples{data, data + num_frames * impl->sample_size_in_bytes}; + std::vector samples{}; + samples.reserve(num_frames * impl->sample_size_in_bytes); + if (impl->sample_size_in_bytes == 1) { + // If the sample format is 8bit, then resample back to 8bit before passing back to core + const s16* data = reinterpret_cast(input_buffer); + std::transform(data, data + num_frames, std::back_inserter(samples), + [](s16 sample) { return static_cast(static_cast(sample) >> 8); }); + } else { + // Otherwise copy all of the samples to the buffer (which will be treated as s16 by core) + const u8* data = reinterpret_cast(input_buffer); + samples.insert(samples.begin(), data, data + num_frames * impl->sample_size_in_bytes); + } impl->sample_queue->Push(samples); // returning less than num_frames here signals cubeb to stop sampling diff --git a/src/core/frontend/mic.cpp b/src/core/frontend/mic.cpp index 8f2b4846a0..543a237677 100644 --- a/src/core/frontend/mic.cpp +++ b/src/core/frontend/mic.cpp @@ -4,7 +4,6 @@ #include #include "core/frontend/mic.h" -#include "core/hle/service/mic_u.h" namespace Frontend::Mic { diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index ca2f065548..779b520b85 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -121,7 +121,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_TRACE(Service_MIC, "MapSharedMem called, size=0x{:X}", size); + LOG_TRACE(Service_MIC, "called, size=0x{:X}", size); } void UnmapSharedMem(Kernel::HLERequestContext& ctx) { @@ -129,7 +129,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); shared_memory = nullptr; rb.Push(RESULT_SUCCESS); - LOG_TRACE(Service_MIC, "UnmapSharedMem called"); + LOG_TRACE(Service_MIC, "called"); } void UpdateSharedMemBuffer(u64 userdata, s64 cycles_late) { @@ -237,7 +237,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_TRACE(Service_MIC, "SetGain gain={}", gain); + LOG_TRACE(Service_MIC, "gain={}", gain); } void GetGain(Kernel::HLERequestContext& ctx) { @@ -247,7 +247,7 @@ struct MIC_U::Impl { rb.Push(RESULT_SUCCESS); u8 gain = mic->GetGain(); rb.Push(gain); - LOG_TRACE(Service_MIC, "GetGain gain={}", gain); + LOG_TRACE(Service_MIC, "gain={}", gain); } void SetPower(Kernel::HLERequestContext& ctx) { @@ -257,7 +257,7 @@ struct MIC_U::Impl { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - LOG_TRACE(Service_MIC, "SetPower mic_power={}", power); + LOG_TRACE(Service_MIC, "mic_power={}", power); } void GetPower(Kernel::HLERequestContext& ctx) { diff --git a/src/core/settings.cpp b/src/core/settings.cpp index c7311e268d..d34aad32aa 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -5,7 +5,6 @@ #include #include "audio_core/dsp_interface.h" #include "core/core.h" -#include "core/frontend/emu_window.h" #include "core/gdbstub/gdbstub.h" #include "core/hle/service/hid/hid.h" #include "core/hle/service/ir/ir_rst.h"