Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'master' of https://github.com/GTAmodding/re3 into erorcun
  • Loading branch information
erorcun committed Jul 29, 2020
2 parents 2c6f2f2 + 8ceeb10 commit 0009558fcb0833ccdf2dcaec9d83b0413125fa5f
@@ -1,3 +1,15 @@
[submodule "librw"] [submodule "librw"]
path = librw path = librw
url = https://github.com/aap/librw url = https://github.com/aap/librw
[submodule "opus"]
path = opus
url = https://github.com/xiph/opus.git
branch = master
[submodule "opusfile"]
path = opusfile
url = https://github.com/xiph/opusfile.git
branch = master
[submodule "ogg"]
path = ogg
url = https://github.com/xiph/ogg.git
branch = master
@@ -31,7 +31,7 @@ such that we have a working game at all times.
- **If you use 64-bit D3D9**: We don't ship 64-bit Dx9 SDK. You need to download it from Microsoft if you don't have it(although it should come pre-installed after some Windows version) - **If you use 64-bit D3D9**: We don't ship 64-bit Dx9 SDK. You need to download it from Microsoft if you don't have it(although it should come pre-installed after some Windows version)




> :information_source: **If you choose OpenAL(OAL) on Windows** You must read [Running OAL build on Windows](https://github.com/GTAmodding/re3/wiki/Running-OAL-build-on-Windows). > :information_source: **If you choose OpenAL on Windows** You must read [Running OpenAL build on Windows](https://github.com/GTAmodding/re3/wiki/Running-OpenAL-build-on-Windows).
> :information_source: **Did you notice librw?** re3 uses completely homebrew RenderWare-replacement rendering engine; [librw](https://github.com/aap/librw/). librw comes as submodule of re3, but you also can use LIBRW enviorenment variable to specify path to your own librw. > :information_source: **Did you notice librw?** re3 uses completely homebrew RenderWare-replacement rendering engine; [librw](https://github.com/aap/librw/). librw comes as submodule of re3, but you also can use LIBRW enviorenment variable to specify path to your own librw.
1 ogg
Submodule ogg added at 1e8d7c
1 opus
Submodule opus added at 8aa776
Submodule opusfile added at eb2525
@@ -24,6 +24,11 @@ newoption {
description = "Build and use librw from this solution" description = "Build and use librw from this solution"
} }


newoption {
trigger = "with-opus",
description = "Build with opus"
}

if(_OPTIONS["with-librw"]) then if(_OPTIONS["with-librw"]) then
Librw = "librw" Librw = "librw"
else else
@@ -200,10 +205,25 @@ project "re3"
includedirs { "src/extras" } includedirs { "src/extras" }
includedirs { "eax" } includedirs { "eax" }


if _OPTIONS["with-opus"] then
includedirs { "ogg/include" }
includedirs { "opus/include" }
includedirs { "opusfile/include" }
end

filter "platforms:*mss" filter "platforms:*mss"
defines { "AUDIO_MSS" } defines { "AUDIO_MSS" }
includedirs { "milessdk/include" } includedirs { "milessdk/include" }
libdirs { "milessdk/lib" } libdirs { "milessdk/lib" }

if _OPTIONS["with-opus"] then
filter "platforms:win*"
libdirs { "ogg/win32/VS2015/Win32/%{cfg.buildcfg}" }
libdirs { "opus/win32/VS2015/Win32/%{cfg.buildcfg}" }
libdirs { "opusfile/win32/VS2015/Win32/Release-NoHTTP" }
filter {}
defines { "AUDIO_OPUS" }
end


filter "platforms:*oal" filter "platforms:*oal"
defines { "AUDIO_OAL" } defines { "AUDIO_OAL" }
@@ -238,6 +258,13 @@ project "re3"


filter "platforms:linux*oal" filter "platforms:linux*oal"
links { "openal", "mpg123", "sndfile", "pthread" } links { "openal", "mpg123", "sndfile", "pthread" }

if _OPTIONS["with-opus"] then
filter {}
links { "libogg" }
links { "opus" }
links { "opusfile" }
end


filter "platforms:*RW33*" filter "platforms:*RW33*"
staticruntime "on" staticruntime "on"
@@ -4,6 +4,9 @@
#include "stream.h" #include "stream.h"
#include "sampman.h" #include "sampman.h"


#ifdef AUDIO_OPUS
#include <opusfile.h>
#else
#ifdef _WIN32 #ifdef _WIN32


// TODO: This is due to version difference of 32-bit libmpg123 and 64-bit libmpg123, fix it // TODO: This is due to version difference of 32-bit libmpg123 and 64-bit libmpg123, fix it
@@ -17,7 +20,9 @@ typedef long ssize_t;
#endif #endif
#include <sndfile.h> #include <sndfile.h>
#include <mpg123.h> #include <mpg123.h>
#endif


#ifndef AUDIO_OPUS
class CSndFile : public IDecoder class CSndFile : public IDecoder
{ {
SNDFILE *m_pfSound; SNDFILE *m_pfSound;
@@ -177,15 +182,111 @@ class CMP3File : public IDecoder
return (uint32)size; return (uint32)size;
} }
}; };
#else
class COpusFile : public IDecoder
{
OggOpusFile *m_FileH;
bool m_bOpened;
uint32 m_nRate;
uint32 m_nChannels;
public:
COpusFile(const char *path) : m_FileH(nil),
m_bOpened(false),
m_nRate(0),
m_nChannels(0)
{
int ret;
m_FileH = op_open_file(path, &ret);

if (m_FileH) {
m_nChannels = op_head(m_FileH, 0)->channel_count;
m_nRate = op_head(m_FileH, 0)->input_sample_rate;
const OpusTags *tags = op_tags(m_FileH, 0);
for (int i = 0; i < tags->comments; i++) {
if (strncmp(tags->user_comments[i], "SAMPLERATE", sizeof("SAMPLERATE")-1) == 0)
{
sscanf(tags->user_comments[i], "SAMPLERATE=%i", &m_nRate);
break;
}
}

m_bOpened = true;
}
}

~COpusFile()
{
if (m_FileH)
{
op_free(m_FileH);
m_FileH = nil;
}
}

bool IsOpened()
{
return m_bOpened;
}

uint32 GetSampleSize()
{
return sizeof(uint16);
}

uint32 GetSampleCount()
{
if ( !IsOpened() ) return 0;
return op_pcm_total(m_FileH, 0);
}

uint32 GetSampleRate()
{
return m_nRate;
}

uint32 GetChannels()
{
return m_nChannels;
}

void Seek(uint32 milliseconds)
{
if ( !IsOpened() ) return;
op_pcm_seek(m_FileH, ms2samples(milliseconds) * GetSampleSize());
}

uint32 Tell()
{
if ( !IsOpened() ) return 0;
return samples2ms(op_pcm_tell(m_FileH)/GetSampleSize());
}

uint32 Decode(void *buffer)
{
if ( !IsOpened() ) return 0;

int size = op_read(m_FileH, (opus_int16 *)buffer, GetBufferSamples(), NULL);

if (size < 0)
return 0;

return size * m_nChannels * GetSampleSize();
}
};
#endif


