Skip to content

Commit

Permalink
Be explicit if Songlenth DB is not loaded (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfiemost committed Apr 5, 2024
1 parent 8cddb3c commit bbfcd05
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,19 @@ int ConsolePlayer::args(int argc, const char *argv[])
? (m_iniCfg.sidplay2()).recordLength
: (m_iniCfg.sidplay2()).playLength;


songlengthDB = SLDB_NONE;
bool dbOpened = false;
if (hvscBase)
{
if (tryOpenDatabase(hvscBase, "md5"))
{
dbOpened = true;
newSonglengthDB = true;
songlengthDB = SLDB_MD5;
}
else if (tryOpenDatabase(hvscBase, "txt"))
{
dbOpened = true;
songlengthDB = SLDB_TXT;
}
}

Expand Down Expand Up @@ -587,7 +588,9 @@ int ConsolePlayer::args(int argc, const char *argv[])
}

if ((m_iniCfg.sidplay2()).database.find(TEXT(".md5")) != SID_STRING::npos)
newSonglengthDB = true;
songlengthDB = SLDB_MD5;
else
songlengthDB = SLDB_TXT;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ void ConsolePlayer::menu ()
}
else if (m_timer.valid)
cerr << "FOREVER";
else if (songlengthDB == SLDB_NONE)
cerr << "NO SLDB";
else
cerr << "UNKNOWN";
if (m_timer.start)
Expand Down
4 changes: 2 additions & 2 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ ConsolePlayer::ConsolePlayer (const char * const name) :
m_fcurve(-1.0),
m_quietLevel(0),
m_cpudebug(false),
newSonglengthDB(false),
songlengthDB(SLDB_NONE),
m_autofilter(false)
{
#ifdef FEAT_REGS_DUMP_SID
Expand Down Expand Up @@ -799,7 +799,7 @@ bool ConsolePlayer::open (void)
if (!m_timer.valid)
{
#ifdef FEAT_NEW_SONLEGTH_DB
const int_least32_t length = newSonglengthDB ? m_database.lengthMs(m_tune) : (m_database.length(m_tune) * 1000);
const int_least32_t length = songlengthDB == SLDB_MD5 ? m_database.lengthMs(m_tune) : (m_database.length(m_tune) * 1000);
#else
const int_least32_t length = m_database.length(m_tune) * 1000;
#endif
Expand Down
14 changes: 11 additions & 3 deletions src/player.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of sidplayfp, a console SID player.
*
* Copyright 2011-2023 Leandro Nini
* Copyright 2011-2024 Leandro Nini
* Copyright 2000-2001 Simon White
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -92,6 +92,14 @@ enum
ERR_FILE_OPEN
};

// Songlength DB.
typedef enum
{
SLDB_NONE = 0,
SLDB_TXT,
SLDB_MD5
} sldb_t;

void displayError (const char *arg0, unsigned int num);


Expand Down Expand Up @@ -139,9 +147,9 @@ class ConsolePlayer
uint_least8_t m_quietLevel;
uint_least8_t m_verboseLevel;

bool m_cpudebug;
sldb_t songlengthDB;

bool newSonglengthDB;
bool m_cpudebug;

bool m_autofilter;

Expand Down

0 comments on commit bbfcd05

Please sign in to comment.