Fixes #1538: Lua playFile(): current language sound path added to the file name in case of a relative path
This commit is contained in:
@@ -850,6 +850,9 @@ void AudioQueue::playFile(const char *filename, uint8_t flags, uint8_t id)
|
|||||||
{
|
{
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
printf("playFile(\"%s\", flags=%x, id=%d)\n", filename, flags, id);
|
printf("playFile(\"%s\", flags=%x, id=%d)\n", filename, flags, id);
|
||||||
|
if (strlen(filename) > AUDIO_FILENAME_MAXLEN) {
|
||||||
|
TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN);
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,8 @@ void pushPrompt(uint16_t prompt, uint8_t id=0);
|
|||||||
#define START_SILENCE_PERIOD()
|
#define START_SILENCE_PERIOD()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char * getAudioPath(char * path);
|
||||||
|
|
||||||
void referenceSystemAudioFiles();
|
void referenceSystemAudioFiles();
|
||||||
void referenceModelAudioFiles();
|
void referenceModelAudioFiles();
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,15 @@ static int luaGetValue(lua_State *L)
|
|||||||
static int luaPlayFile(lua_State *L)
|
static int luaPlayFile(lua_State *L)
|
||||||
{
|
{
|
||||||
const char * filename = luaL_checkstring(L, 1);
|
const char * filename = luaL_checkstring(L, 1);
|
||||||
|
if (filename[0] != '/') {
|
||||||
|
// relative sound file path - use current languague dir for absolute path
|
||||||
|
char file[AUDIO_FILENAME_MAXLEN+1];
|
||||||
|
char * str = getAudioPath(file);
|
||||||
|
strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file));
|
||||||
|
file[AUDIO_FILENAME_MAXLEN] = 0;
|
||||||
|
PLAY_FILE(file, 0, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
PLAY_FILE(filename, 0, 0);
|
PLAY_FILE(filename, 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user