mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Implemented a better way to mute videos.
This commit is contained in:
parent
46c178af1d
commit
cfff577549
|
@ -30,7 +30,8 @@
|
|||
libvlc_instance_t* VideoVlcComponent::mVLC = nullptr;
|
||||
|
||||
// VLC prepares to render a video frame.
|
||||
static void* lock(void* data, void** p_pixels) {
|
||||
static void* lock(void* data, void** p_pixels)
|
||||
{
|
||||
struct VideoContext* c = reinterpret_cast<struct VideoContext*>(data);
|
||||
SDL_LockMutex(c->mutex);
|
||||
SDL_LockSurface(c->surface);
|
||||
|
@ -39,14 +40,16 @@ static void* lock(void* data, void** p_pixels) {
|
|||
}
|
||||
|
||||
// VLC just rendered a video frame.
|
||||
static void unlock(void* data, void* /*id*/, void *const* /*p_pixels*/) {
|
||||
static void unlock(void* data, void* /*id*/, void *const* /*p_pixels*/)
|
||||
{
|
||||
struct VideoContext* c = reinterpret_cast<struct VideoContext*>(data);
|
||||
SDL_UnlockSurface(c->surface);
|
||||
SDL_UnlockMutex(c->mutex);
|
||||
}
|
||||
|
||||
// VLC wants to display a video frame.
|
||||
static void display(void* /*data*/, void* /*id*/) {
|
||||
static void display(void* /*data*/, void* /*id*/)
|
||||
{
|
||||
// Data to be displayed.
|
||||
}
|
||||
|
||||
|
@ -357,11 +360,17 @@ void VideoVlcComponent::startVideo()
|
|||
// Setup the media player.
|
||||
mMediaPlayer = libvlc_media_player_new_from_media(mMedia);
|
||||
|
||||
libvlc_media_player_play(mMediaPlayer);
|
||||
libvlc_video_set_callbacks(mMediaPlayer, lock, unlock, display,
|
||||
reinterpret_cast<void*>(&mContext));
|
||||
libvlc_video_set_format(mMediaPlayer, "RGBA", static_cast<int>(mVideoWidth),
|
||||
static_cast<int>(mVideoHeight), static_cast<int>(mVideoWidth * 4));
|
||||
|
||||
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") &&
|
||||
!mScreensaverMode) ||
|
||||
(!Settings::getInstance()->getBool("ScreensaverVideoAudio") &&
|
||||
mScreensaverMode)) {
|
||||
libvlc_audio_set_mute(mMediaPlayer, 1);
|
||||
libvlc_audio_set_volume(mMediaPlayer, 0);
|
||||
}
|
||||
else {
|
||||
libvlc_audio_set_mute(mMediaPlayer, 0);
|
||||
|
@ -369,12 +378,6 @@ void VideoVlcComponent::startVideo()
|
|||
Settings::getInstance()->getInt("SoundVolumeVideos"));
|
||||
}
|
||||
|
||||
libvlc_media_player_play(mMediaPlayer);
|
||||
libvlc_video_set_callbacks(mMediaPlayer, lock, unlock, display,
|
||||
reinterpret_cast<void*>(&mContext));
|
||||
libvlc_video_set_format(mMediaPlayer, "RGBA", static_cast<int>(mVideoWidth),
|
||||
static_cast<int>(mVideoHeight), static_cast<int>(mVideoWidth * 4));
|
||||
|
||||
// Update the playing state.
|
||||
mIsPlaying = true;
|
||||
mFadeIn = 0.0f;
|
||||
|
@ -429,13 +432,12 @@ void VideoVlcComponent::handleLooping()
|
|||
}
|
||||
else {
|
||||
libvlc_media_player_set_media(mMediaPlayer, mMedia);
|
||||
libvlc_media_player_play(mMediaPlayer);
|
||||
|
||||
if ((!Settings::getInstance()->getBool("GamelistVideoAudio") &&
|
||||
!mScreensaverMode) || (!Settings::getInstance()->
|
||||
getBool("ScreensaverVideoAudio") && mScreensaverMode))
|
||||
libvlc_audio_set_mute(mMediaPlayer, 1);
|
||||
|
||||
libvlc_media_player_play(mMediaPlayer);
|
||||
libvlc_audio_set_volume(mMediaPlayer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue