1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-19 11:49:09 +00:00

Initial pass at getting subtitle support in. Doesn't compile for unknown reasons

This commit is contained in:
ZarothYe
2022-02-23 21:35:03 -06:00
parent 84eedce685
commit 229883654e
22 changed files with 579 additions and 39 deletions

View File

@ -994,6 +994,7 @@ hsBool plgAudioSys::fInit = false;
hsBool plgAudioSys::fActive = false;
hsBool plgAudioSys::fUseHardware = false;
hsBool plgAudioSys::fMuted = true;
bool plgAudioSys::fEnableSubtitles = false;
hsBool plgAudioSys::fDelayedActivate = false;
hsBool plgAudioSys::fEnableEAX = false;
hsWindowHndl plgAudioSys::fWnd = nil;
@ -1047,6 +1048,11 @@ void plgAudioSys::SetMuted( hsBool b )
SetGlobalFadeVolume(1.0);
}
void plgAudioSys::SetEnableSubtitles(bool b)
{
fEnableSubtitles = b;
}
void plgAudioSys::SetUseHardware(hsBool b)
{
fUseHardware = b;

View File

@ -193,11 +193,13 @@ public:
static void SetUseHardware(hsBool b);
static void SetActive(hsBool b);
static void SetMuted( hsBool b );
static void SetEnableSubtitles(bool b);
static void EnableEAX( hsBool b );
static hsBool Active() { return fInit; }
static void Shutdown();
static void Activate(hsBool b);
static hsBool IsMuted( void ) { return fMuted; }
static bool AreSubtitlesEnabled() { return fEnableSubtitles; }
static hsWindowHndl hWnd() { return fWnd; }
static plAudioSystem* Sys() { return fSys; }
static void Restart( void );

View File

@ -53,10 +53,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plWavFile.h"
#include "../plAudible/plWinAudible.h"
#include "../plAudioCore/plSrtFileReader.h"
#include "../pnMessage/plEventCallbackMsg.h"
#include "../pnMessage/plSoundMsg.h"
#include "../plMessage/plSubtitleMsg.h"
#include "../plNetMessage/plNetMessage.h"
#include "../pnNetCommon/plNetApp.h"
#include "../pnMessage/plSoundMsg.h"
#include "../pnMessage/plEventCallbackMsg.h"
#include "../plPipeline/plPlates.h"
#include "../plStatusLog/plStatusLog.h"
@ -108,6 +110,18 @@ void plWin32Sound::IFreeBuffers( void )
void plWin32Sound::Update()
{
plSoundBuffer* buf = GetDataBuffer();
if (plgAudioSys::AreSubtitlesEnabled() && buf != nullptr) {
plSrtFileReader* srtReader = buf->GetSrtReader();
if (srtReader != nullptr) {
while (plSrtEntry* nextEntry = srtReader->GetNextEntryStartingBeforeTime((uint32_t)(GetActualTimeSec() * 1000.0f))) {
// add a plSubtitleMsg to go... to whoever is listening (probably the KI)
plSubtitleMsg* msg = new plSubtitleMsg(nextEntry->GetSubtitleText(), nextEntry->GetSpeakerName());
msg->Send();
}
}
}
plSound::Update();
}
@ -120,6 +134,17 @@ void plWin32Sound::IActuallyPlay( void )
{
if (fDSoundBuffer && plgAudioSys::Active() )
{
if (!fReallyPlaying && fSynchedStartTimeSec > 0) {
// advance past any subtitles that would end before the synched start time
// not sure when this actually happens...
plSoundBuffer* buf = GetDataBuffer();
if (buf != nullptr) {
plSrtFileReader* srtReader = buf->GetSrtReader();
if (srtReader != nullptr) {
srtReader->AdvanceToTime(fSynchedStartTimeSec * 1000.0);
}
}
}
// Sometimes base/derived classes can be annoying
IDerivedActuallyPlay();