mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-04-12 10:46:29 +00:00
WIP SDL3 compatibility
This commit is contained in:
@@ -123,7 +123,7 @@ int FFmpegVideoDecoder::getDecoderCapabilities()
|
||||
|
||||
if (!isHardwareAccelerated()) {
|
||||
// Slice up to 4 times for parallel CPU decoding, once slice per core
|
||||
int slices = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||
int slices = qMin(MAX_SLICES, SDL_GetNumLogicalCPUCores());
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Encoder configured for %d slices per frame",
|
||||
slices);
|
||||
@@ -269,10 +269,10 @@ void FFmpegVideoDecoder::reset()
|
||||
// Terminate the decoder thread before doing anything else.
|
||||
// It might be touching things we're about to free.
|
||||
if (m_DecoderThread != nullptr) {
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
LiWakeWaitForVideoFrame();
|
||||
SDL_WaitThread(m_DecoderThread, NULL);
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 0);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 0);
|
||||
m_DecoderThread = nullptr;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ bool FFmpegVideoDecoder::completeInitialization(const AVCodec* decoder, enum AVP
|
||||
// Enable slice multi-threading for software decoding
|
||||
if (!isHardwareAccelerated()) {
|
||||
m_VideoDecoderCtx->thread_type = FF_THREAD_SLICE;
|
||||
m_VideoDecoderCtx->thread_count = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||
m_VideoDecoderCtx->thread_count = qMin(MAX_SLICES, SDL_GetNumLogicalCPUCores());
|
||||
}
|
||||
else {
|
||||
// No threading for HW decode
|
||||
@@ -1608,7 +1608,7 @@ int FFmpegVideoDecoder::decoderThreadProcThunk(void *context)
|
||||
|
||||
void FFmpegVideoDecoder::decoderThreadProc()
|
||||
{
|
||||
while (!SDL_AtomicGet(&m_DecoderThreadShouldQuit)) {
|
||||
while (!SDL_GetAtomicInt(&m_DecoderThreadShouldQuit)) {
|
||||
if (m_FramesIn == m_FramesOut) {
|
||||
VIDEO_FRAME_HANDLE handle;
|
||||
PDECODE_UNIT du;
|
||||
@@ -1736,18 +1736,18 @@ void FFmpegVideoDecoder::decoderThreadProc()
|
||||
"Resetting decoder due to consistent failure");
|
||||
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
// Don't consume any additional data
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
}
|
||||
|
||||
// Just in case the error resulted in the loss of the frame,
|
||||
// request an IDR frame to reset our decoder state.
|
||||
LiRequestIdrFrame();
|
||||
}
|
||||
} while (err == AVERROR(EAGAIN) && !SDL_AtomicGet(&m_DecoderThreadShouldQuit));
|
||||
} while (err == AVERROR(EAGAIN) && !SDL_GetAtomicInt(&m_DecoderThreadShouldQuit));
|
||||
|
||||
if (err != 0) {
|
||||
// Free the frame if we failed to submit it
|
||||
@@ -1862,11 +1862,11 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
"Resetting decoder due to consistent failure");
|
||||
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
// Don't consume any additional data
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
}
|
||||
|
||||
return DR_NEED_IDR;
|
||||
|
||||
Reference in New Issue
Block a user