play: use stack to store filename

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2025-08-01 00:01:08 +01:00
parent c5d2650ea7
commit fb7c6166b1
3 changed files with 10 additions and 5 deletions

View File

@@ -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. */

View File

@@ -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);
printf("Playing: %s\n", playbackInfo->file);
//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;
}
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);

View File

@@ -208,7 +208,6 @@ out:
ndspExit();
}
delete(info->file);
linearFree(buffer1);
linearFree(buffer2);