diff --git a/src/audio/ogg_sound_file.cpp b/src/audio/ogg_sound_file.cpp index 75ae72e9cd7..b080bfa1fb8 100644 --- a/src/audio/ogg_sound_file.cpp +++ b/src/audio/ogg_sound_file.cpp @@ -21,7 +21,8 @@ #include #include -OggSoundFile::OggSoundFile(PHYSFS_File* file_, double loop_begin_, double loop_at_) : +OggSoundFile::OggSoundFile(PHYSFS_File* file_, double loop_begin_, double loop_at_, std::string author) : + SoundFile(author), m_file(file_), m_vorbis_file(), m_loop_begin(), diff --git a/src/audio/ogg_sound_file.hpp b/src/audio/ogg_sound_file.hpp index 35e10f2a83d..ed0499fb1a0 100644 --- a/src/audio/ogg_sound_file.hpp +++ b/src/audio/ogg_sound_file.hpp @@ -32,7 +32,7 @@ class OggSoundFile final : public SoundFile static long cb_tell(void* source); public: - OggSoundFile(PHYSFS_File* file, double loop_begin, double loop_at); + OggSoundFile(PHYSFS_File* file, double loop_begin, double loop_at, std::string m_author = ""); ~OggSoundFile() override; virtual size_t read(void* buffer, size_t buffer_size) override; diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index cf98711cca3..730310f7b3b 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -62,10 +62,12 @@ std::unique_ptr load_music_file(const std::string& filename_original) auto music = root.get_mapping(); std::string raw_music_file; + std::string author; float loop_begin = 0; float loop_at = -1; music.get("file", raw_music_file); + music.get("author", author); music.get("loop-begin", loop_begin); music.get("loop-at", loop_at); @@ -85,11 +87,11 @@ std::unique_ptr load_music_file(const std::string& filename_original) auto format = SoundFile::get_file_format(file, raw_music_file); if (format == SoundFile::FORMAT_WAV) { - return std::make_unique(file); + return std::make_unique(file, author); } else { - return std::make_unique(file, loop_begin, loop_at); + return std::make_unique(file, loop_begin, loop_at, author); } } } diff --git a/src/audio/sound_file.hpp b/src/audio/sound_file.hpp index 1dffb6fb04d..a36c3ffdd6e 100644 --- a/src/audio/sound_file.hpp +++ b/src/audio/sound_file.hpp @@ -34,11 +34,12 @@ class SoundFile static FileFormat get_file_format(PHYSFS_File* file, const std::string& filename); public: - SoundFile() : + SoundFile(std::string author = "") : m_channels(), m_rate(), m_bits_per_sample(), - m_size() + m_size(), + m_author(author) {} virtual ~SoundFile() {} @@ -52,6 +53,7 @@ class SoundFile int m_bits_per_sample; /// size in bytes size_t m_size; + std::string m_author; private: SoundFile(const SoundFile&) = delete; diff --git a/src/audio/wav_sound_file.cpp b/src/audio/wav_sound_file.cpp index 4db3720de5d..37a52e0bf36 100644 --- a/src/audio/wav_sound_file.cpp +++ b/src/audio/wav_sound_file.cpp @@ -44,7 +44,8 @@ static inline uint16_t read16LE(PHYSFS_file* file) return result; } -WavSoundFile::WavSoundFile(PHYSFS_file* file_) : +WavSoundFile::WavSoundFile(PHYSFS_file* file_, std::string author) : + SoundFile(author), m_file(file_), m_datastart() { diff --git a/src/audio/wav_sound_file.hpp b/src/audio/wav_sound_file.hpp index f119370e7fb..254f13da725 100644 --- a/src/audio/wav_sound_file.hpp +++ b/src/audio/wav_sound_file.hpp @@ -24,7 +24,7 @@ class WavSoundFile final : public SoundFile { public: - WavSoundFile(PHYSFS_file* file); + WavSoundFile(PHYSFS_file* file, std::string author = ""); ~WavSoundFile() override; virtual size_t read(void* buffer, size_t buffer_size) override;