mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-01 19:00:34 +02:00
add libvorbis for 3DS to save 2 ms per block (8 -> 6 ms for 2352 stereo samples)
This commit is contained in:
@@ -104,6 +104,11 @@
|
|||||||
#undef OS_PTHREAD_MT
|
#undef OS_PTHREAD_MT
|
||||||
#undef USE_CUBEMAP_MIPS
|
#undef USE_CUBEMAP_MIPS
|
||||||
#define USE_ATLAS_RGBA16
|
#define USE_ATLAS_RGBA16
|
||||||
|
|
||||||
|
// for 2352 stereo samples
|
||||||
|
// stb_vorbis - 8 ms
|
||||||
|
// libvorbis - 6 ms
|
||||||
|
#define USE_LIBVORBIS
|
||||||
#elif _PSP
|
#elif _PSP
|
||||||
#define _OS_PSP 1
|
#define _OS_PSP 1
|
||||||
#define _GAPI_GU 1
|
#define _GAPI_GU 1
|
||||||
|
@@ -59,13 +59,13 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
LIBS := -lcitro3d -lctru -lm
|
LIBS := -lcitro3d -lctru -lm -lvorbisidec -logg
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
# include and lib
|
# include and lib
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBDIRS := $(CTRULIB)
|
LIBDIRS := $(CTRULIB) $(PORTLIBS)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
65
src/sound.h
65
src/sound.h
@@ -19,8 +19,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DECODE_OGG
|
#ifdef DECODE_OGG
|
||||||
#define STB_VORBIS_HEADER_ONLY
|
#ifdef USE_LIBVORBIS
|
||||||
#include "libs/stb_vorbis/stb_vorbis.c"
|
#include <tremor/ivorbisfile.h>
|
||||||
|
#include <tremor/ivorbiscodec.h>
|
||||||
|
#else
|
||||||
|
#define STB_VORBIS_HEADER_ONLY
|
||||||
|
#include "libs/stb_vorbis/stb_vorbis.c"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SND_CHANNELS_MAX 128
|
#define SND_CHANNELS_MAX 128
|
||||||
@@ -699,13 +704,60 @@ namespace Sound {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DECODE_OGG
|
#ifdef DECODE_OGG
|
||||||
|
|
||||||
|
#ifdef USE_LIBVORBIS
|
||||||
|
struct OGG : Decoder {
|
||||||
|
OggVorbis_File vf;
|
||||||
|
FILE *memFile;
|
||||||
|
uint8 *data;
|
||||||
|
|
||||||
|
OGG(Stream *stream, int channels) : Decoder(stream, channels, 0) {
|
||||||
|
char buf[255];
|
||||||
|
strcpy(buf, contentDir);
|
||||||
|
strcat(buf, stream->name);
|
||||||
|
|
||||||
|
data = new uint8[stream->size];
|
||||||
|
stream->raw(data, stream->size);
|
||||||
|
|
||||||
|
memFile = fmemopen(data, stream->size, "rb");
|
||||||
|
int err = ov_open(memFile, &vf, NULL, 0);
|
||||||
|
ASSERT(err >= 0);
|
||||||
|
vorbis_info *info = ov_info(&vf, -1);
|
||||||
|
this->channels = info->channels;
|
||||||
|
this->freq = info->rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~OGG() {
|
||||||
|
ov_clear(&vf);
|
||||||
|
fclose(memFile);
|
||||||
|
delete[] data;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int decode(Frame *frames, int count) {
|
||||||
|
PROFILE_CPU_TIMING(stats.ogg);
|
||||||
|
int i = 0;
|
||||||
|
int bytes = count * sizeof(Frame);
|
||||||
|
while (i < bytes) {
|
||||||
|
int bitstream;
|
||||||
|
int res = ov_read(&vf, (char*)frames + i, bytes - i, &bitstream);
|
||||||
|
if (!res) break;
|
||||||
|
i += res;
|
||||||
|
}
|
||||||
|
return i / sizeof(Frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void replay() {
|
||||||
|
fseek(memFile, 0, SEEK_SET);
|
||||||
|
ov_open(memFile, &vf, NULL, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#else // stb_vorbis
|
||||||
struct OGG : Decoder {
|
struct OGG : Decoder {
|
||||||
stb_vorbis *ogg;
|
stb_vorbis *ogg;
|
||||||
stb_vorbis_alloc alloc;
|
stb_vorbis_alloc alloc;
|
||||||
|
uint8 *data;
|
||||||
|
|
||||||
uint8 *data;
|
OGG(Stream *stream, int channels) : Decoder(stream, channels, 0) {
|
||||||
|
|
||||||
OGG(Stream *stream, int channels) : Decoder(stream, channels, 0), ogg(NULL) {
|
|
||||||
char buf[255];
|
char buf[255];
|
||||||
strcpy(buf, contentDir);
|
strcpy(buf, contentDir);
|
||||||
strcat(buf, stream->name);
|
strcat(buf, stream->name);
|
||||||
@@ -744,6 +796,9 @@ namespace Sound {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // DECODE_OGG
|
||||||
|
|
||||||
Core::Mutex lock;
|
Core::Mutex lock;
|
||||||
|
|
||||||
struct Listener {
|
struct Listener {
|
||||||
|
Reference in New Issue
Block a user