void CStream::Initialise() void CStream::Initialise()
{ {
#ifndef AUDIO_OPUS
mpg123_init(); mpg123_init();
#endif
} }


void CStream::Terminate() void CStream::Terminate()
{ {
#ifndef AUDIO_OPUS
mpg123_exit(); mpg123_exit();
#endif
} }


CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) : CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) :
@@ -216,10 +317,15 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF


DEV("Stream %s\n", m_aFilename); DEV("Stream %s\n", m_aFilename);


#ifndef AUDIO_OPUS
if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3"))
m_pSoundFile = new CMP3File(m_aFilename); m_pSoundFile = new CMP3File(m_aFilename);
else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav"))
m_pSoundFile = new CSndFile(m_aFilename); m_pSoundFile = new CSndFile(m_aFilename);
#else
if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus"))
m_pSoundFile = new COpusFile(m_aFilename);
#endif
else else
m_pSoundFile = nil; m_pSoundFile = nil;
ASSERT(m_pSoundFile != nil); ASSERT(m_pSoundFile != nil);
@@ -218,6 +218,42 @@ class cSampleManager
extern cSampleManager SampleManager; extern cSampleManager SampleManager;
extern uint32 BankStartOffset[MAX_SAMPLEBANKS]; extern uint32 BankStartOffset[MAX_SAMPLEBANKS];


