Handle track duration with milliseconds precision. ref #244

This commit is contained in:
emeric
2022-08-20 14:27:54 +02:00
parent 2aafeddb1b
commit 49f0d40515
4 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -286,7 +286,7 @@ TagLibParser::parse(const std::filesystem::path& p, bool debug)
{
const TagLib::AudioProperties *properties {f.audioProperties() };
track.duration = std::chrono::milliseconds {properties->length() * 1000};
track.duration = std::chrono::milliseconds {properties->lengthInMilliseconds()};
MetaData::AudioStream audioStream {static_cast<unsigned>(properties->bitrate() * 1000)};
track.audioStreams = {std::move(audioStream)};
@@ -591,6 +591,15 @@ CREATE TABLE IF NOT EXISTS "track_artist_link_backup" (
session.getDboSession().execute("ALTER TABLE tracklist ADD last_modified_date_time TEXT");
}
static
void
migrateFromV36(Session& session)
{
// Increased precision for track durations (now in milliseconds instead of secodns)
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
ScanSettings::get(session).modify()->incScanVersion();
}
void
doDbMigration(Session& session)
{
@@ -633,6 +642,7 @@ CREATE TABLE IF NOT EXISTS "track_artist_link_backup" (
{33, migrateFromV33},
{34, migrateFromV34},
{35, migrateFromV35},
{36, migrateFromV36},
};
while (1)
@@ -26,7 +26,7 @@ namespace Database
class Session;
using Version = std::size_t;
static constexpr Version LMS_DATABASE_VERSION {36};
static constexpr Version LMS_DATABASE_VERSION {37};
class VersionInfo
{
public: