mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-23 00:19:53 +00:00
Revert "Remove decoding thread like in Java common"
This reverts commit 50733f6d7a.
This commit is contained in:
@@ -18,6 +18,7 @@ static SOCKET firstFrameSocket = INVALID_SOCKET;
|
||||
|
||||
static PLT_THREAD udpPingThread;
|
||||
static PLT_THREAD receiveThread;
|
||||
static PLT_THREAD decoderThread;
|
||||
|
||||
void initializeVideoStream(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, PDECODER_RENDERER_CALLBACKS drCallbacks,
|
||||
PCONNECTION_LISTENER_CALLBACKS clCallbacks) {
|
||||
@@ -82,6 +83,20 @@ static void ReceiveThreadProc(void* context) {
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static void DecoderThreadProc(void* context) {
|
||||
PDECODE_UNIT du;
|
||||
while (!PltIsThreadInterrupted(&decoderThread)) {
|
||||
if (!getNextDecodeUnit(&du)) {
|
||||
printf("Decoder thread terminating\n");
|
||||
return;
|
||||
}
|
||||
|
||||
callbacks.submitDecodeUnit(du);
|
||||
|
||||
freeDecodeUnit(du);
|
||||
}
|
||||
}
|
||||
|
||||
int readFirstFrame(void) {
|
||||
char* firstFrame;
|
||||
int err;
|
||||
@@ -118,6 +133,7 @@ void stopVideoStream(void) {
|
||||
|
||||
PltInterruptThread(&udpPingThread);
|
||||
PltInterruptThread(&receiveThread);
|
||||
PltInterruptThread(&decoderThread);
|
||||
|
||||
if (firstFrameSocket != INVALID_SOCKET) {
|
||||
closesocket(firstFrameSocket);
|
||||
@@ -130,9 +146,11 @@ void stopVideoStream(void) {
|
||||
|
||||
PltJoinThread(&udpPingThread);
|
||||
PltJoinThread(&receiveThread);
|
||||
PltJoinThread(&decoderThread);
|
||||
|
||||
PltCloseThread(&udpPingThread);
|
||||
PltCloseThread(&receiveThread);
|
||||
PltCloseThread(&decoderThread);
|
||||
}
|
||||
|
||||
int startVideoStream(void* rendererContext, int drFlags) {
|
||||
@@ -158,6 +176,11 @@ int startVideoStream(void* rendererContext, int drFlags) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = PltCreateThread(DecoderThreadProc, NULL, &decoderThread);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
callbacks.start();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user