Commit Graph

692 Commits

Author SHA1 Message Date
f99d3dbd5c Android: Ask system for optimal audio buffer size and sample rate
This can reduce audio latency according to
https://developer.android.com/ndk/guides/audio/opensl/opensl-prog-notes#perform.

Previously we were using the hardcoded values of 48000 Hz and 256 frames
per buffer. The sample rate we use with this change is 48000 Hz on all
devices I'm aware of, but the buffer size does vary across devices.

Terminology note: The old code used the term "sample" to refer to what
Android refers to as a "frame". "Frame" is a clearer term to use for
this, so I've changed OpenSLESStream's terminology. One frame consists
of one sample per channel.
2025-05-25 11:59:33 +02:00
34e8fb068f Android: Get rid of OpenSLESStream's global state
Not sure if we're ever going to want to have more than one of these at
the same time, but these global variables are a code smell nonetheless.

I'm also deleting the existing member variables because they were
unused.
2025-05-25 11:55:22 +02:00
aea5054509 CubebUtils: Add COM helper class 2025-05-07 20:33:22 +04:00
1ac40f25a2 IOS/USB: Emulate Wii Speak using cubeb
Based on @noahpistilli (Sketch) PR:
https://github.com/dolphin-emu/dolphin/pull/12567

Fixed the Windows support and the heisenbug caused by uninitialized
members.

Config system integration finalized.
2025-05-07 20:33:22 +04:00
d2db9d9590 Merge pull request #13608 from jordan-woyak/async-work-thread
Common: Add AsyncWorkThread.
2025-05-04 18:45:14 +02:00
06826319c7 AudioCommon/CubebUtils: Fix logged file name. 2025-05-02 02:54:15 -05:00
4e736d60db Core and AudioCommon: Use AsyncWorkThread. 2025-05-01 22:55:23 -05:00
1fc6be7f80 AudioCommon: Make cubeb sound backend default on Linux. 2025-04-21 16:25:40 -05:00
74e752ed9c Mixer: Use Doubles for Sample Rate Conversion. 2025-04-05 13:46:37 -05:00
877864c23a Improve Performance of Granular Buffering + User Adjustable Buffer Size 2025-04-01 18:17:21 -04:00
896b4bb1fa AudioPanel: Refactor to use Config system. Some options were changed to a different format, for easier compatibility.
Removed VolumeChanged signal, as ConfigChanged will trigger what is needed.

Only applies UpdateSoundStream to things that can change during emulation.