#ifdef AUDIO_OPUS
static char StreamedNameTable[][25] = {
"AUDIO\\HEAD.OPUS", "AUDIO\\CLASS.OPUS", "AUDIO\\KJAH.OPUS", "AUDIO\\RISE.OPUS", "AUDIO\\LIPS.OPUS", "AUDIO\\GAME.OPUS",
"AUDIO\\MSX.OPUS", "AUDIO\\FLASH.OPUS", "AUDIO\\CHAT.OPUS", "AUDIO\\HEAD.OPUS", "AUDIO\\POLICE.OPUS", "AUDIO\\CITY.OPUS",
"AUDIO\\WATER.OPUS", "AUDIO\\COMOPEN.OPUS", "AUDIO\\SUBOPEN.OPUS", "AUDIO\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S", "AUDIO\\D4_GTA.OPUS", "AUDIO\\D4_GTA2.OPUS", "AUDIO\\D6_STS.OPUS", "AUDIO\\A6_BAIT.OPUS", "AUDIO\\A7_ETG.OPUS",
"AUDIO\\A8_PS.OPUS", "AUDIO\\A9_ASD.OPUS", "AUDIO\\K4_SHI2.OPUS", "AUDIO\\C1_TEX.OPUS", "AUDIO\\EL_PH1.OPUS", "AUDIO\\EL_PH2.OPUS",
"AUDIO\\EL_PH3.OPUS", "AUDIO\\EL_PH4.OPUS", "AUDIO\\YD_PH1.OPUS", "AUDIO\\YD_PH2.OPUS", "AUDIO\\YD_PH3.OPUS", "AUDIO\\YD_PH4.OPUS",
"AUDIO\\HD_PH1.OPUS", "AUDIO\\HD_PH2.OPUS", "AUDIO\\HD_PH3.OPUS", "AUDIO\\HD_PH4.OPUS", "AUDIO\\HD_PH5.OPUS", "AUDIO\\MT_PH1.OPUS",
"AUDIO\\MT_PH2.OPUS", "AUDIO\\MT_PH3.OPUS", "AUDIO\\MT_PH4.OPUS", "AUDIO\\MISCOM.OPUS", "AUDIO\\END.OPUS", "AUDIO\\lib_a1.OPUS",
"AUDIO\\lib_a2.OPUS", "AUDIO\\lib_a.OPUS", "AUDIO\\lib_b.OPUS", "AUDIO\\lib_c.OPUS", "AUDIO\\lib_d.OPUS", "AUDIO\\l2_a.OPUS",
"AUDIO\\j4t_1.OPUS", "AUDIO\\j4t_2.OPUS", "AUDIO\\j4t_3.OPUS", "AUDIO\\j4t_4.OPUS", "AUDIO\\j4_a.OPUS", "AUDIO\\j4_b.OPUS",
"AUDIO\\j4_c.OPUS", "AUDIO\\j4_d.OPUS", "AUDIO\\j4_e.OPUS", "AUDIO\\j4_f.OPUS", "AUDIO\\j6_1.OPUS", "AUDIO\\j6_a.OPUS",
"AUDIO\\j6_b.OPUS", "AUDIO\\j6_c.OPUS", "AUDIO\\j6_d.OPUS", "AUDIO\\t4_a.OPUS", "AUDIO\\s1_a.OPUS", "AUDIO\\s1_a1.OPUS",
"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IO\\yd2_g.OPUS", "AUDIO\\yd2_h.OPUS", "AUDIO\\yd2_ass.OPUS", "AUDIO\\yd2_ok.OPUS", "AUDIO\\h5_a.OPUS",
"AUDIO\\h5_b.OPUS", "AUDIO\\h5_c.OPUS", "AUDIO\\ammu_a.OPUS", "AUDIO\\ammu_b.OPUS", "AUDIO\\ammu_c.OPUS", "AUDIO\\door_1.OPUS",
"AUDIO\\door_2.OPUS", "AUDIO\\door_3.OPUS", "AUDIO\\door_4.OPUS", "AUDIO\\door_5.OPUS", "AUDIO\\door_6.OPUS", "AUDIO\\t3_a.OPUS",
"AUDIO\\t3_b.OPUS", "AUDIO\\t3_c.OPUS", "AUDIO\\k1_b.OPUS", "AUDIO\\cat1.OPUS"};
#else
static char StreamedNameTable[][25]= static char StreamedNameTable[][25]=
{ {
#ifdef PS2_AUDIO #ifdef PS2_AUDIO
@@ -515,3 +551,4 @@ static char StreamedNameTable[][25]=
"AUDIO\\k1_b.WAV", "AUDIO\\k1_b.WAV",
"AUDIO\\cat1.WAV" "AUDIO\\cat1.WAV"
}; };
#endif

0 comments on commit 0009558

Please sign in to comment.