Add constants and variable units
Scrobble point constants are now defined as the minimum and maximum time last.fm requires for a scrobble to be valid.
This commit is contained in:
parent
50ff5f5b0e
commit
fde8ae0f30
@ -95,6 +95,9 @@ const char* Playlist::kWriteMetadata = "write_metadata";
|
|||||||
const int Playlist::kUndoStackSize = 20;
|
const int Playlist::kUndoStackSize = 20;
|
||||||
const int Playlist::kUndoItemLimit = 500;
|
const int Playlist::kUndoItemLimit = 500;
|
||||||
|
|
||||||
|
const qint64 Playlist::kMinScrobblePointNsecs = 31ll * kNsecPerSec;
|
||||||
|
const qint64 Playlist::kMaxScrobblePointNsecs = 240ll * kNsecPerSec;
|
||||||
|
|
||||||
Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
|
Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager,
|
||||||
LibraryBackend* library, int id, const QString& special_type,
|
LibraryBackend* library, int id, const QString& special_type,
|
||||||
bool favorite, QObject* parent)
|
bool favorite, QObject* parent)
|
||||||
@ -1705,24 +1708,24 @@ Song Playlist::current_item_metadata() const {
|
|||||||
return current_item()->Metadata();
|
return current_item()->Metadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::UpdateScrobblePoint(qint64 seek_point) {
|
void Playlist::UpdateScrobblePoint(qint64 seek_point_nanosec) {
|
||||||
const qint64 length = current_item_metadata().length_nanosec();
|
const qint64 length = current_item_metadata().length_nanosec();
|
||||||
|
|
||||||
if (seek_point == 0) {
|
if (seek_point_nanosec == 0) {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
scrobble_point_ = 240ll * kNsecPerSec; // 4 minutes
|
scrobble_point_ = kMaxScrobblePointNsecs; // 4 minutes
|
||||||
} else {
|
} else {
|
||||||
scrobble_point_ =
|
scrobble_point_ =
|
||||||
qBound(31ll * kNsecPerSec, length / 2, 240ll * kNsecPerSec);
|
qBound(kMinScrobblePointNsecs, length / 2, kMaxScrobblePointNsecs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
// current time + 4 minutes
|
// current time + 4 minutes
|
||||||
scrobble_point_ = seek_point + (240ll * kNsecPerSec);
|
scrobble_point_ = seek_point_nanosec + kMaxScrobblePointNsecs;
|
||||||
} else {
|
} else {
|
||||||
scrobble_point_ =
|
scrobble_point_ = qBound(seek_point_nanosec + kMinScrobblePointNsecs,
|
||||||
qBound(seek_point + (31ll * kNsecPerSec), seek_point + (length / 2),
|
seek_point_nanosec + (length / 2),
|
||||||
seek_point + (240ll * kNsecPerSec));
|
seek_point_nanosec + kMaxScrobblePointNsecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +160,9 @@ class Playlist : public QAbstractListModel {
|
|||||||
static const int kUndoStackSize;
|
static const int kUndoStackSize;
|
||||||
static const int kUndoItemLimit;
|
static const int kUndoItemLimit;
|
||||||
|
|
||||||
|
static const qint64 kMinScrobblePointNsecs;
|
||||||
|
static const qint64 kMaxScrobblePointNsecs;
|
||||||
|
|
||||||
static bool CompareItems(int column, Qt::SortOrder order, PlaylistItemPtr a,
|
static bool CompareItems(int column, Qt::SortOrder order, PlaylistItemPtr a,
|
||||||
PlaylistItemPtr b);
|
PlaylistItemPtr b);
|
||||||
|
|
||||||
@ -227,7 +230,7 @@ class Playlist : public QAbstractListModel {
|
|||||||
}
|
}
|
||||||
void set_lastfm_status(LastFMStatus status) { lastfm_status_ = status; }
|
void set_lastfm_status(LastFMStatus status) { lastfm_status_ = status; }
|
||||||
void set_have_incremented_playcount() { have_incremented_playcount_ = true; }
|
void set_have_incremented_playcount() { have_incremented_playcount_ = true; }
|
||||||
void UpdateScrobblePoint(qint64 seek_point = 0);
|
void UpdateScrobblePoint(qint64 seek_point_nanosec = 0);
|
||||||
|
|
||||||
// Changing the playlist
|
// Changing the playlist
|
||||||
void InsertItems(const PlaylistItemList& items, int pos = -1,
|
void InsertItems(const PlaylistItemList& items, int pos = -1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user