Skip to content

Commit

Permalink
Cross-platform music track reading
Browse files Browse the repository at this point in the history
Works on at least Windows and Linux. May need testing for macOS.

Won't see a difference in Map Editor music tracks unless the way sound-utils.cfg macros are used (reading track titles from that file) is changed.
  • Loading branch information
Wedge009 authored and Vultraz committed Jan 22, 2019
1 parent e0a6588 commit 897fbd2
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/sound_music_track.cpp
Expand Up @@ -19,9 +19,7 @@
#include "filesystem.hpp"
#include "log.hpp"
#include "serialization/string_utils.hpp"
#if !defined(_WIN32) && !defined(__APPLE__)
#include "vorbis/vorbisfile.h"
#endif

static lg::log_domain log_audio("audio");
#define ERR_AUDIO LOG_STREAM(err, log_audio)
Expand Down Expand Up @@ -83,21 +81,10 @@ void music_track::resolve()
return;
}


#if !defined(_WIN32) && !defined(__APPLE__)
if (title_.empty()) {
FILE* f;
f = fopen(file_path_.c_str(), "r");
if (f == nullptr) {
LOG_AUDIO << "Error opening file '" << file_path_
<< "' for track identification\n";
return;
}

OggVorbis_File vf;
if(ov_open(f, &vf, nullptr, 0) < 0) {
LOG_AUDIO << "track does not appear to be an Ogg file '"
<< id_ << "', cannot be identified\n";
if(ov_fopen(file_path_.c_str(), &vf) < 0) {
LOG_AUDIO << "Error opening file '" << file_path_ << "' for track identification\n";
ov_clear(&vf);
return;
}
Expand All @@ -121,7 +108,6 @@ void music_track::resolve()

ov_clear(&vf);
}
#endif

LOG_AUDIO << "resolved music track '" << id_ << "' into '" << file_path_ << "'\n";
}
Expand Down

0 comments on commit 897fbd2

Please sign in to comment.