diff options
| author | callum_linden <none@none> | 2013-01-07 13:08:40 -0800 | 
|---|---|---|
| committer | callum_linden <none@none> | 2013-01-07 13:08:40 -0800 | 
| commit | 8c654704d4aeea045f26ec5aa8ad7d44b8ec9818 (patch) | |
| tree | 97c398281ac4778d824e6fd3b03d4daa92fe7350 | |
| parent | 0d12d171cf20c63a45e7ad0989e65d05aabb86ea (diff) | |
| parent | 88fe6da622eccd2ad2874bb59610932a982f7c9e (diff) | |
merge with head
| -rw-r--r-- | indra/media_plugins/webkit/windows_volume_catcher.cpp | 52 | 
1 files changed, 41 insertions, 11 deletions
| diff --git a/indra/media_plugins/webkit/windows_volume_catcher.cpp b/indra/media_plugins/webkit/windows_volume_catcher.cpp index 5fb84756ee..b0c3134eb0 100644 --- a/indra/media_plugins/webkit/windows_volume_catcher.cpp +++ b/indra/media_plugins/webkit/windows_volume_catcher.cpp @@ -48,18 +48,37 @@ private:  	set_volume_func_t mSetVolumeFunc;  	set_mute_func_t mSetMuteFunc; +	// tests if running on Vista, 7, 8 + once in CTOR +	bool isWindowsVistaOrHigher(); +  	F32 	mVolume;  	F32 	mPan; +	bool mSystemIsVistaOrHigher;  }; + +bool VolumeCatcherImpl::isWindowsVistaOrHigher()
 +{
 +	OSVERSIONINFO osvi;
 +	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
 +	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 +	GetVersionEx(&osvi);
 +	return osvi.dwMajorVersion >= 6;
 +}
 +  VolumeCatcherImpl::VolumeCatcherImpl() -:	mVolume(1.0f),	// default volume is max -	mPan(0.f)		// default pan is centered +:	mVolume(1.0f),			// default volume is max +	mPan(0.f)				// default pan is centered  { -	HMODULE handle = ::LoadLibrary(L"winmm.dll"); -	if(handle) +	mSystemIsVistaOrHigher = isWindowsVistaOrHigher(); + +	if ( mSystemIsVistaOrHigher )  	{ -		mSetVolumeFunc = (set_volume_func_t)::GetProcAddress(handle, "setPluginVolume"); -		mSetMuteFunc = (set_mute_func_t)::GetProcAddress(handle, "setPluginMute"); +		HMODULE handle = ::LoadLibrary(L"winmm.dll"); +		if(handle) +		{ +			mSetVolumeFunc = (set_volume_func_t)::GetProcAddress(handle, "setPluginVolume"); +			mSetMuteFunc = (set_mute_func_t)::GetProcAddress(handle, "setPluginMute"); +		}  	}  } @@ -67,18 +86,29 @@ VolumeCatcherImpl::~VolumeCatcherImpl()  {  } -  void VolumeCatcherImpl::setVolume(F32 volume)  {  	mVolume = volume; -	if (mSetMuteFunc) +	if ( mSystemIsVistaOrHigher )  	{ -		mSetMuteFunc(volume == 0.f); +		// set both left/right to same volume +		// TODO: use pan value to set independently +		DWORD left_channel  = (DWORD)(mVolume * 65535.0f); +		DWORD right_channel =  (DWORD)(mVolume * 65535.0f); +		DWORD hw_volume = left_channel << 16 | right_channel; +		::waveOutSetVolume(NULL, hw_volume);  	} -	if (mSetVolumeFunc) +	else  	{ -		mSetVolumeFunc(mVolume); +		if (mSetMuteFunc) +		{ +			mSetMuteFunc(volume == 0.f); +		} +		if (mSetVolumeFunc) +		{ +			mSetVolumeFunc(mVolume); +		}  	}  } | 
