Skip to content

Commit e3d753c

Browse files
committed
console: Load companion .m3u/.m3u8 for subsong metadata
The bundled GME library includes a full M3u_Playlist parser that understands the NEZplug extended m3u format (with ::TYPE and $track syntax), but the code to auto-load a companion .m3u was disabled. Re-enable it using the Audacious StringBuf API. When a game music file is loaded, look for a matching .m3u8 (preferred) or .m3u file in the same directory and feed it to the emulator. This provides track names, durations, and correct subsong mapping for KSS, NSF, GBS, HES, and other multi-track formats.
1 parent 95a3dbf commit e3d753c

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/console/Audacious_Driver.cc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,22 @@ int ConsoleFileHandler::load(int sample_rate)
120120

121121
log_warning(m_emu);
122122

123-
#if 0
124-
// load .m3u from same directory( replace/add extension with ".m3u")
125-
char *m3u_path = g_strdup(m_path);
126-
char *ext = strrchr(m3u_path, '.');
127-
if (ext == nullptr)
128-
{
129-
ext = g_strdup_printf("%s.m3u", m3u_path);
130-
g_free(m3u_path);
131-
m3u_path = ext;
132-
}
123+
// load companion .m3u or .m3u8 from same directory
124+
StringBuf base_path = str_copy(m_path);
125+
const char *dot = strrchr(base_path, '.');
126+
if (dot)
127+
base_path.resize(dot - base_path);
133128

134129
Vfs_File_Reader m3u;
130+
StringBuf m3u_path = str_concat({base_path, ".m3u8"});
131+
if (m3u.open(m3u_path))
132+
m3u_path = str_concat({base_path, ".m3u"});
133+
135134
if (!m3u.open(m3u_path))
136135
{
137-
if (log_err(m_emu->load_m3u(m3u))) // TODO: fail if m3u can't be loaded?
138-
log_warning(m_emu); // this will log line number of first problem in m3u
136+
if (log_err(m_emu->load_m3u(m3u)))
137+
log_warning(m_emu);
139138
}
140-
#endif
141139

142140
return 0;
143141
}

0 commit comments

Comments
 (0)