diff options
author | John Regan <john@jrjrtech.com> | 2017-09-22 16:51:36 +0200 |
---|---|---|
committer | John Regan <john@jrjrtech.com> | 2017-09-22 19:58:17 +0200 |
commit | e96513c8db704c67817cb6c1cc2876cff8b33c2c (patch) | |
tree | 9e6232e195707006a1882b9487791538d8cad2ec /src/decoder/plugins/GmeDecoderPlugin.cxx | |
parent | da9657aac46bddf194ff9d910eaf542b159632a6 (diff) |
GME Plugin: try loading m3u sidecar files
Diffstat (limited to 'src/decoder/plugins/GmeDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/GmeDecoderPlugin.cxx | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index 5a9379488..3f9dbfee1 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -105,16 +105,39 @@ ParseContainerPath(Path path_fs) return { path_fs.GetDirectoryName(), track - 1 }; } -static void -gme_file_decode(DecoderClient &client, Path path_fs) -{ - const auto container = ParseContainerPath(path_fs); +static Music_Emu* +LoadGmeAndM3u(GmeContainerPath container) { + + const char *path = container.path.c_str(); + const char *suffix = uri_get_suffix(path); Music_Emu *emu; 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) { 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; } @@ -129,7 +152,7 @@ gme_file_decode(DecoderClient &client, Path path_fs) #endif 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) { LogWarning(gme_domain, gme_err); return; @@ -255,11 +278,8 @@ gme_scan_file(Path path_fs, { const auto container = ParseContainerPath(path_fs); - Music_Emu *emu; - const char *gme_err = - gme_open_file(container.path.c_str(), &emu, GME_SAMPLE_RATE); - if (gme_err != nullptr) { - LogWarning(gme_domain, gme_err); + Music_Emu *emu = LoadGmeAndM3u(container); + if(emu == nullptr) { return false; } @@ -272,12 +292,10 @@ static std::forward_list<DetachedSong> gme_container_scan(Path path_fs) { std::forward_list<DetachedSong> list; + const auto container = ParseContainerPath(path_fs); - Music_Emu *emu; - const char *gme_err = gme_open_file(path_fs.c_str(), &emu, - GME_SAMPLE_RATE); - if (gme_err != nullptr) { - LogWarning(gme_domain, gme_err); + Music_Emu *emu = LoadGmeAndM3u(container); + if(emu == nullptr) { return list; } |