| 84 | } |
| 85 | |
| 86 | std::string format_time(int64_t sample, int sample_rate) { |
| 87 | const int64_t ms = (sample * 1000 + sample_rate / 2) / sample_rate; |
| 88 | const int64_t hours = ms / 3600000; |
| 89 | const int64_t minutes = (ms / 60000) % 60; |
| 90 | const int64_t seconds = (ms / 1000) % 60; |
| 91 | const int64_t millis = ms % 1000; |
| 92 | |
| 93 | std::ostringstream out; |
| 94 | out << std::setfill('0') |
| 95 | << std::setw(2) << hours << ':' |
| 96 | << std::setw(2) << minutes << ':' |
| 97 | << std::setw(2) << seconds << ',' |
| 98 | << std::setw(3) << millis; |
| 99 | return out.str(); |
| 100 | } |
| 101 | |
| 102 | } // namespace |
| 103 | |