Commit Graph

108 Commits

Author SHA1 Message Date
MechaCat02
7b6902e08f [WIP] Audio/threading fixes + crash investigation; NEW ORACLE: crash is ours not the game
Some checks failed
Orchestrator / Commit Message Validation (push) Has been skipped
Orchestrator / Lint (push) Failing after 1m34s
Orchestrator / Windows (x86-64) (push) Has been skipped
Orchestrator / Linux (x86-64) (push) Has been skipped
Orchestrator / Create Release (push) Has been skipped
Snapshot for handoff. Contains the mission-audio + threading fixes and the
crash-investigation instrumentation (all diagnostic cvars default-OFF).

Fixes (behavioral):
- threading_posix.cc: reap-once guard on PosixCondition<Thread>::post_execution
  (double pthread_join at mission teardown -> fault loop -> audio death + freeze).
- xma_decoder.cc: work_event_->Set() in Pause() so the idle XMA worker observes
  paused_ and signals pause_fence_ (Pause() deadlock -> permanent audio death).
- audio_system / xma_context_master / xboxkrnl_audio / apu_flags / alsa: mission
  audio keepalive + guest_audio_flags + watchdogs.

Instrumentation (additive, default-off): xboxkrnl_debug cache-throw diag +
guest-catch dispatcher, xex_module PE/PDATA/EH scans, kernel_state mem_watch
(NOTE: mem_watch DEFAULTS TRUE -- an always-on host poll thread; prime crash suspect).

NEW ORACLE (see HANDOFF-crash-oracle-2026-07-16.md): stock 6e5b8324f built with
our toolchain + zero custom code = NO crash, NO sound-stop, plays the Ready Room.
=> the Ready-Room out_of_range crash is introduced by THESE changes, not the game
and not the (LTO-broken) build chain. Bisection plan + suspect ranking in the note.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 22:43:50 +02:00
oreyg
6e5b8324f4 [APU] Pace audio subsystem 2026-07-08 19:24:32 +02:00
Gliniak
29311ddcdd [APU] Replaced min-max with clamp for queued frames 2026-05-26 22:58:46 +02:00
Herman S.
7887efa69f [APU] fix potential semaphore leak on invalid client index 2026-04-13 12:16:24 +09:00
Herman S.
9371e73d92 [APU] Fix audio crashes during shutdown 2026-03-09 14:15:14 +09:00
Herman S.
fade0cd889 [APU] Add ALSA apu on Linux 2026-02-17 23:46:16 +09:00
Hendi
5a76cac218 [APU] Refactor audio system to work with different frequencies/channel layouts 2024-10-23 22:04:47 +02:00
Gliniak
4452e300ac [Emulator] Changed default config values for:
- mount_cache: false -> true
 - framerate_limit: 60 -> 0
 - font_size: 12 -> 14
 - apu_max_queued_frames: 64 -> 8
2024-08-31 21:48:34 +02:00
Gliniak
94473eda19 [APU] Changed default value of apu_max_queued_frames to 8.
Added ability to set it even lower to 4. However this might impact CPU usage.
2024-08-31 20:39:48 +02:00
Gliniak
b9061e6292 [LINT] Linted files + Added lint job to CI 2024-03-12 19:19:30 +01:00
disjtqz
a7b047b2a2 Implement kernel processes 2023-10-12 22:13:40 +02:00
Margen67
28c67b9384 [APU] Add apu_ prefix to max_queued_frames cvar
Also add note about the minimum value.
2023-06-12 07:21:44 -07:00
Gliniak
c74a047655 [Win] Revert XE_USE_KUSER_SHARED back to 0
Also limit queued audio frames
2023-02-11 18:20:21 +01:00
Gliniak
6c6c5ac14b Merge remote-tracking branch 'GliniakRepo/experimentals' into canary_experimental 2022-05-19 10:51:44 +02:00
Joel Linn
986dcf4f65 [Base] Check success of sync primitive creation
- Mainly use `assert`s, since failure is very rare
- Forward failure of `CreateSemaphore` to guests because it is more easy
  to trigger with invalid initial parameters.
