Call decoder depending on file type

Signed-off-by: Mahyar Koshkouei <deltabeard@users.noreply.github.com>
This commit is contained in:
Mahyar Koshkouei
2016-12-21 20:41:35 +00:00
parent 70e920cec6
commit 90622a974a
2 changed files with 17 additions and 7 deletions

View File

@@ -136,12 +136,24 @@ int main(int argc, char **argv)
err_print("Opening file failed.");
else
{
int ret;
// TODO: make this dynamic
if((ret = convOpus(file, "sdmc:/MUSIC/out.wav")) != 0)
playWav(file);
char* ext = strrchr(file, '.');
printf("ret=%d\n", ret);
if(ext == NULL)
printf("\nUnable to obtain file type.");
else
{
/* To skip the dot */
ext++;
// TODO: Don't rely on file extension.
if(strncasecmp(ext, "opus", 4) == 0)
convOpus(file, "sdmc:/MUSIC/out.wav");
else if(strncasecmp(ext, "wav", 3) == 0 ||
strncasecmp(ext, "aiff", 4) == 0)
playWav(file);
else
printf("\nFile type \"%s\" not recognised.", ext);
}
}
free(file);

View File

@@ -14,5 +14,3 @@
* \return Zero if successful, else failure.
*/
int playWav(const char *wav);
int playOpus(const char *opus);