@ -205,6 +205,10 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
// If we're paused or going to shut down, we don't want to consume buffers as coretiming is
// If we're paused or going to shut down, we don't want to consume buffers as coretiming is
// paused and we'll desync, so just play silence.
// paused and we'll desync, so just play silence.
if ( system . IsPaused ( ) | | system . IsShuttingDown ( ) ) {
if ( system . IsPaused ( ) | | system . IsShuttingDown ( ) ) {
if ( system . IsShuttingDown ( ) ) {
release_cv . notify_one ( ) ;
}
static constexpr std : : array < s16 , 6 > silence { } ;
static constexpr std : : array < s16 , 6 > silence { } ;
for ( size_t i = frames_written ; i < num_frames ; i + + ) {
for ( size_t i = frames_written ; i < num_frames ; i + + ) {
std : : memcpy ( & output_buffer [ i * frame_size ] , & silence [ 0 ] , frame_size_bytes ) ;
std : : memcpy ( & output_buffer [ i * frame_size ] , & silence [ 0 ] , frame_size_bytes ) ;
@ -240,6 +244,12 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
}
}
// Successfully dequeued a new buffer.
// Successfully dequeued a new buffer.
queued_buffers - - ;
queued_buffers - - ;
{
std : : unique_lock lk { release_mutex } ;
}
release_cv . notify_one ( ) ;
}
}
// Get the minimum frames available between the currently playing buffer, and the
// Get the minimum frames available between the currently playing buffer, and the
@ -303,4 +313,9 @@ u64 SinkStream::GetExpectedPlayedSampleCount() {
return std : : min < u64 > ( exp_played_sample_count , max_played_sample_count ) ;
return std : : min < u64 > ( exp_played_sample_count , max_played_sample_count ) ;
}
}
void SinkStream : : WaitFreeSpace ( ) {
std : : unique_lock lk { release_mutex } ;
release_cv . wait ( lk , [ this ] ( ) { return queued_buffers < max_queue_size | | system . IsShuttingDown ( ) ; } ) ;
}
} // namespace AudioCore::Sink
} // namespace AudioCore::Sink