diff options
| author | 2016-04-25 10:01:37 +0100 | |
|---|---|---|
| committer | 2016-04-29 16:32:29 +0100 | |
| commit | 22995bd9bfc5e7f103e03066d4aa035e4294c359 (patch) | |
| tree | 7610b942422a12796f6cfacbaf287fdbf61b4b6b /src/audio_core/hle/dsp.cpp | |
| parent | Merge pull request #1708 from MerryMage/dsp_dsp (diff) | |
| download | yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.gz yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.xz yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.zip | |
AudioCore: CurrentRegion() -> ReadRegion(), WriteRegion()
Diffstat (limited to 'src/audio_core/hle/dsp.cpp')
| -rw-r--r-- | src/audio_core/hle/dsp.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp index c89356edc..5759a5b9e 100644 --- a/src/audio_core/hle/dsp.cpp +++ b/src/audio_core/hle/dsp.cpp | |||
| @@ -8,8 +8,32 @@ | |||
| 8 | namespace DSP { | 8 | namespace DSP { |
| 9 | namespace HLE { | 9 | namespace HLE { |
| 10 | 10 | ||
| 11 | SharedMemory g_region0; | 11 | std::array<SharedMemory, 2> g_regions; |
| 12 | SharedMemory g_region1; | 12 | |
| 13 | static size_t CurrentRegionIndex() { | ||
| 14 | // The region with the higher frame counter is chosen unless there is wraparound. | ||
| 15 | // This function only returns a 0 or 1. | ||
| 16 | |||
| 17 | if (g_regions[0].frame_counter == 0xFFFFu && g_regions[1].frame_counter != 0xFFFEu) { | ||
| 18 | // Wraparound has occured. | ||
| 19 | return 1; | ||
| 20 | } | ||
| 21 | |||
| 22 | if (g_regions[1].frame_counter == 0xFFFFu && g_regions[0].frame_counter != 0xFFFEu) { | ||
| 23 | // Wraparound has occured. | ||
| 24 | return 0; | ||
| 25 | } | ||
| 26 | |||
| 27 | return (g_regions[0].frame_counter > g_regions[1].frame_counter) ? 0 : 1; | ||
| 28 | } | ||
| 29 | |||
| 30 | static SharedMemory& ReadRegion() { | ||
| 31 | return g_regions[CurrentRegionIndex()]; | ||
| 32 | } | ||
| 33 | |||
| 34 | static SharedMemory& WriteRegion() { | ||
| 35 | return g_regions[1 - CurrentRegionIndex()]; | ||
| 36 | } | ||
| 13 | 37 | ||
| 14 | void Init() { | 38 | void Init() { |
| 15 | DSP::HLE::ResetPipes(); | 39 | DSP::HLE::ResetPipes(); |
| @@ -22,21 +46,5 @@ bool Tick() { | |||
| 22 | return true; | 46 | return true; |
| 23 | } | 47 | } |
| 24 | 48 | ||
| 25 | SharedMemory& CurrentRegion() { | ||
| 26 | // The region with the higher frame counter is chosen unless there is wraparound. | ||
| 27 | |||
| 28 | if (g_region0.frame_counter == 0xFFFFu && g_region1.frame_counter != 0xFFFEu) { | ||
| 29 | // Wraparound has occured. | ||
| 30 | return g_region1; | ||
| 31 | } | ||
| 32 | |||
| 33 | if (g_region1.frame_counter == 0xFFFFu && g_region0.frame_counter != 0xFFFEu) { | ||
| 34 | // Wraparound has occured. | ||
| 35 | return g_region0; | ||
| 36 | } | ||
| 37 | |||
| 38 | return (g_region0.frame_counter > g_region1.frame_counter) ? g_region0 : g_region1; | ||
| 39 | } | ||
| 40 | |||
| 41 | } // namespace HLE | 49 | } // namespace HLE |
| 42 | } // namespace DSP | 50 | } // namespace DSP |