Commit e96513c8 authored by John Regan's avatar John Regan

GME Plugin: try loading m3u sidecar files

parent da9657aa
...@@ -105,16 +105,39 @@ ParseContainerPath(Path path_fs) ...@@ -105,16 +105,39 @@ ParseContainerPath(Path path_fs)
return { path_fs.GetDirectoryName(), track - 1 }; return { path_fs.GetDirectoryName(), track - 1 };
} }
static void static Music_Emu*
gme_file_decode(DecoderClient &client, Path path_fs) LoadGmeAndM3u(GmeContainerPath container) {
{
const auto container = ParseContainerPath(path_fs); const char *path = container.path.c_str();
const char *suffix = uri_get_suffix(path);
Music_Emu *emu; Music_Emu *emu;
const char *gme_err = const char *gme_err =
gme_open_file(container.path.c_str(), &emu, GME_SAMPLE_RATE); gme_open_file(path, &emu, GME_SAMPLE_RATE);
if (gme_err != nullptr) { if (gme_err != nullptr) {
LogWarning(gme_domain, gme_err); LogWarning(gme_domain, gme_err);
return nullptr;
}
if(suffix == nullptr) {
return emu;
}
std::string m3u_path(path,suffix);
m3u_path += "m3u";
gme_load_m3u(emu,m3u_path.c_str());
return emu;
}
static void
gme_file_decode(DecoderClient &client, Path path_fs)
{
const auto container = ParseContainerPath(path_fs);
Music_Emu *emu = LoadGmeAndM3u(container);
if(emu == nullptr) {
return; return;
} }
...@@ -129,7 +152,7 @@ gme_file_decode(DecoderClient &client, Path path_fs) ...@@ -129,7 +152,7 @@ gme_file_decode(DecoderClient &client, Path path_fs)
#endif #endif
gme_info_t *ti; gme_info_t *ti;
gme_err = gme_track_info(emu, &ti, container.track); const char *gme_err = gme_track_info(emu, &ti, container.track);
if (gme_err != nullptr) { if (gme_err != nullptr) {
LogWarning(gme_domain, gme_err); LogWarning(gme_domain, gme_err);
return; return;
...@@ -255,11 +278,8 @@ gme_scan_file(Path path_fs, ...@@ -255,11 +278,8 @@ gme_scan_file(Path path_fs,
{ {
const auto container = ParseContainerPath(path_fs); const auto container = ParseContainerPath(path_fs);
Music_Emu *emu; Music_Emu *emu = LoadGmeAndM3u(container);
const char *gme_err = if(emu == nullptr) {
gme_open_file(container.path.c_str(), &emu, GME_SAMPLE_RATE);
if (gme_err != nullptr) {
LogWarning(gme_domain, gme_err);
return false; return false;
} }
...@@ -272,12 +292,10 @@ static std::forward_list<DetachedSong> ...@@ -272,12 +292,10 @@ static std::forward_list<DetachedSong>
gme_container_scan(Path path_fs) gme_container_scan(Path path_fs)
{ {
std::forward_list<DetachedSong> list; std::forward_list<DetachedSong> list;
const auto container = ParseContainerPath(path_fs);
Music_Emu *emu; Music_Emu *emu = LoadGmeAndM3u(container);
const char *gme_err = gme_open_file(path_fs.c_str(), &emu, if(emu == nullptr) {
GME_SAMPLE_RATE);
if (gme_err != nullptr) {
LogWarning(gme_domain, gme_err);
return list; return list;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment