Skip to content

Commit 09ea9b5

Browse files
committed
Submit tracks of unknown duration after minimum playback time
1 parent dc04859 commit 09ea9b5

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/play.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace lbz
3131
"tracknumber",
3232
};
3333

34+
static const size_t min_playback_duration = 240U;
35+
3436
class lbz_play_callback_static : public play_callback_static
3537
{
3638
public:
@@ -43,16 +45,20 @@ namespace lbz
4345
{
4446
m_counter = 0;
4547
const double length = handle->get_length();
46-
if (length >= 5.0 && prefs::check_enabled.get_value())
48+
m_listened_at = 0;
49+
m_target = SIZE_MAX; // ignore this track unless it matches below
50+
if (prefs::check_enabled.get_value())
4751
{
48-
const size_t half = static_cast<size_t>(std::round(length / 2));
49-
m_target = std::min<size_t>(half, 240U);
5052
m_listened_at = pfc::fileTimeWtoU(pfc::fileTimeNow());
51-
}
52-
else
53-
{
54-
m_target = SIZE_MAX;
55-
m_listened_at = 0;
53+
if (length >= 5.0)
54+
{
55+
const size_t half = static_cast<size_t>(std::round(length / 2));
56+
m_target = std::min<size_t>(half, min_playback_duration);
57+
}
58+
else if (length == 0.0)
59+
{
60+
m_target = min_playback_duration;
61+
}
5662
}
5763
}
5864

0 commit comments

Comments
 (0)