Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ endif()

# Find/Add build dependencies and stubs shared by all projects
if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
include(cmake/miles.cmake)
include(cmake/bink.cmake)
include(cmake/dx8.cmake)
endif()

Expand Down Expand Up @@ -84,6 +82,9 @@ if (IS_VS6_BUILD)
add_compile_options(/FIUtility/CppMacros.h)
endif()

add_subdirectory(Dependencies/Bink)
add_subdirectory(Dependencies/Miles)

add_subdirectory(resources)

add_subdirectory(Core)
Expand Down
4 changes: 2 additions & 2 deletions Core/GameEngineDevice/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ target_link_libraries(corei_gameenginedevice_private INTERFACE
)

target_link_libraries(corei_gameenginedevice_public INTERFACE
binkstub
binkloader
corei_gameengine_public
d3d8lib
milesstub
milesloader
)

if(RTS_BUILD_OPTION_FFMPEG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ class MilesAudioManager : public AudioManager
UnsignedInt m_num3DSamples;
UnsignedInt m_numStreams;

Bool m_deviceOpened;
Bool m_milesLoaded;

#if defined(RTS_DEBUG)
typedef std::set<AsciiString> SetAsciiString;
typedef SetAsciiString::iterator SetAsciiStringIt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "Common/file.h"

#include <Utility/interlocked_adapter.h>
#include "MilesLoader.h"


enum { INFINITE_LOOP_COUNT = 1000000 };
Expand All @@ -91,6 +92,8 @@ MilesAudioManager::MilesAudioManager() :
m_num2DSamples(0),
m_num3DSamples(0),
m_numStreams(0),
m_deviceOpened(false),
m_milesLoaded(false),
m_delayFilter(nullptr),
m_binkHandle(nullptr),
m_pref3DProvider(AsciiString::TheEmptyString),
Expand Down Expand Up @@ -1369,6 +1372,18 @@ void MilesAudioManager::openDevice()
return;
}

m_deviceOpened = true;

// Load the Miles Sound System on runtime here instead of importing it into the executable.
if (!MilesLoader::load())
{
DEBUG_LOG(("Failed to load mss32.dll (error %d). Audio will be turned off.", MilesLoader::getLastError()));
setOn(false, AudioAffect_All);
return;
}

m_milesLoaded = true;