2022-03-08 12:17:57 -06:00
Gliniak
07a1e77218 Allow users to change max amount of queued frames 2022-01-31 20:12:39 +01:00
Joel Linn
a86d7173e1 Refactor FourCC magic uses
- Use new fourcc_t type
- Improves compiler compatibility by removing multi chars
2021-06-02 22:28:43 -05:00
gibbed
c51cba080b Fix some bad string formats. 2020-04-08 13:05:37 -05:00
gibbed
38a6d110e7 [APU] Only wait on the worker thread if it actually exists. 2019-08-04 00:27:49 -05:00
Dr. Chat
f81a99e83a XMA: Use a threadsafe bitmap to acquire/release contexts
Support Pausing/Resuming
2016-07-28 21:11:12 -05:00
Dr. Chat
ee0a41aa2c Fix AudioSystem Restore and cleanup some code 2015-12-29 13:09:43 -08:00
Dr. Chat
b94ab4acbc AudioSystem Save/Restore 2015-12-29 13:09:42 -08:00
Dr. Chat
4eff2d8420 AudioSystem - switch to a free flag for free clients rather than a queue. 2015-12-29 13:09:41 -08:00
Ben Vanik
5834a42ef3 Dependency injection for apu/gpu/hid. 2015-11-08 15:02:24 -08:00
Ben Vanik
4af6c41740 Moving profiling.h to base - UI could be separated for cleanliness. 2015-11-07 12:31:07 -08:00
Ben Vanik
3fc1d02a09 Suspend some host threads that make guest callbacks. 2015-09-21 21:24:26 -07:00
Ben Vanik
3c96b6fa0a DANGER DANGER. Switching to global critical region.
This changes almost all locks held by guest threads to use a single global
critical region. This emulates the behavior on the PPC of disabling
interrupts (by calls like KeRaiseIrqlToDpcLevel or masking interrupts),
and prevents deadlocks from occuring when threads are suspended or
otherwise blocked.
This has performance implications and a pass is needed to ensure the
locking is as granular as possible. It could also break everything
because it's fundamentally unsound. We'll see.
2015-09-06 09:30:54 -07:00
Ben Vanik
19299fad4b Removing apu/ deps on Emulator. 2015-08-18 10:54:56 -07:00
Ben Vanik
ad090a40eb Fixing misuse of std::chrono. 2015-08-18 10:18:30 -07:00
Ben Vanik
fefaa31cd8 Switching a few types to their platform-agnostic versions. 2015-07-15 22:09:19 -07:00
Ben Vanik
a6012b73f4 Switching audio system to platform-agnostic primitives. 2015-07-14 23:13:56 -07:00
Ben Vanik
d89bad7380 Removing uses of Sleep/SwitchToThread/etc. 2015-07-13 21:54:24 -07:00
Ben Vanik
8c69a4df09 Cleaning up apu/ and renaming -private files to _flags.
Part of #296.
2015-06-27 11:25:56 -07:00
Ben Vanik
fb1f4906d9 xb format --all (we are now format clean). Buildbot will yell at you. 2015-06-22 22:26:51 -07:00
gibbed
021b5a3d17 Moved the XMA decoder out of AudioSystem and into its own world (plus minor code cleanup in the process). 2015-06-21 02:25:24 -05:00
gibbed
7e582c14fb Removed some unused code. 2015-06-21 00:23:29 -05:00
Dr. Chat
0bbaedae22 Fix release-mode audio 2015-06-20 19:50:24 -05:00
gibbed
641a4a5e47 Rejiggered ProcessXmaContext. Sound working again in Super Meat Boy. 2015-06-19 22:39:41 -05:00
gibbed
edbd724370 - Fixed a few bugs with ringbuffer, and some cleanup.
- Reworked audio system to use semaphores instead of events for waiting.
  Should fix rare issues where the XAudio2 driver would run out of buffers
  even though it was supposed to be guarded against that.
2015-06-19 21:48:51 -05:00
gibbed
f3547a832f Removed XMAContextData::kSize constant, moved kXmaContextCount, changes to use newer ringbuffer, cleaned up XMAInitializeContext a bit (with fixes for loop_data handling). 2015-06-19 09:54:21 -05:00
Ben Vanik
573f190a43 Adding modules/functions to the debugger. 2015-06-08 23:22:25 -07:00
Ben Vanik
ba88955be4 vsnprintf return is dumb. 2015-06-07 16:13:05 -07:00
Dr. Chat
23ae1b6297 Hookup libav logging 2015-06-04 02:10:56 -05:00
Dr. Chat
826609cd60 Cleanup some audio system code. 2015-06-03 11:14:10 -05:00
Dr. Chat
e20aa16b59 Cleanup audio system code 2015-06-02 10:12:13 -05:00
Dr. Chat
77e245dc51 Fix audio decoding. 2015-06-02 00:45:00 -05:00
Dr. Chat
93763c166f input_buffer_*_block_count -> input_buffer_*_packet_count 2015-06-02 00:44:59 -05:00
Dr. Chat
fedf7357a5 Remove variable bits per sample - it's always 16. 2015-05-30 21:01:55 -05:00
Ben Vanik
0a83b49744 Speeding up inner loop. 2015-05-29 17:05:43 -07:00
Dr. Chat
8c1b36d102 Don't need this. 2015-05-28 22:34:59 -05:00