diff options
| -rw-r--r-- | src/audio_core/sink/cubeb_sink.cpp | 2 | ||||
| -rw-r--r-- | src/audio_core/sink/sdl2_sink.cpp | 2 | ||||
| -rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 12 | ||||
| -rw-r--r-- | src/audio_core/sink/sink_stream.h | 6 | ||||
| -rw-r--r-- | src/core/arm/arm_interface.cpp | 16 |
5 files changed, 26 insertions, 12 deletions
diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp index bbb598bc5..51a23fe15 100644 --- a/src/audio_core/sink/cubeb_sink.cpp +++ b/src/audio_core/sink/cubeb_sink.cpp | |||
| @@ -146,7 +146,7 @@ public: | |||
| 146 | return; | 146 | return; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | paused = true; | 149 | SignalPause(); |
| 150 | if (cubeb_stream_stop(stream_backend) != CUBEB_OK) { | 150 | if (cubeb_stream_stop(stream_backend) != CUBEB_OK) { |
| 151 | LOG_CRITICAL(Audio_Sink, "Error stopping cubeb stream"); | 151 | LOG_CRITICAL(Audio_Sink, "Error stopping cubeb stream"); |
| 152 | } | 152 | } |
diff --git a/src/audio_core/sink/sdl2_sink.cpp b/src/audio_core/sink/sdl2_sink.cpp index 7b89151de..96e0efce2 100644 --- a/src/audio_core/sink/sdl2_sink.cpp +++ b/src/audio_core/sink/sdl2_sink.cpp | |||
| @@ -111,7 +111,7 @@ public: | |||
| 111 | if (device == 0 || paused) { | 111 | if (device == 0 || paused) { |
| 112 | return; | 112 | return; |
| 113 | } | 113 | } |
| 114 | paused = true; | 114 | SignalPause(); |
| 115 | SDL_PauseAudioDevice(device, 1); | 115 | SDL_PauseAudioDevice(device, 1); |
| 116 | } | 116 | } |
| 117 | 117 | ||
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index d66d04fae..2a09db599 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp | |||
| @@ -282,11 +282,19 @@ u64 SinkStream::GetExpectedPlayedSampleCount() { | |||
| 282 | void SinkStream::WaitFreeSpace(std::stop_token stop_token) { | 282 | void SinkStream::WaitFreeSpace(std::stop_token stop_token) { |
| 283 | std::unique_lock lk{release_mutex}; | 283 | std::unique_lock lk{release_mutex}; |
| 284 | release_cv.wait_for(lk, std::chrono::milliseconds(5), | 284 | release_cv.wait_for(lk, std::chrono::milliseconds(5), |
| 285 | [this]() { return queued_buffers < max_queue_size; }); | 285 | [this]() { return paused || queued_buffers < max_queue_size; }); |
| 286 | if (queued_buffers > max_queue_size + 3) { | 286 | if (queued_buffers > max_queue_size + 3) { |
| 287 | Common::CondvarWait(release_cv, lk, stop_token, | 287 | Common::CondvarWait(release_cv, lk, stop_token, |
| 288 | [this] { return queued_buffers < max_queue_size; }); | 288 | [this] { return paused || queued_buffers < max_queue_size; }); |
| 289 | } | 289 | } |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | void SinkStream::SignalPause() { | ||
| 293 | { | ||
| 294 | std::scoped_lock lk{release_mutex}; | ||
| 295 | paused = true; | ||
| 296 | } | ||
| 297 | release_cv.notify_one(); | ||
| 298 | } | ||
| 299 | |||
| 292 | } // namespace AudioCore::Sink | 300 | } // namespace AudioCore::Sink |
diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h index 6a4996ca3..f2ccd19b8 100644 --- a/src/audio_core/sink/sink_stream.h +++ b/src/audio_core/sink/sink_stream.h | |||
| @@ -214,6 +214,12 @@ public: | |||
| 214 | void WaitFreeSpace(std::stop_token stop_token); | 214 | void WaitFreeSpace(std::stop_token stop_token); |
| 215 | 215 | ||
| 216 | protected: | 216 | protected: |
| 217 | /** | ||
| 218 | * Unblocks the ADSP if the stream is paused. | ||
| 219 | */ | ||
| 220 | void SignalPause(); | ||
| 221 | |||
| 222 | protected: | ||
| 217 | /// Core system | 223 | /// Core system |
| 218 | Core::System& system; | 224 | Core::System& system; |
| 219 | /// Type of this stream | 225 | /// Type of this stream |
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp index 5e27dde58..558fba5bd 100644 --- a/src/core/arm/arm_interface.cpp +++ b/src/core/arm/arm_interface.cpp | |||
| @@ -153,6 +153,14 @@ void ARM_Interface::Run() { | |||
| 153 | Kernel::KThread* current_thread{Kernel::GetCurrentThreadPointer(system.Kernel())}; | 153 | Kernel::KThread* current_thread{Kernel::GetCurrentThreadPointer(system.Kernel())}; |
| 154 | HaltReason hr{}; | 154 | HaltReason hr{}; |
| 155 | 155 | ||
| 156 | // If the thread is scheduled for termination, exit the thread. | ||
| 157 | if (current_thread->HasDpc()) { | ||
| 158 | if (current_thread->IsTerminationRequested()) { | ||
| 159 | current_thread->Exit(); | ||
| 160 | UNREACHABLE(); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 156 | // Notify the debugger and go to sleep if a step was performed | 164 | // Notify the debugger and go to sleep if a step was performed |
| 157 | // and this thread has been scheduled again. | 165 | // and this thread has been scheduled again. |
| 158 | if (current_thread->GetStepState() == StepState::StepPerformed) { | 166 | if (current_thread->GetStepState() == StepState::StepPerformed) { |
| @@ -174,14 +182,6 @@ void ARM_Interface::Run() { | |||
| 174 | } | 182 | } |
| 175 | system.ExitCPUProfile(); | 183 | system.ExitCPUProfile(); |
| 176 | 184 | ||
| 177 | // If the thread is scheduled for termination, exit the thread. | ||
| 178 | if (current_thread->HasDpc()) { | ||
| 179 | if (current_thread->IsTerminationRequested()) { | ||
| 180 | current_thread->Exit(); | ||
| 181 | UNREACHABLE(); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | // Notify the debugger and go to sleep if a breakpoint was hit, | 185 | // Notify the debugger and go to sleep if a breakpoint was hit, |
| 186 | // or if the thread is unable to continue for any reason. | 186 | // or if the thread is unable to continue for any reason. |
| 187 | if (True(hr & HaltReason::InstructionBreakpoint) || True(hr & HaltReason::PrefetchAbort)) { | 187 | if (True(hr & HaltReason::InstructionBreakpoint) || True(hr & HaltReason::PrefetchAbort)) { |