mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-28 03:54:15 +01:00
wiiu: use dr_wav instead of sndfile
- seems to be a bit faster - libsndfile no longer needed
This commit is contained in:
parent
91893ff104
commit
7842ff0781
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,3 +4,6 @@
|
||||
[submodule "vendor/openal-soft"]
|
||||
path = vendor/openal-soft
|
||||
url = https://github.com/GaryOderNichts/openal-soft
|
||||
[submodule "vendor/dr_libs"]
|
||||
path = vendor/dr_libs
|
||||
url = https://github.com/mackron/dr_libs.git
|
||||
|
5
Makefile
5
Makefile
@ -48,7 +48,8 @@ DATA := data
|
||||
INCLUDES := $(SOURCES) \
|
||||
vendor/librw \
|
||||
vendor/librw/inc \
|
||||
vendor/openal-soft/include
|
||||
vendor/openal-soft/include \
|
||||
vendor/dr_libs
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
@ -64,7 +65,7 @@ CXXFLAGS := $(CFLAGS)
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lrw -lmpg123 -lopenal -lSDL2 -lsndfile -lwut
|
||||
LIBS := -lrw -lmpg123 -lopenal -lSDL2 -lwut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level
|
||||
|
@ -11,7 +11,12 @@
|
||||
#pragma comment( lib, "libsndfile-1.lib" )
|
||||
#pragma comment( lib, "libmpg123-0.lib" )
|
||||
#endif
|
||||
#ifndef __WIIU__
|
||||
#include <sndfile.h>
|
||||
#else
|
||||
#define DR_WAV_IMPLEMENTATION
|
||||
#include "dr_wav.h"
|
||||
#endif
|
||||
#include <mpg123.h>
|
||||
#endif
|
||||
|
||||
@ -20,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_OPUS
|
||||
#ifndef __WIIU__
|
||||
class CSndFile : public IDecoder
|
||||
{
|
||||
SNDFILE *m_pfSound;
|
||||
@ -84,6 +90,90 @@ public:
|
||||
return sf_read_short(m_pfSound, (short *)buffer, GetBufferSamples()) * GetSampleSize();
|
||||
}
|
||||
};
|
||||
#else
|
||||
class CDrWav : public IDecoder
|
||||
{
|
||||
drwav m_drWav;
|
||||
bool m_bIsLoaded;
|
||||
public:
|
||||
CDrWav(const char *path) :
|
||||
m_bIsLoaded(false)
|
||||
{
|
||||
memset(&m_drWav, 0, sizeof(m_drWav));
|
||||
if( !drwav_init_file(&m_drWav, path, NULL) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_bIsLoaded = true;
|
||||
}
|
||||
|
||||
~CDrWav()
|
||||
{
|
||||
if ( m_bIsLoaded )
|
||||
{
|
||||
drwav_uninit(&m_drWav);
|
||||
m_bIsLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsOpened()
|
||||
{
|
||||
return m_bIsLoaded;
|
||||
}
|
||||
|
||||
uint32 GetSampleSize()
|
||||
{
|
||||
return drwav_get_bytes_per_pcm_frame(&m_drWav);
|
||||
}
|
||||
|
||||
uint32 GetSampleCount()
|
||||
{
|
||||
return m_drWav.totalPCMFrameCount;
|
||||
}
|
||||
|
||||
uint32 GetSampleRate()
|
||||
{
|
||||
return m_drWav.sampleRate;
|
||||
}
|
||||
|
||||
uint32 GetChannels()
|
||||
{
|
||||
return m_drWav.channels;
|
||||
}
|
||||
|
||||
void Seek(uint32 milliseconds)
|
||||
{
|
||||
if ( !IsOpened() ) return;
|
||||
drwav_seek_to_pcm_frame(&m_drWav, ms2samples(milliseconds));
|
||||
}
|
||||
|
||||
uint32 Tell()
|
||||
{
|
||||
if ( !IsOpened() ) return 0;
|
||||
|
||||
if (drwav__is_compressed_format_tag(m_drWav.translatedFormatTag)) {
|
||||
return samples2ms(m_drWav.compressed.iCurrentPCMFrame);
|
||||
} else {
|
||||
uint32 bytes_per_frame = GetSampleSize();
|
||||
return samples2ms(
|
||||
((m_drWav.totalPCMFrameCount * bytes_per_frame) - m_drWav.bytesRemaining) / bytes_per_frame
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 Decode(void *buffer)
|
||||
{
|
||||
if ( !IsOpened() ) return 0;
|
||||
size_t read = drwav_read_raw(&m_drWav, GetBufferSize(), buffer);
|
||||
#ifdef BIGENDIAN
|
||||
for (int i = 0; i < GetBufferSize() / sizeof(uint16); i++) {
|
||||
((uint16*)buffer)[i] = BSWAP16(((uint16*)buffer)[i]);
|
||||
}
|
||||
#endif
|
||||
return read;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
class CMP3File : public IDecoder
|
||||
{
|
||||
@ -318,7 +408,11 @@ CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUF
|
||||
if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3"))
|
||||
m_pSoundFile = new CMP3File(m_aFilename);
|
||||
else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav"))
|
||||
#ifndef __WIIU__
|
||||
m_pSoundFile = new CSndFile(m_aFilename);
|
||||
#else
|
||||
m_pSoundFile = new CDrWav(m_aFilename);
|
||||
#endif
|
||||
#else
|
||||
if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".opus")], ".opus"))
|
||||
m_pSoundFile = new COpusFile(m_aFilename);
|
||||
|
1
vendor/dr_libs
vendored
Submodule
1
vendor/dr_libs
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 00370db889a8b7d46e4db51b5b4073428fd42ee8
|
Loading…
Reference in New Issue
Block a user