Fix file type error
Additionally changed compiler optimisation back to O3 and temporarily use only a single buffer with flac decoding. Signed-off-by: Mahyar Koshkouei <deltabeard@users.noreply.github.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -42,7 +42,7 @@ APP_AUTHOR = Deltabeard
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
|
||||
CFLAGS := -g -Wall -Os -mword-relocations \
|
||||
CFLAGS := -g -Wall -O3 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections \
|
||||
$(ARCH)
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ int playFlac(const char* in)
|
||||
waveBuf[0].nsamples = drflac_read_s16(pFlac, chunkSize, buffer1) / pFlac->channels;
|
||||
waveBuf[0].data_vaddr = &buffer1[0];
|
||||
ndspChnWaveBufAdd(CHANNEL, &waveBuf[0]);
|
||||
waveBuf[1].nsamples = drflac_read_s16(pFlac, chunkSize, buffer2) / pFlac->channels;
|
||||
waveBuf[1].data_vaddr = &buffer2[0];
|
||||
ndspChnWaveBufAdd(CHANNEL, &waveBuf[1]);
|
||||
//waveBuf[1].nsamples = drflac_read_s16(pFlac, chunkSize, buffer2) / pFlac->channels;
|
||||
//waveBuf[1].data_vaddr = &buffer2[0];
|
||||
//ndspChnWaveBufAdd(CHANNEL, &waveBuf[1]);
|
||||
|
||||
printf("Playing %s\n", in);
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ int playFlac(const char* in)
|
||||
while(ndspChnIsPlaying(CHANNEL) == false)
|
||||
{}
|
||||
|
||||
while(playing == false || ndspChnIsPlaying(CHANNEL) == true)
|
||||
while(true || playing == false || ndspChnIsPlaying(CHANNEL) == true)
|
||||
{
|
||||
u32 kDown;
|
||||
/* Number of bytes read from file.
|
||||
@@ -87,7 +87,9 @@ int playFlac(const char* in)
|
||||
|
||||
if(waveBuf[0].status == NDSP_WBUF_DONE)
|
||||
{
|
||||
printf("\rBeginning Decode.");
|
||||
read = drflac_read_s16(pFlac, chunkSize, buffer1);
|
||||
printf("\rDone decode.");
|
||||
|
||||
if(read == 0)
|
||||
{
|
||||
@@ -100,6 +102,7 @@ int playFlac(const char* in)
|
||||
ndspChnWaveBufAdd(CHANNEL, &waveBuf[0]);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if(waveBuf[1].status == NDSP_WBUF_DONE)
|
||||
{
|
||||
read = drflac_read_s16(pFlac, chunkSize, buffer2);
|
||||
@@ -114,15 +117,15 @@ int playFlac(const char* in)
|
||||
|
||||
ndspChnWaveBufAdd(CHANNEL, &waveBuf[1]);
|
||||
}
|
||||
|
||||
DSP_FlushDataCache(buffer1, chunkSize);
|
||||
DSP_FlushDataCache(buffer2, chunkSize);
|
||||
|
||||
// TODO: Remove this printf.
|
||||
// \33[2K clears the current line.
|
||||
printf("\33[2K\rRead: %u\tBuf0: %s\tBuf1: %s", read,
|
||||
waveBuf[0].status == NDSP_WBUF_QUEUED ? "Q" : "P",
|
||||
waveBuf[1].status == NDSP_WBUF_QUEUED ? "Q" : "P");
|
||||
#endif
|
||||
|
||||
DSP_FlushDataCache(buffer1, chunkSize);
|
||||
DSP_FlushDataCache(buffer2, chunkSize);
|
||||
}
|
||||
|
||||
printf("\nEnd of file.");
|
||||
|
||||
@@ -134,6 +134,9 @@ int main(int argc, char **argv)
|
||||
if(closedir(dp) != 0)
|
||||
err_print("Closing directory failed.");
|
||||
|
||||
/* TODO: There is an issue with Unicode files here.
|
||||
* Playing a flac file then a file with a name containing the
|
||||
* character 'é' will cause the asprint to not work properly. */
|
||||
if(asprintf(&file, "%s%s", AUDIO_FOLDER, ep->d_name) == -1)
|
||||
{
|
||||
err_print("Constructing file name failed.");
|
||||
@@ -183,9 +186,10 @@ int getFileType(const char *file)
|
||||
int fileSig = 0;
|
||||
enum file_types file_type = FILE_TYPE_ERROR;
|
||||
|
||||
if(file == NULL)
|
||||
if(ftest == NULL)
|
||||
{
|
||||
err_print("Opening file failed.");
|
||||
printf("file: %s\n", file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user