summaryrefslogtreecommitdiff
path: root/src/audio_core/hle/dsp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/hle/dsp.cpp')
-rw-r--r--src/audio_core/hle/dsp.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp
index 31421fdc6..260b182ed 100644
--- a/src/audio_core/hle/dsp.cpp
+++ b/src/audio_core/hle/dsp.cpp
@@ -16,31 +16,33 @@ namespace HLE {
16 16
17// Region management 17// Region management
18 18
19std::array<SharedMemory, 2> g_regions; 19DspMemory g_dsp_memory;
20 20
21static size_t CurrentRegionIndex() { 21static size_t CurrentRegionIndex() {
22 // The region with the higher frame counter is chosen unless there is wraparound. 22 // The region with the higher frame counter is chosen unless there is wraparound.
23 // This function only returns a 0 or 1. 23 // This function only returns a 0 or 1.
24 u16 frame_counter_0 = g_dsp_memory.region_0.frame_counter;
25 u16 frame_counter_1 = g_dsp_memory.region_1.frame_counter;
24 26
25 if (g_regions[0].frame_counter == 0xFFFFu && g_regions[1].frame_counter != 0xFFFEu) { 27 if (frame_counter_0 == 0xFFFFu && frame_counter_1 != 0xFFFEu) {
26 // Wraparound has occurred. 28 // Wraparound has occurred.
27 return 1; 29 return 1;
28 } 30 }
29 31
30 if (g_regions[1].frame_counter == 0xFFFFu && g_regions[0].frame_counter != 0xFFFEu) { 32 if (frame_counter_1 == 0xFFFFu && frame_counter_0 != 0xFFFEu) {
31 // Wraparound has occurred. 33 // Wraparound has occurred.
32 return 0; 34 return 0;
33 } 35 }
34 36
35 return (g_regions[0].frame_counter > g_regions[1].frame_counter) ? 0 : 1; 37 return (frame_counter_0 > frame_counter_1) ? 0 : 1;
36} 38}
37 39
38static SharedMemory& ReadRegion() { 40static SharedMemory& ReadRegion() {
39 return g_regions[CurrentRegionIndex()]; 41 return CurrentRegionIndex() == 0 ? g_dsp_memory.region_0 : g_dsp_memory.region_1;
40} 42}
41 43
42static SharedMemory& WriteRegion() { 44static SharedMemory& WriteRegion() {
43 return g_regions[1 - CurrentRegionIndex()]; 45 return CurrentRegionIndex() != 0 ? g_dsp_memory.region_0 : g_dsp_memory.region_1;
44} 46}
45 47
46// Audio processing and mixing 48// Audio processing and mixing