Skip to content
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,9 @@ class BinkVideoStream : public VideoStream

class BinkVideoPlayer : public VideoPlayer
{
private:

static Int calculateMovieAudioVolume( Real volume );

protected:

Expand All @@ -127,6 +130,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,11 @@ void MilesAudioManager::processPlayingList()

if (m_volumeHasChanged) {
m_volumeHasChanged = false;

// Push speech volume changes because Bink movie audio bypasses the Miles mixer.
if (TheVideoPlayer) {
TheVideoPlayer->setVolume(getVolume(AudioAffect_Speech));
}
}
}

Expand Down
34 changes: 26 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();

Comment thread
xezon marked this conversation as resolved.
}

//============================================================================
Expand Down Expand Up @@ -202,18 +201,37 @@ 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 volume )
{
// Never let volume go to 0, as Bink will interpret that as "play at full volume".
Int mod = (Int) ((volume * 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