Commit 1d445d10 authored by Max Kellermann's avatar Max Kellermann

SongPrint: move duplicate code into PrintRange()

parent 29d03ab9
...@@ -76,14 +76,11 @@ song_print_uri(Response &r, Partition &partition, ...@@ -76,14 +76,11 @@ song_print_uri(Response &r, Partition &partition,
song_print_uri(r, partition, song.GetURI(), base); song_print_uri(r, partition, song.GetURI(), base);
} }
void static void
song_print_info(Response &r, Partition &partition, PrintRange(Response &r, SongTime start_time, SongTime end_time)
const LightSong &song, bool base)
{ {
song_print_uri(r, partition, song, base); const unsigned start_ms = start_time.ToMS();
const unsigned end_ms = end_time.ToMS();
const unsigned start_ms = song.start_time.ToMS();
const unsigned end_ms = song.end_time.ToMS();
if (end_ms > 0) if (end_ms > 0)
r.Format("Range: %u.%03u-%u.%03u\n", r.Format("Range: %u.%03u-%u.%03u\n",
...@@ -95,6 +92,15 @@ song_print_info(Response &r, Partition &partition, ...@@ -95,6 +92,15 @@ song_print_info(Response &r, Partition &partition,
r.Format("Range: %u.%03u-\n", r.Format("Range: %u.%03u-\n",
start_ms / 1000, start_ms / 1000,
start_ms % 1000); start_ms % 1000);
}
void
song_print_info(Response &r, Partition &partition,
const LightSong &song, bool base)
{
song_print_uri(r, partition, song, base);
PrintRange(r, song.start_time, song.end_time);
if (song.mtime > 0) if (song.mtime > 0)
time_print(r, "Last-Modified", song.mtime); time_print(r, "Last-Modified", song.mtime);
...@@ -108,19 +114,7 @@ song_print_info(Response &r, Partition &partition, ...@@ -108,19 +114,7 @@ song_print_info(Response &r, Partition &partition,
{ {
song_print_uri(r, partition, song, base); song_print_uri(r, partition, song, base);
const unsigned start_ms = song.GetStartTime().ToMS(); PrintRange(r, song.GetStartTime(), song.GetEndTime());
const unsigned end_ms = song.GetEndTime().ToMS();
if (end_ms > 0)
r.Format("Range: %u.%03u-%u.%03u\n",
start_ms / 1000,
start_ms % 1000,
end_ms / 1000,
end_ms % 1000);
else if (start_ms > 0)
r.Format("Range: %u.%03u-\n",
start_ms / 1000,
start_ms % 1000);
if (song.GetLastModified() > 0) if (song.GetLastModified() > 0)
time_print(r, "Last-Modified", song.GetLastModified()); time_print(r, "Last-Modified", song.GetLastModified());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment