void CueSheet::parse_index(const std::string *args) { if (!m_tracks.size()) die("INDEX command before TRACK"); if (m_cur_file.empty()) die("INDEX command before FILE"); unsigned no, mm, ss, ff, nframes; if (std::sscanf(args[1].c_str(), "%u", &no) != 1) die("Invalid INDEX number"); if (std::sscanf(args[2].c_str(), "%u:%u:%u", &mm, &ss, &ff) != 3) die("Invalid INDEX time format"); if (ss > 59 || ff > 74) die("Invalid INDEX time format"); nframes = msf2frames(mm, ss, ff); CueSegment *lastseg = last_segment(); if (lastseg && lastseg->m_filename == m_cur_file) { lastseg->m_end = nframes; if (lastseg->m_begin >= nframes) die("INDEX time must be in ascending order"); } CueSegment segment(m_cur_file, no); segment.m_begin = nframes; if (no > 0) m_tracks.back().add_segment(segment); else { if (m_tracks.size() == 1) { /* HTOA */ m_tracks.insert(m_tracks.begin(), CueTrack(this, 0)); m_tracks[0].set_meta("title", "(HTOA)"); segment.m_index = 1; } else segment.m_index = 0x7fffffff; m_tracks[m_tracks.size() - 2].add_segment(segment); } }
void CueSheet::parseTrack(const std::wstring *args) { if (args[2] == L"AUDIO") { unsigned no; if (std::swscanf(args[1].c_str(), L"%d", &no) != 1) die("Invalid TRACK number"); m_tracks.push_back(CueTrack(no)); } }