Skip to content

Commit b2dc16c

Browse files
committed
Revert "audio: Accurate audio output timing. (shadps4-emu#1986)"
This reverts commit 48c51bd. # Conflicts: # src/common/config.cpp
1 parent 10762ee commit b2dc16c

File tree

13 files changed

+792
-170
lines changed

13 files changed

+792
-170
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,7 @@
119119
path = externals/MoltenVK/cereal
120120
url = https://github.com/USCiLab/cereal
121121
shallow = true
122+
[submodule "externals/cubeb"]
123+
path = externals/cubeb
124+
url = https://github.com/mozilla/cubeb
125+
shallow = true

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ find_package(xxHash 0.8.2 MODULE)
127127
find_package(ZLIB 1.3 MODULE)
128128
find_package(Zydis 5.0.0 CONFIG)
129129
find_package(pugixml 1.14 CONFIG)
130+
find_package(cubeb CONFIG)
130131

131132
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR NOT MSVC)
132133
find_package(cryptopp 8.9.0 MODULE)
@@ -202,6 +203,7 @@ set(AUDIO_LIB src/core/libraries/audio/audioin.cpp
202203
src/core/libraries/audio/audioout.h
203204
src/core/libraries/audio/audioout_backend.h
204205
src/core/libraries/audio/audioout_error.h
206+
src/core/libraries/audio/cubeb_audio.cpp
205207
src/core/libraries/audio/sdl_audio.cpp
206208
src/core/libraries/ngs2/ngs2.cpp
207209
src/core/libraries/ngs2/ngs2.h
@@ -497,6 +499,7 @@ set(COMMON src/common/logging/backend.cpp
497499
src/common/polyfill_thread.h
498500
src/common/rdtsc.cpp
499501
src/common/rdtsc.h
502+
src/common/ringbuffer.h
500503
src/common/signal_context.h
501504
src/common/signal_context.cpp
502505
src/common/singleton.h
@@ -889,7 +892,7 @@ endif()
889892
create_target_directory_groups(shadps4)
890893

891894
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt toml11::toml11 tsl::robin_map xbyak::xbyak Tracy::TracyClient RenderDoc::API FFmpeg::ffmpeg Dear_ImGui gcn half::half ZLIB::ZLIB PNG::PNG)
892-
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::glslang SDL3::SDL3 pugixml::pugixml stb::headers)
895+
target_link_libraries(shadps4 PRIVATE Boost::headers GPUOpen::VulkanMemoryAllocator LibAtrac9 sirit Vulkan::Headers xxHash::xxhash Zydis::Zydis glslang::glslang SDL3::SDL3 pugixml::pugixml stb::headers cubeb::cubeb)
893896

894897
target_compile_definitions(shadps4 PRIVATE IMGUI_USER_CONFIG="imgui/imgui_config.h")
895898
target_compile_definitions(Dear_ImGui PRIVATE IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/src/imgui/imgui_config.h")

LICENSES/ISC.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License
2+
3+
<copyright notice>
4+
5+
Permission to use, copy, modify, and /or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

externals/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ if (NOT TARGET stb::headers)
228228
add_library(stb::headers ALIAS stb)
229229
endif()
230230

231+
# cubeb
232+
if (NOT TARGET cubeb::cubeb)
233+
option(BUILD_TESTS "" OFF)
234+
option(BUILD_TOOLS "" OFF)
235+
option(BUNDLE_SPEEX "" ON)
236+
option(USE_SANITIZERS "" OFF)
237+
add_subdirectory(cubeb)
238+
add_library(cubeb::cubeb ALIAS cubeb)
239+
endif()
240+
231241
# Apple-only dependencies
232242
if (APPLE)
233243
# date

externals/cubeb

Submodule cubeb added at 9a9d034

src/common/config.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static bool separateupdatefolder = false;
6868
static bool compatibilityData = false;
6969
static bool checkCompatibilityOnStartup = false;
7070
std::vector<u64> skipedHashes = {};
71+
static std::string audioBackend = "cubeb";
7172

7273
// Gui
7374
std::vector<std::filesystem::path> settings_install_dirs = {};
@@ -240,6 +241,10 @@ bool getCheckCompatibilityOnStartup() {
240241
return checkCompatibilityOnStartup;
241242
}
242243

244+
std::string getAudioBackend() {
245+
return audioBackend;
246+
}
247+
243248
void setGpuId(s32 selectedGpuId) {
244249
gpuId = selectedGpuId;
245250
}
@@ -376,6 +381,10 @@ void setCheckCompatibilityOnStartup(bool use) {
376381
checkCompatibilityOnStartup = use;
377382
}
378383

384+
void setAudioBackend(std::string backend) {
385+
audioBackend = backend;
386+
}
387+
379388
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
380389
main_window_geometry_x = x;
381390
main_window_geometry_y = y;
@@ -617,6 +626,12 @@ void load(const std::filesystem::path& path) {
617626
vkCrashDiagnostic = toml::find_or<bool>(vk, "crashDiagnostic", false);
618627
}
619628

629+
if (data.contains("Audio")) {
630+
const toml::value& audio = data.at("Audio");
631+
632+
audioBackend = toml::find_or<std::string>(audio, "backend", "cubeb");
633+
}
634+
620635
if (data.contains("Debug")) {
621636
const toml::value& debug = data.at("Debug");
622637

@@ -716,6 +731,7 @@ void save(const std::filesystem::path& path) {
716731
data["Vulkan"]["rdocEnable"] = rdocEnable;
717732
data["Vulkan"]["rdocMarkersEnable"] = vkMarkers;
718733
data["Vulkan"]["crashDiagnostic"] = vkCrashDiagnostic;
734+
data["Audio"]["backend"] = audioBackend;
719735
data["Debug"]["DebugDump"] = isDebugDump;
720736
data["Debug"]["CollectShader"] = isShaderDebug;
721737

@@ -819,6 +835,7 @@ void setDefaultValues() {
819835
separateupdatefolder = false;
820836
compatibilityData = false;
821837
checkCompatibilityOnStartup = false;
838+
audioBackend = "cubeb";
822839
}
823840

824841
} // namespace Config

src/common/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bool getEnableDiscordRPC();
2424
bool getSeparateUpdateEnabled();
2525
bool getCompatibilityEnabled();
2626
bool getCheckCompatibilityOnStartup();
27+
std::string getAudioBackend();
2728

2829
std::string getLogFilter();
2930
std::string getLogType();
@@ -76,6 +77,7 @@ void setSeparateUpdateEnabled(bool use);
7677
void setGameInstallDirs(const std::vector<std::filesystem::path>& settings_install_dirs_config);
7778
void setCompatibilityEnabled(bool use);
7879
void setCheckCompatibilityOnStartup(bool use);
80+
void setAudioBackend(std::string backend);
7981

8082
void setCursorState(s16 cursorState);
8183
void setCursorHideTimeout(int newcursorHideTimeout);

0 commit comments

Comments
 (0)