mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-26 11:11:48 +01:00
[Core/MCD] added support for external VORBIS library
This commit is contained in:
parent
ea1924d747
commit
d57d03e222
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* CD drive processor & CD-DA fader
|
* CD drive processor & CD-DA fader
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2014 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -37,7 +37,7 @@
|
|||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#define SUPPORTED_EXT 20
|
#define SUPPORTED_EXT 20
|
||||||
#else
|
#else
|
||||||
#define SUPPORTED_EXT 10
|
#define SUPPORTED_EXT 10
|
||||||
@ -126,7 +126,7 @@ static const unsigned char waveHeader[32] =
|
|||||||
/* supported WAVE file extensions */
|
/* supported WAVE file extensions */
|
||||||
static const char extensions[SUPPORTED_EXT][16] =
|
static const char extensions[SUPPORTED_EXT][16] =
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
"%02d.ogg",
|
"%02d.ogg",
|
||||||
" %02d.ogg",
|
" %02d.ogg",
|
||||||
"-%02d.ogg",
|
"-%02d.ogg",
|
||||||
@ -150,7 +150,7 @@ static const char extensions[SUPPORTED_EXT][16] =
|
|||||||
" - %d.wav"
|
" - %d.wav"
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
static void ogg_free(int i)
|
static void ogg_free(int i)
|
||||||
{
|
{
|
||||||
@ -221,7 +221,7 @@ int cdd_context_load(uint8 *state)
|
|||||||
int lba;
|
int lba;
|
||||||
int bufferptr = 0;
|
int bufferptr = 0;
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* close previous track VORBIS file structure to save memory */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
@ -255,7 +255,7 @@ int cdd_context_load(uint8 *state)
|
|||||||
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
@ -479,7 +479,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
/* adjust current track file read offset with WAVE header length */
|
/* adjust current track file read offset with WAVE header length */
|
||||||
cdd.toc.tracks[cdd.toc.last].offset -= 44;
|
cdd.toc.tracks[cdd.toc.last].offset -= 44;
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (!ov_open(cdd.toc.tracks[cdd.toc.last].fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
else if (!ov_open(cdd.toc.tracks[cdd.toc.last].fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
||||||
{
|
{
|
||||||
/* retrieve stream infos */
|
/* retrieve stream infos */
|
||||||
@ -576,7 +576,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
/* adjust file read offset with previous track end time */
|
/* adjust file read offset with previous track end time */
|
||||||
cdd.toc.tracks[cdd.toc.last].offset += cdd.toc.end * 2352;
|
cdd.toc.tracks[cdd.toc.last].offset += cdd.toc.end * 2352;
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
if (cdd.toc.tracks[cdd.toc.last].vf.datasource)
|
if (cdd.toc.tracks[cdd.toc.last].vf.datasource)
|
||||||
{
|
{
|
||||||
/* convert read offset to PCM sample offset */
|
/* convert read offset to PCM sample offset */
|
||||||
@ -709,7 +709,7 @@ int cdd_load(char *filename, char *header)
|
|||||||
/* increment track number */
|
/* increment track number */
|
||||||
cdd.toc.last++;
|
cdd.toc.last++;
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (!ov_open(fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
else if (!ov_open(fd,&cdd.toc.tracks[cdd.toc.last].vf,0,0))
|
||||||
{
|
{
|
||||||
/* retrieve stream infos */
|
/* retrieve stream infos */
|
||||||
@ -744,7 +744,11 @@ int cdd_load(char *filename, char *header)
|
|||||||
|
|
||||||
/* auto-detect PAUSE within audio files */
|
/* auto-detect PAUSE within audio files */
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.toc.last].vf, 100 * 588);
|
ov_pcm_seek(&cdd.toc.tracks[cdd.toc.last].vf, 100 * 588);
|
||||||
|
#if defined(USE_LIBVORBIS)
|
||||||
|
ov_read(&cdd.toc.tracks[cdd.toc.last].vf, (char *)head, 32, 0, 2, 1, 0);
|
||||||
|
#else
|
||||||
ov_read(&cdd.toc.tracks[cdd.toc.last].vf, (char *)head, 32, 0);
|
ov_read(&cdd.toc.tracks[cdd.toc.last].vf, (char *)head, 32, 0);
|
||||||
|
#endif
|
||||||
ov_pcm_seek(&cdd.toc.tracks[cdd.toc.last].vf, 0);
|
ov_pcm_seek(&cdd.toc.tracks[cdd.toc.last].vf, 0);
|
||||||
if (*(int32 *)head == 0)
|
if (*(int32 *)head == 0)
|
||||||
{
|
{
|
||||||
@ -891,7 +895,7 @@ void cdd_unload(void)
|
|||||||
/* close CD tracks */
|
/* close CD tracks */
|
||||||
for (i=0; i<cdd.toc.last; i++)
|
for (i=0; i<cdd.toc.last; i++)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
if (cdd.toc.tracks[i].vf.datasource)
|
if (cdd.toc.tracks[i].vf.datasource)
|
||||||
{
|
{
|
||||||
/* close VORBIS file (if still opened) */
|
/* close VORBIS file (if still opened) */
|
||||||
@ -962,7 +966,7 @@ void cdd_read_audio(unsigned int samples)
|
|||||||
int endVol = scd.regs[0x34>>1].w >> 4;
|
int endVol = scd.regs[0x34>>1].w >> 4;
|
||||||
|
|
||||||
/* read samples from current block */
|
/* read samples from current block */
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
{
|
{
|
||||||
int len, done = 0;
|
int len, done = 0;
|
||||||
@ -970,7 +974,11 @@ void cdd_read_audio(unsigned int samples)
|
|||||||
samples = samples * 4;
|
samples = samples * 4;
|
||||||
while (done < samples)
|
while (done < samples)
|
||||||
{
|
{
|
||||||
|
#ifdef USE_LIBVORBIS
|
||||||
|
len = ov_read(&cdd.toc.tracks[cdd.index].vf, (char *)(cdc.ram + done), samples - done, 0, 2, 1, 0);
|
||||||
|
#else
|
||||||
len = ov_read(&cdd.toc.tracks[cdd.index].vf, (char *)(cdc.ram + done), samples - done, 0);
|
len = ov_read(&cdd.toc.tracks[cdd.index].vf, (char *)(cdc.ram + done), samples - done, 0);
|
||||||
|
#endif
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
{
|
{
|
||||||
done = samples;
|
done = samples;
|
||||||
@ -1168,7 +1176,7 @@ void cdd_update(void)
|
|||||||
/* check end of current track */
|
/* check end of current track */
|
||||||
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* close previous track VORBIS file structure to save memory */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
@ -1184,7 +1192,7 @@ void cdd_update(void)
|
|||||||
scd.regs[0x36>>1].byte.h = 0x01;
|
scd.regs[0x36>>1].byte.h = 0x01;
|
||||||
|
|
||||||
/* seek to next audio track start */
|
/* seek to next audio track start */
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
if (cdd.toc.tracks[cdd.index].vf.seekable)
|
if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
@ -1211,7 +1219,7 @@ void cdd_update(void)
|
|||||||
/* check current track limits */
|
/* check current track limits */
|
||||||
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
if (cdd.lba >= cdd.toc.tracks[cdd.index].end)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* close previous track VORBIS file structure to save memory */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
@ -1234,7 +1242,7 @@ void cdd_update(void)
|
|||||||
}
|
}
|
||||||
else if (cdd.lba < cdd.toc.tracks[cdd.index].start)
|
else if (cdd.lba < cdd.toc.tracks[cdd.index].start)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* close previous track VORBIS file structure to save memory */
|
/* close previous track VORBIS file structure to save memory */
|
||||||
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
if (cdd.toc.tracks[cdd.index].vf.datasource)
|
||||||
@ -1278,7 +1286,7 @@ void cdd_update(void)
|
|||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
fseek(cdd.toc.tracks[0].fd, cdd.lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
else if (cdd.toc.tracks[cdd.index].vf.seekable)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
@ -1470,7 +1478,7 @@ void cdd_process(void)
|
|||||||
/* get track index */
|
/* get track index */
|
||||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* check if track index has changed */
|
/* check if track index has changed */
|
||||||
if (index != cdd.index)
|
if (index != cdd.index)
|
||||||
@ -1505,7 +1513,7 @@ void cdd_process(void)
|
|||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
{
|
{
|
||||||
/* VORBIS AUDIO track */
|
/* VORBIS AUDIO track */
|
||||||
@ -1562,7 +1570,7 @@ void cdd_process(void)
|
|||||||
/* get current track index */
|
/* get current track index */
|
||||||
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
while ((cdd.toc.tracks[index].end <= lba) && (index < cdd.toc.last)) index++;
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
#ifdef DISABLE_MANY_OGG_OPEN_FILES
|
||||||
/* check if track index has changed */
|
/* check if track index has changed */
|
||||||
if (index != cdd.index)
|
if (index != cdd.index)
|
||||||
@ -1597,7 +1605,7 @@ void cdd_process(void)
|
|||||||
/* DATA track */
|
/* DATA track */
|
||||||
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
fseek(cdd.toc.tracks[0].fd, lba * cdd.sectorSize, SEEK_SET);
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
else if (cdd.toc.tracks[index].vf.seekable)
|
else if (cdd.toc.tracks[index].vf.seekable)
|
||||||
{
|
{
|
||||||
/* VORBIS AUDIO track */
|
/* VORBIS AUDIO track */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Genesis Plus
|
* Genesis Plus
|
||||||
* CD drive processor & CD-DA fader
|
* CD drive processor & CD-DA fader
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2014 Eke-Eke (Genesis Plus GX)
|
* Copyright (C) 2012-2015 Eke-Eke (Genesis Plus GX)
|
||||||
*
|
*
|
||||||
* Redistribution and use of this code or any derivative works are permitted
|
* Redistribution and use of this code or any derivative works are permitted
|
||||||
* provided that the following conditions are met:
|
* provided that the following conditions are met:
|
||||||
@ -40,7 +40,9 @@
|
|||||||
|
|
||||||
#include "blip_buf.h"
|
#include "blip_buf.h"
|
||||||
|
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBVORBIS)
|
||||||
|
#include <vorbis/vorbisfile.h>
|
||||||
|
#elif defined(USE_LIBTREMOR)
|
||||||
#include "tremor/ivorbisfile.h"
|
#include "tremor/ivorbisfile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -65,7 +67,7 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
#ifdef USE_LIBTREMOR
|
#if defined(USE_LIBTREMOR) || defined(USE_LIBVORBIS)
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
#endif
|
#endif
|
||||||
int offset;
|
int offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user