Compare commits

...

2 Commits

Author SHA1 Message Date
v1993
828c830400 Disable workaround on Windows
This is reported to cause more issues than solve there. Disable since people keep complaining.
2022-05-01 22:39:47 +03:00
v1993
e919bea9c8 Workaround for audio pops and clicks
This is most evident on Linux, but happens everywhere. See issue #7144 for more details.
2021-11-17 03:24:02 +03:00
2 changed files with 16 additions and 0 deletions

View File

@@ -87,6 +87,16 @@ static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
}
void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) {
#ifndef _WIN32
auto now = std::chrono::steady_clock::now();
auto duration = now.time_since_epoch();
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration);
if (nanoseconds > expected_cb_time) {
ns_late = nanoseconds - expected_cb_time;
}
#endif
if (!IsPlaying()) {
// Ensure we are in playing state before playing the next buffer
sink_stream.Flush();
@@ -121,6 +131,9 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) {
ns_late = {};
}
#ifndef _WIN32
expected_cb_time = nanoseconds + (buffer_release_ns - ns_late);
#endif
core_timing.ScheduleEvent(buffer_release_ns - ns_late, release_event, {});
}

View File

@@ -124,6 +124,9 @@ private:
SinkStream& sink_stream; ///< Output sink for the stream
Core::Timing::CoreTiming& core_timing; ///< Core timing instance.
std::string name; ///< Name of the stream, must be unique
#ifndef _WIN32
std::chrono::nanoseconds expected_cb_time = {}; ///< Estimated time of next callback
#endif
};
using StreamPtr = std::shared_ptr<Stream>;