Skip to content

Commit

Permalink
Almost match THPPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrkol committed Feb 5, 2025
1 parent dbd0404 commit 8627df9
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 135 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def MatchingFor(*versions):
Object(Matching, "THPPlayer/THPDraw.c"),
Object(NonMatching, "THPPlayer/THPPlayer.c"),
Object(Matching, "THPPlayer/THPRead.c"),
Object(NonMatching, "THPPlayer/THPVideoDecode.c"),
Object(Matching, "THPPlayer/THPVideoDecode.c"),
],
},
{
Expand Down
11 changes: 8 additions & 3 deletions include/THPPlayer/THPPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
extern "C" {
#endif

#define THP_AUDIO_BUFFER_COUNT 3
#define THP_READ_BUFFER_COUNT 10
#define THP_TEXTURE_SET_COUNT 3

typedef struct THPPlayer {
DVDFileInfo fileInfo;
THPHeader header;
Expand Down Expand Up @@ -47,8 +51,8 @@ typedef struct THPPlayer {
THPTextureSet* dispTextureSet;
THPAudioBuffer* playAudioBuffer;
THPReadBuffer readBuffer[10];
THPTextureSet textureSet[3];
THPAudioBuffer audioBuffer[6];
THPTextureSet textureSet[THP_TEXTURE_SET_COUNT];
THPAudioBuffer audioBuffer[THP_AUDIO_BUFFER_COUNT];
} THPPlayer; // Size: 0x1d0

extern THPPlayer ActivePlayer;
Expand All @@ -67,14 +71,15 @@ BOOL THPPlayerSetBuffer(u8* data);
u32 THPPlayerCalcNeedMemory();

BOOL THPPlayerGetVideoInfo(THPVideoInfo* videoInfo);
// BOOL THPPlayerGetAudioInfo(void *dst);
BOOL THPPlayerGetAudioInfo(THPAudioInfo *audioInfo);
// f32 THPPlayerGetFrameRate();
BOOL THPPlayerSetVolume(s32 vol, s32 duration);

s32 THPPlayerDrawCurrentFrame(GXRenderModeObj* rmode, u32 x, u32 y,
u32 polygonW, u32 polygonH);
u32 THPPlayerGetTotalFrame();
s32 THPPlayerGetState();
void THPPlayerDrawDone();

void THPPlayerPostDrawDone();

Expand Down
14 changes: 8 additions & 6 deletions src/THPPlayer/THPAudioDecode.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#include <THPPlayer/THPAudioDecode.h>

#include <THPPlayer/THPPlayer.h>
#include <THPPlayer/THPRead.h>
#include <THPPlayer/THPPlayer.h>
#include <dolphin/thp.h>
#include <dolphin/os.h>

#pragma opt_strength_reduction off

#define STACK_SIZE 4096
#define BUFFER_COUNT 3

static OSThread AudioDecodeThread;
static u8 AudioDecodeThreadStack[STACK_SIZE];
static OSMessageQueue FreeAudioBufferQueue;
static OSMessageQueue DecodedAudioBufferQueue;
static OSMessage FreeAudioBufferMessage[BUFFER_COUNT];
static OSMessage DecodedAudioBufferMessage[BUFFER_COUNT];
static OSMessage FreeAudioBufferMessage[THP_AUDIO_BUFFER_COUNT];
static OSMessage DecodedAudioBufferMessage[THP_AUDIO_BUFFER_COUNT];

static BOOL AudioDecodeThreadCreated;

Expand All @@ -39,9 +41,9 @@ BOOL CreateAudioDecodeThread(OSPriority prio, void* arg)
}

OSInitMessageQueue(&FreeAudioBufferQueue, FreeAudioBufferMessage,
BUFFER_COUNT);
THP_AUDIO_BUFFER_COUNT);
OSInitMessageQueue(&DecodedAudioBufferQueue, DecodedAudioBufferMessage,
BUFFER_COUNT);
THP_AUDIO_BUFFER_COUNT);
AudioDecodeThreadCreated = TRUE;
return TRUE;
}
Expand Down Expand Up @@ -72,8 +74,8 @@ static void* AudioDecoder(void* arg)

static void* AudioDecoderForOnMemory(void* arg)
{
s32 readSize;
s32 frame;
s32 readSize;
THPReadBuffer readBuffer;

frame = 0;
Expand Down
Loading

0 comments on commit 8627df9

Please sign in to comment.