2008-05-17 19:26:20 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
/* RAW
|
|
|
|
|
|
|
|
RAW format is native 44khz PCM file
|
|
|
|
Nothing more :P ...
|
|
|
|
|
|
|
|
2008-05-17 - Fastelbja : First version ...
|
|
|
|
*/
|
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_raw(STREAMFILE *streamFile) {
|
2008-05-17 19:26:20 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2013-05-27 05:55:50 +02:00
|
|
|
char filename[PATH_LIMIT];
|
2008-05-17 19:26:20 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2008-05-20 17:18:38 +02:00
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
2008-05-17 19:26:20 +02:00
|
|
|
if (strcasecmp("raw",filename_extension(filename))) goto fail;
|
|
|
|
|
|
|
|
/* No check to do as they are raw pcm */
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(2,0);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
vgmstream->channels = 2;
|
|
|
|
vgmstream->sample_rate = 44100;
|
|
|
|
vgmstream->coding_type = coding_PCM16LE;
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->num_samples = (int32_t)(get_streamfile_size(streamFile)/4);
|
2008-05-17 19:26:20 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 2;
|
|
|
|
vgmstream->meta_type = meta_RAW;
|
|
|
|
|
|
|
|
/* open the file for reading by each channel */
|
|
|
|
{
|
2008-05-20 22:19:46 +02:00
|
|
|
STREAMFILE *chstreamfile;
|
|
|
|
|
|
|
|
/* have both channels use the same buffer, as interleave is so small */
|
|
|
|
chstreamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
|
|
|
|
if (!chstreamfile) goto fail;
|
2008-05-17 19:26:20 +02:00
|
|
|
|
2008-05-20 22:19:46 +02:00
|
|
|
for (i=0;i<2;i++) {
|
|
|
|
vgmstream->ch[i].streamfile = chstreamfile;
|
2008-05-17 19:26:20 +02:00
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
2008-05-17 19:32:02 +02:00
|
|
|
vgmstream->ch[i].offset=(off_t)(i*vgmstream->interleave_block_size);
|
2008-05-17 19:26:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|