Fallback to silence when no samples have been captured. (#955)
Some checks are pending
citra-build / macos-universal (push) Blocked by required conditions
citra-build / source (push) Waiting to run
citra-build / linux (appimage) (push) Waiting to run
citra-build / linux (fresh) (push) Waiting to run
citra-build / macos (arm64) (push) Waiting to run
citra-build / macos (x86_64) (push) Waiting to run
citra-build / windows (msvc) (push) Waiting to run
citra-build / windows (msys2) (push) Waiting to run
citra-build / android (push) Waiting to run
citra-build / ios (push) Waiting to run
citra-format / clang-format (push) Waiting to run
citra-transifex / transifex (push) Waiting to run

This commit is contained in:
Midou36O 2025-04-19 14:21:13 +01:00 committed by GitHub
parent b1480396fa
commit 1ff5042685
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 5 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2018 Citra Emulator Project // Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -144,6 +144,11 @@ Samples CubebInput::Read() {
while (impl->sample_queue.Pop(queue)) { while (impl->sample_queue.Pop(queue)) {
samples.insert(samples.end(), queue.begin(), queue.end()); samples.insert(samples.end(), queue.begin(), queue.end());
} }
if (samples.empty()) {
samples = GenerateSilentSamples(parameters);
}
return samples; return samples;
} }

View file

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project // Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -53,6 +53,22 @@ public:
*/ */
virtual Samples Read() = 0; virtual Samples Read() = 0;
/**
* Generates a buffer of silence.
* Takes into account the sample size and signedness of the input.
*/
virtual Samples GenerateSilentSamples(const InputParameters& params) {
u8 silent_value = 0x00;
if (params.sample_size == 8) {
silent_value = params.sign == Signedness::Unsigned ? 0x80 : 0x00;
return std::vector<u8>(32, silent_value);
} else {
silent_value = params.sign == Signedness::Unsigned ? 0x80 : 0x00;
return std::vector<u8>(64, silent_value);
}
}
protected: protected:
InputParameters parameters; InputParameters parameters;
}; };

View file

@ -1,4 +1,4 @@
// Copyright 2019 Citra Emulator Project // Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -30,10 +30,11 @@ public:
void AdjustSampleRate(u32 sample_rate) override {} void AdjustSampleRate(u32 sample_rate) override {}
Samples Read() override { Samples Read() override {
return {}; return GenerateSilentSamples(parameters);
} }
private: private:
InputParameters parameters;
bool is_sampling = false; bool is_sampling = false;
}; };

View file

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project // Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -108,6 +108,10 @@ Samples OpenALInput::Read() {
return {}; return {};
} }
if (samples.empty()) {
samples = GenerateSilentSamples(parameters);
}
return samples; return samples;
} }