Change how getting the current title works, and fix ZSM backend not setting itself as opened.
Some checks failed
Build / get-source-code (push) Blocked by required conditions
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 1m43s
Build / download-system-deps (push) Has been cancelled
Some checks failed
Build / get-source-code (push) Blocked by required conditions
Build / build-deb (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 1m43s
Build / download-system-deps (push) Has been cancelled
This commit is contained in:
parent
a41c63d059
commit
de60317656
3 changed files with 22 additions and 9 deletions
|
@ -62,10 +62,7 @@ void SDLMixerXBackend::load(const char *filename) {
|
|||
current_file = std::string(filename);
|
||||
const char *title_tag = Mix_GetMusicTitleTag(output);
|
||||
// Check for an empty string, which indicates there's no title tag.
|
||||
if (title_tag[0] == '\0') {
|
||||
std::filesystem::path path(current_file);
|
||||
current_title = path.stem().string();
|
||||
} else {
|
||||
if (title_tag[0] != '\0') {
|
||||
current_title = std::string(title_tag);
|
||||
}
|
||||
this->music = output;
|
||||
|
@ -73,9 +70,9 @@ void SDLMixerXBackend::load(const char *filename) {
|
|||
PlaybackStream stream;
|
||||
stream.id = 0;
|
||||
stream.length = Mix_MusicDuration(output);
|
||||
stream.name = current_title;
|
||||
streams.push_back(stream);
|
||||
open = true;
|
||||
stream.name = get_current_title.value();
|
||||
streams.push_back(stream);
|
||||
initial = true;
|
||||
}
|
||||
void SDLMixerXBackend::switch_stream(int idx) {
|
||||
|
|
|
@ -40,7 +40,7 @@ std::vector<Property> ZsmBackend::get_property_list() {
|
|||
return properties;
|
||||
}
|
||||
void ZsmBackend::load(const char *filename) {
|
||||
memset(&spec, 0, sizeof(spec));
|
||||
memset(&spec, 0, sizeof(spec));
|
||||
current_file = filename;
|
||||
spec.format = AUDIO_S16SYS;
|
||||
spec.samples = 100;
|
||||
|
@ -157,6 +157,7 @@ void ZsmBackend::load(const char *filename) {
|
|||
property_defaults[#name] = value; \
|
||||
}
|
||||
#include "properties.inc"
|
||||
PlaybackStream stream;
|
||||
}
|
||||
extern SDL_AudioSpec obtained;
|
||||
void ZsmBackend::switch_stream(int idx) {
|
||||
|
@ -172,6 +173,7 @@ void ZsmBackend::switch_stream(int idx) {
|
|||
this->cpuClocks = 0.0;
|
||||
this->delayTicks = 0.0;
|
||||
this->ticks = 0.0;
|
||||
open = true;
|
||||
}
|
||||
void ZsmBackend::cleanup() {
|
||||
delete file;
|
||||
|
|
|
@ -24,7 +24,7 @@ class PlaybackBackend {
|
|||
uint64_t length;
|
||||
std::vector<PlaybackStream> streams;
|
||||
std::string current_file;
|
||||
std::string current_title;
|
||||
std::optional<std::string> current_title;
|
||||
bool open;
|
||||
SDL_AudioSpec spec;
|
||||
uint64_t position;
|
||||
|
@ -134,7 +134,21 @@ class PlaybackBackend {
|
|||
return open ? current_file : std::optional<std::string>();
|
||||
}
|
||||
inline virtual std::optional<std::string> get_title() {
|
||||
return open ? current_title : std::optional<std::string>();
|
||||
if (open) {
|
||||
if (current_title.has_value()) {
|
||||
return current_title;
|
||||
} else {
|
||||
auto file = get_current_file();
|
||||
if (file.has_value()) {
|
||||
std::filesystem::path path(file.value());
|
||||
return path.stem().string();
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
inline virtual int get_stream_idx() {return 0;}
|
||||
inline virtual ~PlaybackBackend() { }
|
||||
|
|
Loading…
Reference in a new issue