play: use stack to store filename
Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef ctrmus_playback_h
|
||||
#define ctrmus_playback_h
|
||||
@@ -53,7 +54,7 @@ struct decoder_fn
|
||||
|
||||
struct playbackInfo_t
|
||||
{
|
||||
char *file;
|
||||
char file[PATH_MAX];
|
||||
struct errInfo_t *errInfo;
|
||||
|
||||
/* If 0, then the duration of file is unavailable. */
|
||||
|
||||
@@ -107,12 +107,18 @@ static int changeFile(const char* ep_file, struct playbackInfo_t* playbackInfo)
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
/* If file is NULL, then only thread termination was requested. */
|
||||
if(ep_file == NULL || playbackInfo == NULL)
|
||||
return 0;
|
||||
|
||||
//playbackInfo->file = strdup(ep_file);
|
||||
if (memccpy(playbackInfo->file, ep_file, '\0', sizeof(playbackInfo->file)) == NULL)
|
||||
{
|
||||
puts("Error: File path too long\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
playbackInfo->file = strdup(ep_file);
|
||||
printf("Playing: %s\n", playbackInfo->file);
|
||||
|
||||
playbackInfo->samples_total = 0;
|
||||
playbackInfo->samples_played = 0;
|
||||
playbackInfo->samples_per_second = 0;
|
||||
@@ -316,7 +322,6 @@ int main(int argc, char **argv)
|
||||
watchdogThread = threadCreate(playbackWatchdog,
|
||||
&watchdogInfoIn, 4 * 1024, 0x20, -2, true);
|
||||
|
||||
playbackInfo.file = NULL;
|
||||
playbackInfo.errInfo = &errInfo;
|
||||
|
||||
chdir(DEFAULT_DIR);
|
||||
|
||||
@@ -208,7 +208,6 @@ out:
|
||||
ndspExit();
|
||||
}
|
||||
|
||||
delete(info->file);
|
||||
linearFree(buffer1);
|
||||
linearFree(buffer2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user