Automated merge with tip of lindenlab/viewer64

Mon, 08 Jan 2018 09:51:51 -0800

author
callum
date
Mon, 08 Jan 2018 09:51:51 -0800
changeset 55056
0147f438ab4a
parent 55055
43ddbba15b0b
parent 54604
ad0e15543836
child 55057
d11c01d7cd73

Automated merge with tip of lindenlab/viewer64

     1.1 --- a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp	Fri Jan 05 18:27:30 2018 -0800
     1.2 +++ b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp	Mon Jan 08 09:51:51 2018 -0800
     1.3 @@ -37,6 +37,11 @@
     1.4  #include "vlc/vlc.h"
     1.5  #include "vlc/libvlc_version.h"
     1.6  
     1.7 +#if LL_WINDOWS
     1.8 +// needed for waveOut call - see below for description
     1.9 +#include <mmsystem.h>
    1.10 +#endif
    1.11 +
    1.12  ////////////////////////////////////////////////////////////////////////////////
    1.13  //
    1.14  class MediaPluginLibVLC :
    1.15 @@ -55,6 +60,7 @@
    1.16  	void playMedia();
    1.17  	void resetVLC();
    1.18  	void setVolume(const F64 volume);
    1.19 +	void setVolumeVLC();
    1.20  	void updateTitle(const char* title);
    1.21  
    1.22  	static void* lock(void* data, void** p_pixels);
    1.23 @@ -221,6 +227,7 @@
    1.24  	case libvlc_MediaPlayerPlaying:
    1.25  		parent->mDuration = (float)(libvlc_media_get_duration(parent->mLibVLCMedia)) / 1000.0f;
    1.26  		parent->mVlcStatus = STATUS_PLAYING;
    1.27 +		parent->setVolumeVLC();
    1.28  		break;
    1.29  
    1.30  	case libvlc_MediaPlayerPaused:
    1.31 @@ -394,26 +401,56 @@
    1.32  	sendMessage(message);
    1.33  }
    1.34  
    1.35 +void MediaPluginLibVLC::setVolumeVLC()
    1.36 +{
    1.37 +	if (mLibVLCMediaPlayer)
    1.38 +	{
    1.39 +		int vlc_vol = (int)(mCurVolume * 100);
    1.40 +
    1.41 +		int result = libvlc_audio_set_volume(mLibVLCMediaPlayer, vlc_vol);
    1.42 +		if (result == 0)
    1.43 +		{
    1.44 +			// volume change was accepted by LibVLC
    1.45 +		}
    1.46 +		else
    1.47 +		{
    1.48 +			// volume change was NOT accepted by LibVLC and not actioned
    1.49 +		}
    1.50 +
    1.51 +#if LL_WINDOWS
    1.52 +		// https ://jira.secondlife.com/browse/MAINT-8119
    1.53 +		// CEF media plugin uses code in media_plugins/cef/windows_volume_catcher.cpp to
    1.54 +		// set the actual output volume of the plugin process since there is no API in 
    1.55 +		// CEF to otherwise do this.
    1.56 +		// There are explicit calls to change the volume in LibVLC but sometimes they
    1.57 +		// are ignored SLPlugin.exe process volume is set to 0 so you never heard audio
    1.58 +		// from the VLC media stream.
    1.59 +		// The right way to solve this is to move the volume catcher stuff out of 
    1.60 +		// the CEF plugin and into it's own folder under media_plugins and have it referenced
    1.61 +		// by both CEF and VLC. That's for later. The code there boils down to this so for 
    1.62 +                // now, as we approach a release, the less risky option is to do it directly vs
    1.63 +                // calls to volume catcher code.
    1.64 +		DWORD left_channel = (DWORD)(mCurVolume * 65535.0f);
    1.65 +		DWORD right_channel = (DWORD)(mCurVolume * 65535.0f);
    1.66 +		DWORD hw_volume = left_channel << 16 | right_channel;
    1.67 +		waveOutSetVolume(NULL, hw_volume);
    1.68 +#endif
    1.69 +	}
    1.70 +	else
    1.71 +	{
    1.72 +		// volume change was requested but VLC wasn't ready.
    1.73 +		// that's okay though because we saved the value in mCurVolume and 
    1.74 +		// the next volume change after the VLC system is initilzied  will set it
    1.75 +	}
    1.76 +}
    1.77 +
    1.78  ////////////////////////////////////////////////////////////////////////////////
    1.79  //
    1.80  void MediaPluginLibVLC::setVolume(const F64 volume)
    1.81  {
    1.82  	mCurVolume = volume;
    1.83  
    1.84 -	if (mLibVLCMediaPlayer)
    1.85 -	{
    1.86 -		int result = libvlc_audio_set_volume(mLibVLCMediaPlayer, (int)(volume * 100));
    1.87 -		if (result != 0)
    1.88 -		{
    1.89 -			// volume wasn't set but not much to be done here
    1.90 -		}
    1.91 -	}
    1.92 -	else
    1.93 -	{
    1.94 -		// volume change was requested but VLC wasn't ready.
    1.95 -		// that's okay thought because we saved the value in mCurVolume and 
    1.96 -		// the next volume change after the VLC system is initilzied  will set it
    1.97 -	}
    1.98 +	setVolumeVLC();
    1.99  }
   1.100  
   1.101  ////////////////////////////////////////////////////////////////////////////////

mercurial