mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Fix XAudio2 cinematic audio and restore Windows build
(cherry picked from commit f09a3083e220f1a715816e097e0e5342ca48456d)
This commit is contained in:
parent
3be85d9c4b
commit
846c00c885
6 changed files with 24 additions and 12 deletions
|
@ -1537,7 +1537,7 @@ if(MSVC)
|
|||
include_directories(libs/ffmpeg-win64/include)
|
||||
include_directories(libs/ffmpeg-win64/include/libswscale)
|
||||
include_directories(libs/ffmpeg-win64/include/libavformat)
|
||||
include_directories(libs/ffmpeg-win64/include/libavutil)
|
||||
include_directories(libs/ffmpeg-win64/include/libavdevice)
|
||||
include_directories(libs/ffmpeg-win64/include/libavcodec)
|
||||
include_directories(libs/ffmpeg-win64/include/libswresample)
|
||||
|
||||
|
@ -1546,7 +1546,7 @@ if(MSVC)
|
|||
include_directories(libs/ffmpeg-win32/include)
|
||||
include_directories(libs/ffmpeg-win32/include/libswscale)
|
||||
include_directories(libs/ffmpeg-win32/include/libavformat)
|
||||
include_directories(libs/ffmpeg-win32/include/libavutil)
|
||||
include_directories(libs/ffmpeg-win32/include/libavdevice)
|
||||
include_directories(libs/ffmpeg-win32/include/libavcodec)
|
||||
include_directories(libs/ffmpeg-win32/include/libswresample)
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ extern "C"
|
|||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
}
|
||||
// SRS - For handling cinematic audio packets
|
||||
#include <queue>
|
||||
#define NUM_PACKETS 4
|
||||
bool hasplanar = true;
|
||||
#endif
|
||||
|
||||
|
@ -127,7 +130,7 @@ private:
|
|||
cinData_t ImageForTimeFFMPEG( int milliseconds );
|
||||
bool InitFromFFMPEGFile( const char* qpath, bool looping );
|
||||
void FFMPEGReset();
|
||||
std::queue<AVPacket> packets[NUM_BUFFERS];
|
||||
std::queue<AVPacket> packets[NUM_PACKETS];
|
||||
#endif
|
||||
#ifdef USE_BINKDEC
|
||||
BinkHandle binkHandle;
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
#else
|
||||
#include <AL/al.h>
|
||||
#endif
|
||||
#include <queue>
|
||||
#ifndef __CINEMATIC_AUDIO_AL_H__
|
||||
#define __CINEMATIC_AUDIO_AL_H__
|
||||
|
||||
#include <queue>
|
||||
#define NUM_BUFFERS 4
|
||||
|
||||
class CinematicAudio_OpenAL: public CinematicAudio
|
||||
|
@ -50,10 +51,10 @@ private:
|
|||
bool trigger;
|
||||
|
||||
//GK: Unlike XAudio2 which can accept buffer until the end of this world.
|
||||
// OpenAL can accept buffers as long as there are freely available buffers.
|
||||
// OpenAL can accept buffers only as long as there are freely available buffers.
|
||||
// So, what happens if there are no freely available buffers but we still geting audio frames ? Loss of data.
|
||||
// That why now I am using two queues in order to store the frames (and their sizes) and when we have available buffers,
|
||||
// then start poping those frames instead of the current, so we don't lose any audio frames and the sound doesn't crack anymore.
|
||||
// then start popping those frames instead of the current, so we don't lose any audio frames and the sound doesn't crack anymore.
|
||||
std::queue<uint8_t*> tBuffer[NUM_BUFFERS];
|
||||
std::queue<int> sizes[NUM_BUFFERS];
|
||||
};
|
||||
|
|
|
@ -33,6 +33,11 @@ extern "C"
|
|||
}
|
||||
#endif
|
||||
|
||||
CinematicAudio_XAudio2::CinematicAudio_XAudio2():
|
||||
pMusicSourceVoice1(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void CinematicAudio_XAudio2::InitAudio( void* audioContext )
|
||||
{
|
||||
//SRS - This InitAudio() implementation is FFMPEG-only until we have a BinkDec solution as well
|
||||
|
@ -55,6 +60,12 @@ void CinematicAudio_XAudio2::InitAudio( void* audioContext )
|
|||
format_byte = 2;
|
||||
break;
|
||||
}
|
||||
case AV_SAMPLE_FMT_S32:
|
||||
case AV_SAMPLE_FMT_S32P:
|
||||
{
|
||||
format_byte = 4;
|
||||
break;
|
||||
}
|
||||
case AV_SAMPLE_FMT_FLT:
|
||||
case AV_SAMPLE_FMT_FLTP:
|
||||
{
|
||||
|
@ -103,7 +114,7 @@ void CinematicAudio_XAudio2::InitAudio( void* audioContext )
|
|||
exvoice.Samples.wValidBitsPerSample = voiceFormatcine.wBitsPerSample;
|
||||
exvoice.Samples.wSamplesPerBlock = voiceFormatcine.wBitsPerSample;
|
||||
exvoice.SubFormat = use_ext ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM;
|
||||
( ( IXAudio2* )soundSystemLocal.GetInternal() )->CreateSourceVoice( &pMusicSourceVoice1, ( WAVEFORMATEX* )&exvoice, XAUDIO2_VOICE_USEFILTER ); //Use the XAudio2 that the game has initialized instead of making your own
|
||||
( ( IXAudio2* )soundSystemLocal.GetIXAudio2() )->CreateSourceVoice( &pMusicSourceVoice1, ( WAVEFORMATEX* )&exvoice, XAUDIO2_VOICE_USEFILTER ); // Use the XAudio2 that the game has initialized instead of making our own
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
class CinematicAudio_XAudio2: public CinematicAudio
|
||||
{
|
||||
public:
|
||||
CinematicAudio_XAudio2():
|
||||
pMusicSourceVoice1( NULL )
|
||||
{
|
||||
}
|
||||
CinematicAudio_XAudio2();
|
||||
void InitAudio( void* audioContext );
|
||||
void PlayAudio( uint8_t* data, int size );
|
||||
void ShutdownAudio();
|
||||
|
|
|
@ -434,7 +434,7 @@ void idSoundHardware_XAudio2::Init()
|
|||
pMasterVoice->GetChannelMask( &win8_channelMask );
|
||||
|
||||
channelMask = ( unsigned int )win8_channelMask;
|
||||
idLib::Printf( "Using device %S\n", selectedDevice.name );
|
||||
idLib::Printf( "Using device: %S\n", selectedDevice.name.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue