Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Core/GameEngine/Include/GameClient/VideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ class VideoPlayerInterface : public SubsystemInterface
virtual const FieldParse *getFieldParse() const = 0; ///< Return the field parse info

virtual void notifyVideoPlayerOfNewProvider( Bool nowHasValid ) = 0; ///< Notify the video player that they can now ask for an audio handle, or they need to give theirs up.

virtual void setVolume( Real volume ) = 0; ///< Push a new speech volume to the video player's audio output
};


Expand Down Expand Up @@ -294,6 +296,8 @@ class VideoPlayer : public VideoPlayerInterface

virtual void notifyVideoPlayerOfNewProvider( Bool nowHasValid ) override { }

virtual void setVolume( Real volume ) override { }

// Implementation specific
void remove( VideoStream *stream ); ///< remove stream from active list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class BinkVideoStream : public VideoStream

class BinkVideoPlayer : public VideoPlayer
{
private:

// TheSuperHackers @bugfix Compute the Bink volume for a given speech volume.
static Int calculateMovieAudioVolume( Real speechVolume );

protected:

Expand All @@ -127,6 +131,7 @@ class BinkVideoPlayer : public VideoPlayer
virtual VideoStreamInterface* load( AsciiString movieTitle ) override; ///< Load video file in to memory for playback

virtual void notifyVideoPlayerOfNewProvider( Bool nowHasValid ) override;
virtual void setVolume( Real volume ) override;
virtual void initializeBinkWithMiles();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,12 @@ void MilesAudioManager::processPlayingList()

if (m_volumeHasChanged) {
m_volumeHasChanged = false;

// Push the new speech volume to any playing movie's audio output, which
// bypasses the Miles mixer and so does not see volume changes on its own.
if (TheVideoPlayer) {
TheVideoPlayer->setVolume(getVolume(AudioAffect_Speech));
}
}
}

Expand Down
35 changes: 27 additions & 8 deletions Core/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ void BinkVideoPlayer::reset()
void BinkVideoPlayer::update()
{
VideoPlayer::update();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come on now...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is not a good idea to prompt the LLM to revert whatever it did, and use a diff tool instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i revert the whitespace?

}

//============================================================================
Expand Down Expand Up @@ -202,18 +201,38 @@ VideoStreamInterface* BinkVideoPlayer::createStream( HBINK handle )
stream->m_player = this;
m_firstStream = stream;

// never let volume go to 0, as Bink will interpret that as "play at full volume".
Int mod = (Int) ((TheAudio->getVolume(AudioAffect_Speech) * 0.8f) * 100) + 1;
Int volume = (32768*mod)/100;
DEBUG_LOG(("BinkVideoPlayer::createStream() - About to set volume (%g -> %d -> %d",
TheAudio->getVolume(AudioAffect_Speech), mod, volume));
BinkSetVolume( stream->m_handle,0, volume);
DEBUG_LOG(("BinkVideoPlayer::createStream() - set volume"));
BinkSetVolume( stream->m_handle, 0, calculateMovieAudioVolume(TheAudio->getVolume(AudioAffect_Speech)) );
}

return stream;
}

//============================================================================
// BinkVideoPlayer::calculateMovieAudioVolume
//============================================================================

Int BinkVideoPlayer::calculateMovieAudioVolume( Real speechVolume )
{
// Never let volume go to 0, as Bink will interpret that as "play at full
// volume".
Int mod = (Int) ((speechVolume * 0.8f) * 100) + 1;
return (32768*mod)/100;
}

//============================================================================
// BinkVideoPlayer::setVolume
//============================================================================

void BinkVideoPlayer::setVolume( Real volume )
{
// Push the new volume to every open stream's audio output.
Int binkVolume = calculateMovieAudioVolume( volume );
for ( VideoStreamInterface *stream = firstStream(); stream != nullptr; stream = stream->next() )
{
BinkSetVolume( static_cast<BinkVideoStream*>( stream )->m_handle, 0, binkVolume );
}
}

//============================================================================
// BinkVideoPlayer::open
//============================================================================
Expand Down
Loading