void music_track::resolve() { if (id_.empty()) { LOG_AUDIO << "empty track filename specified for track identification\n"; return; } file_path_ = get_binary_file_location("music", id_); if (file_path_.empty()) { LOG_AUDIO << "could not find track '" << id_ << "' for track identification\n"; return; } #if !defined(_WIN32) && !defined(__APPLE__) && !defined(PANDORA) if (title_.empty()) { FILE* f; f = fopen(file_path_.c_str(), "r"); if (f == NULL) { LOG_AUDIO << "Error opening file '" << file_path_ << "' for track identification\n"; return; } OggVorbis_File vf; if(ov_open(f, &vf, NULL, 0) < 0) { LOG_AUDIO << "track does not appear to be an Ogg file '" << id_ << "', cannot be identified\n"; ov_clear(&vf); return; } vorbis_comment* comments = ov_comment(&vf, -1); char** user_comments = comments->user_comments; bool found = false; for (int i=0; i< comments->comments; i++) { const std::string comment_string(user_comments[i]); const std::vector<std::string> comment_list = utils::split(comment_string, '='); if (comment_list[0] == "TITLE" || comment_list[0] == "title") { title_ = comment_list[1]; found = true; } } if (!found) { LOG_AUDIO << "No title for music track '" << id_ << "'\n"; } ov_clear(&vf); } #endif LOG_AUDIO << "resolved music track '" << id_ << "' into '" << file_path_ << "'\n"; }
void music_track::resolve() { if (id_.empty()) { ERR_AUDIO << "empty track filename specified\n"; return; } file_path_ = get_binary_file_location("music", id_); if (file_path_.empty()) { ERR_AUDIO << "could not find track '" << id_ << "'\n"; return; } LOG_AUDIO << "resolved music track '" << id_ << "' into '" << file_path_ << "'\n"; }