GME Plugin: try loading m3u sidecar files

This commit is contained in:
John Regan 2017-09-22 16:51:36 +02:00
parent da9657aac4
commit e96513c8db

View File

@ -105,16 +105,39 @@ ParseContainerPath(Path path_fs)
return { path_fs.GetDirectoryName(), track - 1 };
}
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(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;
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;
}
@ -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;
}