*[libwiigui] Minor adjustment of the ogg sound decoder to be capable of reading files into memory on its own.

*Replaced libtremor with libvorbisidec
This commit is contained in:
eraserxl 2010-09-15 00:51:15 +00:00
parent 3f61761739
commit fa6bbdf47d
3 changed files with 213 additions and 4 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>1.0 r938</version> <version>1.0 r939</version>
<release_date>201007040019</release_date> <release_date>201009110014</release_date>
<short_description>Loads games from USB-devices</short_description> <short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. <long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -64,7 +64,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80B00
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lpngu -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -ltremor -lmad -lmxml -ljpeg LIBS := -lpngu -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -lvorbisidec -lmad -lmxml -ljpeg
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# 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

View File

@ -16,9 +16,218 @@
#include <asndlib.h> #include <asndlib.h>
#include <tremor/ivorbiscodec.h> #include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h> #include <tremor/ivorbisfile.h>
#include <string.h>
#include "gui_sound_decoder.h" #include "gui_sound_decoder.h"
/* functions to read the Ogg file from memory */
static struct
{
char *mem;
int size;
int pos;
} file[4];
static int f_read(void * punt, int bytes, int blocks, int *f)
{
int b;
int c = 0;
int d;
if (bytes * blocks <= 0)
return 0;
blocks *= bytes;
while (blocks > 0)
{
b = blocks;
if (b > 4096)
b = 4096;
d = (*f) - 0x666;
if((unsigned)(d) <= (0x669 - 0x666))
{
if (file[d].size == 0)
return -1;
if ((file[d].pos + b) > file[d].size)
b = file[d].size - file[d].pos;
if (b > 0)
{
memcpy(punt, file[d].mem + file[d].pos, b);
file[d].pos += b;
}
}
else
b = read(*f, ((char *) punt) + c, b);
if (b <= 0)
{
return c / bytes;
}
c += b;
blocks -= b;
}
return c / bytes;
}
static int f_seek(int *f, ogg_int64_t offset, int mode)
{
if(f==NULL) return(-1);
int k;
mode &= 3;
int d = (*f) - 0x666;
if((unsigned)(d) <= (0x669 - 0x666))
{
k = 0;
if (file[d].size == 0)
return -1;
if (mode == 0)
{
if ((offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos = offset;
}
else if (mode == 1)
{
if ((file[d].pos + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].pos + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos += offset;
}
else if (mode == 2)
{
if ((file[d].size + offset) >= file[d].size)
{
file[d].pos = file[d].size;
k = -1;
}
else if ((file[d].size + offset) < 0)
{
file[d].pos = 0;
k = -1;
}
else
file[d].pos = file[d].size + offset;
}
}
else
k = lseek(*f, (int) offset, mode);
if (k < 0)
k = -1;
else
k = 0;
return k;
}
static int f_close(int *f)
{
int d = (*f) - 0x666;
if((unsigned)(d) <= (0x669 - 0x666))
{
file[d].size = 0;
file[d].pos = 0;
if (file[d].mem)
{
file[d].mem = (char *) 0;
}
return 0;
}
else
return close(*f);
return 0;
}
static long f_tell(int *f)
{
int k;
int d = (*f) - 0x666;
if((unsigned)(d) <= (0x669 - 0x666))
{
k = file[d].pos;
}
else
k = lseek(*f, 0, 1);
return (long) k;
}
static int mem_open(char * ogg, int size)
{
static int one = 1;
int n;
if (one)
{
one = 0;
file[0].size = 0;
file[1].size = 0;
file[2].size = 0;
file[3].size = 0;
file[0].mem = ogg;
file[0].size = size;
file[0].pos = 0;
return (0x666);
}
for (n = 0; n < 4; n++)
{
if (file[n].size == 0)
{
file[n].mem = ogg;
file[n].size = size;
file[n].pos = 0;
return (0x666 + n);
}
}
return -1;
}
static int mem_close(int fd)
{
if((unsigned)((fd) - 0x666) <= (0x669 - 0x666)) // it is a memory file descriptor?
{
fd -= 0x666;
file[fd].size = 0;
return 0;
}
else
return f_close(&fd);
}
static ov_callbacks callbacks = {
(size_t (*)(void *, size_t, size_t, void *)) f_read,
(int (*)(void *, ogg_int64_t, int)) f_seek,
(int (*)(void *)) f_close,
(long (*)(void *)) f_tell
};
class GuiSoundDecoderOGG : public GuiSoundDecoder class GuiSoundDecoderOGG : public GuiSoundDecoder
{ {
protected: protected:
@ -29,7 +238,7 @@ protected:
ogg_fd = mem_open((char *)snd, len); ogg_fd = mem_open((char *)snd, len);
if(ogg_fd < 0) throw("mem open failed"); if(ogg_fd < 0) throw("mem open failed");
if (ov_open((FILE*)&ogg_fd, &ogg_file, NULL, 0) < 0) if (ov_open_callbacks((void*)&ogg_fd, &ogg_file, NULL, 0, callbacks) < 0)
{ {
mem_close(ogg_fd); mem_close(ogg_fd);
throw("ogg open failed"); throw("ogg open failed");