Skip to content

Commit e0d794b

Browse files
committed
Removed COM audio control from webbrowser stuff (consistency and does not work with Flash anyway)
Added MTA build tag to the CEF user agent
1 parent 9f56a0b commit e0d794b

File tree

4 files changed

+5
-68
lines changed

4 files changed

+5
-68
lines changed

MTA10/core/CWebCore.cpp

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "CWebCore.h"
1313
#include "CWebView.h"
1414
#include "CWebsiteRequests.h"
15-
#include <Audiopolicy.h>
1615
#include <cef3/include/cef_app.h>
1716
#include <cef3/include/cef_browser.h>
1817
#include <cef3/include/cef_sandbox_win.h>
@@ -37,12 +36,6 @@ CWebCore::CWebCore ()
3736

3837
// Update dynamic lists from QA server
3938
UpdateListsFromMaster ();
40-
41-
// Get AudioVolume COM interface if the Audio Core API is available
42-
if ( GetApplicationSetting("os-version") >= "6.2" )
43-
{
44-
InitialiseCoreAudio ();
45-
}
4639
}
4740

4841
CWebCore::~CWebCore ()
@@ -401,71 +394,14 @@ void CWebCore::ClearTextures ()
401394
}
402395
}
403396

404-
bool CWebCore::InitialiseCoreAudio()
405-
{
406-
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
407-
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
408-
const IID IID_IAudioSessionManager2 = __uuidof(IAudioSessionManager2);
409-
410-
IMMDeviceEnumerator* pEnumerator;
411-
CoCreateInstance ( CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pEnumerator );
412-
if ( !pEnumerator )
413-
return false;
414-
415-
IMMDevice* pMMDevice;
416-
pEnumerator->GetDefaultAudioEndpoint ( EDataFlow::eRender, ERole::eMultimedia, &pMMDevice );
417-
pEnumerator->Release ();
418-
if ( !pMMDevice )
419-
return false;
420-
421-
IAudioSessionManager2* pAudioSessionManager;
422-
pMMDevice->Activate ( IID_IAudioSessionManager2, 0, NULL, (void**)&pAudioSessionManager );
423-
pMMDevice->Release ();
424-
if ( !pAudioSessionManager )
425-
return false;
426-
427-
m_pAudioSessionManager = pAudioSessionManager;
428-
return true;
429-
}
430-
431397
bool CWebCore::SetGlobalAudioVolume ( float fVolume )
432398
{
433399
if ( fVolume < 0.0f || fVolume > 1.0f )
434400
return false;
435401

436-
if ( GetApplicationSetting ( "os-version" ) < "6.2" || !m_pAudioSessionManager )
437-
{
438-
for ( auto& pWebView : m_WebViews )
439-
{
440-
pWebView->SetAudioVolume ( fVolume );
441-
}
442-
}
443-
else
402+
for ( auto& pWebView : m_WebViews )
444403
{
445-
IAudioSessionEnumerator* pSessionEnumerator;
446-
m_pAudioSessionManager->GetSessionEnumerator ( &pSessionEnumerator );
447-
if ( !pSessionEnumerator )
448-
return false;
449-
450-
// Obtain the associated ISimpleAudioVolume interface
451-
int sessionCount;
452-
pSessionEnumerator->GetCount ( &sessionCount );
453-
for ( int i = 0; i < sessionCount; ++i )
454-
{
455-
IAudioSessionControl2* pSessionControl;
456-
pSessionEnumerator->GetSession ( i, (IAudioSessionControl**)&pSessionControl );
457-
PWSTR szIdentifier;
458-
pSessionControl->GetSessionIdentifier(&szIdentifier);
459-
460-
if ( std::wstring(szIdentifier).find(L"CEFLauncher") != std::string::npos )
461-
{
462-
ISimpleAudioVolume* pSimpleAudioVolume;
463-
pSessionControl->QueryInterface ( &pSimpleAudioVolume );
464-
pSimpleAudioVolume->SetMasterVolume ( fVolume, NULL );
465-
}
466-
pSessionControl->Release ();
467-
}
468-
pSessionEnumerator->Release ();
404+
pWebView->SetAudioVolume ( fVolume );
469405
}
470406
return true;
471407
}

MTA10/core/CWebCore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class CWebCore : public CWebCoreInterface
8181
void OnPreScreenshot ();
8282
void OnPostScreenshot ();
8383

84-
bool InitialiseCoreAudio ();
8584
bool SetGlobalAudioVolume( float fVolume );
8685

8786
bool UpdateListsFromMaster();

MTA10/core/CWebView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ bool CWebView::OnBeforeResourceLoad ( CefRefPtr<CefBrowser> browser, CefRefPtr<C
516516
if ( iter != headerMap.end () )
517517
{
518518
// Add MTA:SA "watermark"
519-
iter->second = iter->second.ToString () + "; Multi Theft Auto: San Andreas Client";
519+
iter->second = iter->second.ToString () + "; " MTA_CEF_USERAGENT;
520520

521521
// Add 'Android' to get the mobile version
522522
SString strPropertyValue;

MTA10/core/CWebView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define GetNextSibling(hwnd) GetWindow(hwnd, GW_HWNDNEXT) // Re-define the conflicting macro
2828
#define GetFirstChild(hwnd) GetTopWindow(hwnd)
2929

30+
#define MTA_CEF_USERAGENT "Multi Theft Auto: San Andreas Client " MTA_DM_BUILDTAG_LONG
31+
3032
class CWebView : public CWebViewInterface, private CefClient, private CefRenderHandler, private CefLoadHandler, private CefRequestHandler, private CefLifeSpanHandler, private CefJSDialogHandler, private CefDialogHandler, private CefDisplayHandler
3133
{
3234
public:

0 commit comments

Comments
 (0)