AIL_set_redist_directory("MSS\\");
AIL_startup();
Int retval = 0;
Expand Down Expand Up @@ -1404,9 +1419,18 @@ void MilesAudioManager::openDevice()
//-------------------------------------------------------------------------------------------------
void MilesAudioManager::closeDevice()
{
freeAllMilesHandles();
unselectProvider();
AIL_shutdown();
if (m_deviceOpened)
{
if (m_milesLoaded)
{
freeAllMilesHandles();
unselectProvider();
AIL_shutdown();
m_milesLoaded = false;
}
MilesLoader::unload();
m_deviceOpened = false;
}
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2760,7 +2784,7 @@ void MilesAudioManager::initSamplePools()
DEBUG_ASSERTCRASH(sample, ("Couldn't get %d 2D samples", i + 1));
if (sample) {
AIL_init_sample(sample);
AIL_set_sample_user_data(sample, 0, (void *)(i + 1));
AIL_set_sample_user_data(sample, 0, i + 1);
m_availableSamples.push_back(sample);
++m_num2DSamples;
}
Expand All @@ -2770,7 +2794,7 @@ void MilesAudioManager::initSamplePools()
H3DSAMPLE sample = AIL_allocate_3D_sample_handle(m_provider3D[m_selectedProvider].id);
DEBUG_ASSERTCRASH(sample, ("Couldn't get %d 3D samples", i + 1));
if (sample) {
AIL_set_3D_user_data(sample, 0, (void *)(i + 1));
AIL_set_3D_user_data(sample, 0, i + 1);
m_available3DSamples.push_back(sample);
++m_num3DSamples;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "Common/GameMemory.h"
#include "Common/GlobalData.h"
#include "Common/Registry.h"
#include "BinkLoader.h"

//----------------------------------------------------------------------------
// Externals
Expand Down Expand Up @@ -130,6 +131,12 @@ void BinkVideoPlayer::init()
// Need to load the stuff from the ini file.
VideoPlayer::init();

// Load Bink on runtime instead of importing it into the executable.
if (!BinkLoader::load())
{
DEBUG_LOG(("Failed to load binkw32.dll (error %d). Videos will not play.", BinkLoader::getLastError()));
}

initializeBinkWithMiles();
}

Expand All @@ -141,6 +148,7 @@ void BinkVideoPlayer::deinit()
{
TheAudio->releaseHandleForBink();
VideoPlayer::deinit();
BinkLoader::unload();
}

//============================================================================
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target_compile_definitions(core_wwcommon INTERFACE

target_link_libraries(core_wwcommon INTERFACE
d3d8lib
milesstub
milesloader
stlport
)

Expand Down
23 changes: 16 additions & 7 deletions Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "WWSaveLoad/definitionclassids.h"
#include "WWDebug/wwmemlog.h"
#include "WWDebug/wwprofile.h"
#include "MilesLoader.h"


#ifdef G_CODE_BASE
Expand Down Expand Up @@ -129,6 +130,13 @@ WWAudioClass::WWAudioClass ()
{
::InitializeCriticalSection (&MMSLockClass::_MSSLockCriticalSection);

//
// Load the Miles Sound System on runtime instead of importing it into the executable.
//
if (MilesLoader::load () == false) {
WWDEBUG_SAY (("Failed to load mss32.dll (error %d). Audio will not play.", MilesLoader::getLastError ()));
}

//
// Start Miles Sound System
//
Expand Down Expand Up @@ -161,6 +169,9 @@ WWAudioClass::~WWAudioClass ()
WWAudioThreadsClass::End_Delayed_Release_Thread ();

Shutdown ();

MilesLoader::unload ();

_theInstance = nullptr;
::CloseHandle(_TimerSyncEvent);
_TimerSyncEvent = nullptr;
Expand Down Expand Up @@ -231,11 +242,10 @@ WWAudioClass::Open_2D_Device (LPWAVEFORMAT format)
AIL_set_preference (AIL_LOCK_PROTECTION, NO);

// Try to use DirectSound if possible
S32 success = ::AIL_set_preference (DIG_USE_WAVEOUT, FALSE);
WWASSERT (success == AIL_NO_ERROR);
::AIL_set_preference (DIG_USE_WAVEOUT, FALSE);

// Open the driver
success = ::AIL_waveOutOpen (&m_Driver2D, nullptr, 0, format);
S32 success = ::AIL_waveOutOpen (&m_Driver2D, nullptr, 0, format);

// Do we need to switch from direct sound to waveout?
if ((success == AIL_NO_ERROR) &&
Expand All @@ -251,8 +261,7 @@ WWAudioClass::Open_2D_Device (LPWAVEFORMAT format)
if (success != AIL_NO_ERROR) {

// Try to use the default wave out driver
success = ::AIL_set_preference (DIG_USE_WAVEOUT, TRUE);
WWASSERT (success == AIL_NO_ERROR);
::AIL_set_preference (DIG_USE_WAVEOUT, TRUE);

// Open the driver
success = ::AIL_waveOutOpen (&m_Driver2D, nullptr, 0, format);
Expand Down Expand Up @@ -1374,7 +1383,7 @@ WWAudioClass::Allocate_2D_Handles ()
for (int index = 0; index < m_Max2DSamples; index ++) {
HSAMPLE sample = ::AIL_allocate_sample_handle (m_Driver2D);
if (sample != nullptr) {
::AIL_set_sample_user_data (sample, INFO_OBJECT_PTR, nullptr);
::AIL_set_sample_user_data (sample, INFO_OBJECT_PTR, 0);
m_2DSampleHandles.Add (sample);
}
}
Expand Down Expand Up @@ -1819,7 +1828,7 @@ WWAudioClass::Allocate_3D_Handles ()
for (int index = 0; index < m_Max3DSamples; index ++) {
H3DSAMPLE sample = ::AIL_allocate_3D_sample_handle (m_Driver3D);
if (sample != nullptr) {
::AIL_set_3D_object_user_data (sample, INFO_OBJECT_PTR, nullptr);
::AIL_set_3D_object_user_data (sample, INFO_OBJECT_PTR, 0);
m_3DSampleHandles.Add (sample);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void
Sound2DHandleClass::Set_Sample_User_Data (S32 i, void *val)
{
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
::AIL_set_sample_user_data (SampleHandle, i, val);
::AIL_set_sample_user_data (SampleHandle, i, (S32)val);
}
}

Expand All @@ -308,7 +308,7 @@ Sound2DHandleClass::Get_Sample_User_Data (S32 i)
void *retval = nullptr;

if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
retval = ::AIL_sample_user_data (SampleHandle, i);
retval = (void *)::AIL_sample_user_data (SampleHandle, i);
}

return retval;
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void
Sound3DHandleClass::Set_Sample_User_Data (S32 i, void *val)
{
if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
::AIL_set_3D_object_user_data (SampleHandle, i, val);
::AIL_set_3D_object_user_data (SampleHandle, i, (S32)val);
}
}

Expand All @@ -307,7 +307,7 @@ Sound3DHandleClass::Get_Sample_User_Data (S32 i)
void *retval = nullptr;

if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) {
retval = AIL_3D_object_user_data (SampleHandle, i);
retval = (void *)AIL_3D_object_user_data (SampleHandle, i);
}

return retval;
Expand Down
4 changes: 2 additions & 2 deletions Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void
SoundStreamHandleClass::Set_Sample_User_Data (S32 i, void *val)
{
if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
::AIL_set_sample_user_data (SampleHandle, i, val);
::AIL_set_sample_user_data (SampleHandle, i, (S32)val);
}
}

Expand All @@ -310,7 +310,7 @@ SoundStreamHandleClass::Get_Sample_User_Data (S32 i)
void *retval = nullptr;

if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) {
retval = ::AIL_sample_user_data (SampleHandle, i);
retval = (void *)::AIL_sample_user_data (SampleHandle, i);
}

return retval;
Expand Down
Loading
Loading