GS/GSCapture: Flush stale GSCapture audio buffer during state load

This commit is contained in:
Benjamin
2026-09-19 13:12:14 -04:00
committed by Ty
parent 00879fe78b
commit 86b7693f98
3 changed files with 17 additions and 5 deletions
+14 -3
View File
@@ -169,6 +169,7 @@ namespace GSCapture
static bool ReceivePackets(AVCodecContext* codec_context, AVStream* stream, AVPacket* packet);
static bool ProcessAudioPackets(s64 video_pts);
static void InternalEndCapture(std::unique_lock<std::mutex>& lock);
static void InternalFlush(bool flush_audio_only);
static CodecList GetCodecListForContainer(const char* container, AVMediaType type);
static std::mutex s_lock;
@@ -1463,14 +1464,14 @@ std::string GSCapture::GetNextCaptureFileName()
return ret;
}
void GSCapture::Flush()
void GSCapture::InternalFlush(bool flush_audio_only)
{
std::unique_lock<std::mutex> lock(s_lock);
if (s_encoding_error)
return;
ProcessAllInFlightFrames(lock);
if (!flush_audio_only)
ProcessAllInFlightFrames(lock);
if (IsCapturingAudio())
{
@@ -1485,6 +1486,16 @@ void GSCapture::Flush()
}
}
void GSCapture::Flush()
{
InternalFlush(false);
}
void GSCapture::FlushAudioOnly()
{
InternalFlush(true);
}
GSCapture::CodecList GSCapture::GetCodecListForContainer(const char* container, AVMediaType type)
{
CodecList ret;
+1 -1
View File
@@ -32,7 +32,7 @@ namespace GSCapture
GSVector2i GetSize();
std::string GetNextCaptureFileName();
void Flush();
void FlushAudioOnly();
using CodecName = std::pair<std::string, std::string>; // shortname,longname
using CodecList = std::vector<CodecName>;
CodecList GetVideoCodecList(const char* container);
+2 -1
View File
@@ -14,6 +14,7 @@
#include "GS.h"
#include "GS/Renderers/HW/GSTextureReplacements.h"
#include "GSDumpReplayer.h"
#include "GS/GSCapture.h"
#include "GameDatabase.h"
#include "GameList.h"
#include "Host.h"
@@ -1910,7 +1911,7 @@ bool VMManager::DoLoadState(const char* filename, Error* error)
Error::SetString(error, TRANSLATE_STR("VMManager", "Cannot load state while replaying a GS dump."));
return false;
}
GSCapture::FlushAudioOnly();
Host::OnSaveStateLoading(filename);
if (!SaveState_UnzipFromDisk(filename, error))