Settings::SetVolume might no longer be used, but left it in.
2025-03-26 12:26:01 -07:00
f09ba10daa AudioCommon: Added Granular Synthesis 2025-03-14 01:22:35 -05:00
d89e7c84fb CMakeLists: Add flag to disable Cubeb 2025-01-25 14:06:55 -05:00
d627b78c46 Adjust order and spacing of various #includes
Move some #includes around to match the Contributing guidelines.
2024-07-26 14:28:34 -07:00
1d8b1715ab AudioCommon: unlock mutex explicitly to avoid -Wunused-result warning 2024-06-20 02:25:15 +01:00
a3c23353c0 Android: Implement OpenSLESStream::SetRunning 2024-06-04 19:32:04 +02:00
9c5605a59c AudioCommon: When ALSA is absent on Linux, default to Cubeb backend
Default to Cubeb instead of the NULL backend on Linux when ALSA isn't
valid.
2024-04-16 14:06:28 -07:00
ba2ccf3889 Set default sound backend on OpenBSD to cubeb
Set the default sound backend to cubeb instead of the default
being none.
2024-04-14 18:47:20 -04:00
d933e58d9a Cubeb: check correct log level 2024-03-17 01:33:42 +00:00
4d9038c7c3 Cubeb: change log level from NOTICE to INFO
Cubeb logs a message at CUBEB_LOG_NORMAL verbosity every time you start
or stop a stream which can get a bit annoying when using frame advance
at Dolphin's default verbosity.
2024-03-14 00:31:02 +00:00
7197e3abd0 Use structs for config callback IDs
This way you can't mix up regular config callback IDs and CPU thread
config callback IDs. (It would be rather bad if you did!)
2023-08-17 19:19:26 +02:00
b5be399fd4 cubeb: Change name to "Dolphin Emulator"
To avoid conflicts with KDE's file manager.
2023-07-22 23:12:34 +02:00
fa81006b51 Merge pull request #11955 from TellowKrinkle/CMakeDependencies
CMake: Allow ignoring system packages
2023-06-30 19:06:04 +02:00
get
ffabb6c57b Replace std::ostringstream usage with fmt::format 2023-06-18 18:37:32 -05:00
5b10a80401 CMake: Use targets for all optionally-external dependencies 2023-06-15 01:41:41 -05:00
0f326c6067 Common: Move FixedSizeQueue into Common namespace
Gets this out of the global namespace.
2023-03-22 01:23:15 -04:00
f27e8216a5 Skylander Portal: Play Trap Team Audio
Asserts and length handling
2023-03-13 13:01:48 +13:00
7c4fcc30a3 WorkQueueThread: provide name and function at same time 2023-02-04 15:56:27 +13:00
8edca2039e Merge pull request #10947 from Zopolis4/opensleuth
Restrict OpenSLES to Android via CMake
2023-01-30 09:02:45 +01:00
c338f9e2a1 windows: replace comdef dependency with winrt 2023-01-23 06:09:01 -08:00
bc1cc9eeb4 CoreTiming: Throttle Before Every Event Using Chrono 2023-01-06 17:21:17 -05:00
673f81c18a New FrameTime/VBlank Analyzer + Graph 2022-12-23 19:52:53 -05:00
64bb9ae9a9 Correctly call CoUninitialize() on Cubeb helper class destruction. 2022-11-27 03:58:50 +01:00
e085bf14f9 Core: Use extra thread for Cubeb on Windows to not disturb the CoInitialize state of whatever thread happens to call a Cubeb function. 2022-11-26 05:05:57 +01:00
ca10e92ab9 Core: Abide by COM MTA requirement for cubeb on Windows. Partially based on https://github.com/dolphin-emu/dolphin/pull/8920#discussion_r459746604
Co-authored-by: Michael M <mchtly@gmail.com>
2022-11-26 05:05:56 +01:00
59b1419a8e Externals: Update cubeb to mozilla/cubeb@773f16b7ea and make it a submodule.
CMakeLists.txt has been extracted and modified a bit to work with Dolphin's typical build settings.
2022-11-26 05:05:52 +01:00
1c63349984 AudioCommon: Pass Core::System to AudioCommon functions. 2022-11-06 02:13:58 +01:00
6de55e416b WaveFile: Fix size check
`count` is the number of stereo samples to write (where each stereo sample is two shorts), while `BUFFER_SIZE` is the size of the buffer in shorts.  So `count` needs to be multiplied by `2`, not `BUFFER_SIZE`.  Also, when this check was failed, the previous code just clobbered whatever was past the end of the buffer after logging the warning, which corrupted `basename`, eventually resulting in Dolphin crashing.

This affected Datel's Wii-compatible Action Replay, which uses a block size of 2298, or 18384 stereo samples, which is 36768 shorts, which is bigger than the buffer size of 32768. (However, the previous commit means that only one block is transfered at a time, eliminating this issue; fixing the bounds check is just a general safety thing instead of an actual bugfix now.)
2022-10-22 11:44:38 -07:00
72de74d4fc Mixer: Add assertions regarding num_samples versus buffer length 2022-09-08 12:10:10 -07:00
abb59a781a Mixer: Use smaller array for PushWiimoteSpeakerSamples 2022-09-08 12:10:02 -07:00
c310e504cb AudioCommon: Move sound stream variables to Core::System. 2022-08-31 21:44:21 +02:00
e2aefe13a6 Restrict OpenSLES to Android via CMake 2022-08-08 09:18:36 +10:00
f92541fbd9 StripSpaces: only strip spaces
StripWhitespace maintains old behavior
2022-07-25 18:40:12 -07:00
0a15d2fcec cubeb: fix logged source file paths 2022-07-18 09:52:54 -07:00
4234b25682 Do not directly store input sample rate, rather just store a divisor for that sample rate, with it using a fixed dividend of 54000000 * 2.
This should reduce (but not completely eliminate) gradual audio desyncs in dumps. This also allows for accurate sample rates for the GameCube.
Completely eliminating gradual audio desyncs will require resampling to an integer sample rate, as nothing seems to support a non-integer sample rate.
2022-07-03 15:07:06 -07:00
ad892176d0 have audio dumps apply volume (fixes cases of audio dumps being "too loud" and in game audio controls having no effect) 2022-06-10 21:27:10 -07:00
580c721c82 cmake: Don't use PCH with Qt6. 2022-05-22 01:19:44 +02:00
36cfcb530f IOFile: Make origin parameter to Seek() an enum class. 2022-01-29 06:49:21 +01:00
ca9bf3174f Use HRWrap in remaining locations
Note that D3DCommon can't use DX11HRWrap or DX12HRWrap since it's shared between them.
2022-01-09 12:44:55 -08:00
eb5bb2993e Core/AudioCommon: Add config caching to Mixer. 2022-01-06 16:43:43 +01:00