- audioplayer: change screensaver handling

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2020-01-31 22:20:04 +01:00
committed by Thilo Graf
parent 04b426412e
commit cad5532dcb
2 changed files with 31 additions and 47 deletions

View File

@@ -287,9 +287,6 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
m_x = DETAILSLINE_WIDTH; m_x = DETAILSLINE_WIDTH;
m_y = getScreenStartY(m_height); m_y = getScreenStartY(m_height);
m_idletime = time(NULL);
m_screensaver = false;
m_cover.clear(); m_cover.clear();
m_stationlogo = false; m_stationlogo = false;
@@ -351,6 +348,7 @@ int CAudioPlayerGui::show()
m_frameBuffer->paintBackground(); m_frameBuffer->paintBackground();
CInfoClock::getInstance()->block(); CInfoClock::getInstance()->block();
CScreenSaver::getInstance()->OnAfterStop.connect(sigc::mem_fun(CInfoClock::getInstance(), &CInfoClock::block)); CScreenSaver::getInstance()->OnAfterStop.connect(sigc::mem_fun(CInfoClock::getInstance(), &CInfoClock::block));
CScreenSaver::getInstance()->resetIdleTime();
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
paintLCD(); paintLCD();
@@ -372,6 +370,9 @@ int CAudioPlayerGui::show()
while (loop) while (loop)
{ {
if (msg <= CRCInput::RC_MaxRC)
CScreenSaver::getInstance()->resetIdleTime();
updateMetaData(); updateMetaData();
updateTimes(); updateTimes();
@@ -419,17 +420,17 @@ int CAudioPlayerGui::show()
if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) if (msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER)
{ {
int delay = time(NULL) - m_idletime; if (CScreenSaver::getInstance()->canStart() && !CScreenSaver::getInstance()->isActive())
int screensaver_delay = g_settings.screensaver_delay;
if (screensaver_delay != 0 && delay > screensaver_delay*60 && !m_screensaver)
screensaver(true);
}
else
{
m_idletime = time(NULL);
if (m_screensaver)
{ {
screensaver(false); CScreenSaver::getInstance()->Start();
}
}
else if (!CScreenSaver::getInstance()->ignoredMsg(msg))
{
if (CScreenSaver::getInstance()->isActive())
{
printf("[audioplayer.cpp] CScreenSaver stop; msg: %lX\n", msg);
CScreenSaver::getInstance()->Stop();
m_frameBuffer->stopFrame(); m_frameBuffer->stopFrame();
m_frameBuffer->showFrame("mp3.jpg"); m_frameBuffer->showFrame("mp3.jpg");
@@ -794,7 +795,7 @@ int CAudioPlayerGui::show()
picture->exec(this, "audio"); picture->exec(this, "audio");
delete picture; delete picture;
pictureviewer = false; pictureviewer = false;
screensaver(false); CScreenSaver::getInstance()->resetIdleTime();
videoDecoder->setBlank(true); videoDecoder->setBlank(true);
m_frameBuffer->showFrame("mp3.jpg"); m_frameBuffer->showFrame("mp3.jpg");
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
@@ -1544,7 +1545,7 @@ bool CAudioPlayerGui::openFilebrowser(void)
result = true; result = true;
} }
m_idletime = time(NULL); CScreenSaver::getInstance()->resetIdleTime();
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
paintLCD(); paintLCD();
// if playlist is turned off -> start playing immediately // if playlist is turned off -> start playing immediately
@@ -1619,7 +1620,7 @@ bool CAudioPlayerGui::openSCbrowser(void)
#endif #endif
result = true; result = true;
} }
m_idletime = time(NULL); CScreenSaver::getInstance()->resetIdleTime();
CVFD::getInstance()->setMode(CVFD::MODE_AUDIO); CVFD::getInstance()->setMode(CVFD::MODE_AUDIO);
paintLCD(); paintLCD();
// if playlist is turned off -> start playing immediately // if playlist is turned off -> start playing immediately
@@ -1697,7 +1698,7 @@ void CAudioPlayerGui::paintItem(int pos)
void CAudioPlayerGui::paintHead() void CAudioPlayerGui::paintHead()
{ {
if (!m_show_playlist || m_screensaver) if (!m_show_playlist || CScreenSaver::getInstance()->isActive())
return; return;
CComponentsHeader header(m_x, m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER, m_width, m_header_height, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_AUDIO); CComponentsHeader header(m_x, m_y + m_title_height + OFFSET_SHADOW + OFFSET_INTER, m_width, m_header_height, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_AUDIO);
@@ -1716,7 +1717,7 @@ void CAudioPlayerGui::paintHead()
void CAudioPlayerGui::paintFoot() void CAudioPlayerGui::paintFoot()
{ {
if (m_screensaver) if (CScreenSaver::getInstance()->isActive())
return; return;
const struct button_label SecondLineButtons[3] = const struct button_label SecondLineButtons[3] =
@@ -1855,7 +1856,7 @@ void CAudioPlayerGui::paintCover()
void CAudioPlayerGui::paintTitleBox() void CAudioPlayerGui::paintTitleBox()
{ {
if (m_screensaver) if (CScreenSaver::getInstance()->isActive())
return; return;
if (m_state == CAudioPlayerGui::STOP && m_show_playlist) if (m_state == CAudioPlayerGui::STOP && m_show_playlist)
@@ -2149,31 +2150,31 @@ void CAudioPlayerGui::play(unsigned int pos)
if (m_selected - m_liststart >= m_listmaxshow && g_settings.audioplayer_follow) if (m_selected - m_liststart >= m_listmaxshow && g_settings.audioplayer_follow)
{ {
m_liststart = m_selected; m_liststart = m_selected;
if (!m_screensaver && !pictureviewer) if (!CScreenSaver::getInstance()->isActive() && !pictureviewer)
paint(); paint();
} }
else if (m_liststart < m_selected && g_settings.audioplayer_follow) else if (m_liststart < m_selected && g_settings.audioplayer_follow)
{ {
m_liststart = m_selected - m_listmaxshow + 1; m_liststart = m_selected - m_listmaxshow + 1;
if (!m_screensaver && !pictureviewer) if (!CScreenSaver::getInstance()->isActive() && !pictureviewer)
paint(); paint();
} }
else else
{ {
if (old_current >= m_liststart && old_current - m_liststart < m_listmaxshow) if (old_current >= m_liststart && old_current - m_liststart < m_listmaxshow)
{ {
if (!m_screensaver && !pictureviewer) if (!CScreenSaver::getInstance()->isActive() && !pictureviewer)
paintItem(old_current - m_liststart); paintItem(old_current - m_liststart);
} }
if (pos >= m_liststart && pos - m_liststart < m_listmaxshow) if (pos >= m_liststart && pos - m_liststart < m_listmaxshow)
{ {
if (!m_screensaver && !pictureviewer) if (!CScreenSaver::getInstance()->isActive() && !pictureviewer)
paintItem(pos - m_liststart); paintItem(pos - m_liststart);
} }
if (g_settings.audioplayer_follow) if (g_settings.audioplayer_follow)
{ {
if (old_selected >= m_liststart && old_selected - m_liststart < m_listmaxshow) if (old_selected >= m_liststart && old_selected - m_liststart < m_listmaxshow)
if (!m_screensaver && !pictureviewer) if (!CScreenSaver::getInstance()->isActive() && !pictureviewer)
paintItem(old_selected - m_liststart); paintItem(old_selected - m_liststart);
} }
} }
@@ -2186,7 +2187,7 @@ void CAudioPlayerGui::play(unsigned int pos)
m_state = CAudioPlayerGui::PLAY; m_state = CAudioPlayerGui::PLAY;
m_curr_audiofile = m_playlist[m_current]; m_curr_audiofile = m_playlist[m_current];
if (m_screensaver && g_settings.audioplayer_cover_as_screensaver) if (CScreenSaver::getInstance()->isActive() && g_settings.audioplayer_cover_as_screensaver)
CScreenSaver::getInstance()->forceRefresh(); CScreenSaver::getInstance()->forceRefresh();
// Play // Play
@@ -2246,13 +2247,13 @@ void CAudioPlayerGui::updateMetaData()
info << " / " << meta.samplerate/1000 << "." << (meta.samplerate/100)%10 <<"kHz"; info << " / " << meta.samplerate/1000 << "." << (meta.samplerate/100)%10 <<"kHz";
m_metainfo = meta.type_info + info.str(); m_metainfo = meta.type_info + info.str();
updateMeta = !m_screensaver; updateMeta = !CScreenSaver::getInstance()->isActive();
if (!meta.artist.empty() && meta.artist != m_curr_audiofile.MetaData.artist) if (!meta.artist.empty() && meta.artist != m_curr_audiofile.MetaData.artist)
{ {
m_curr_audiofile.MetaData.artist = meta.artist; m_curr_audiofile.MetaData.artist = meta.artist;
if (!m_screensaver) if (!CScreenSaver::getInstance()->isActive())
updateScreen = true; updateScreen = true;
updateLcd = true; updateLcd = true;
} }
@@ -2261,7 +2262,7 @@ void CAudioPlayerGui::updateMetaData()
{ {
m_curr_audiofile.MetaData.title = meta.title; m_curr_audiofile.MetaData.title = meta.title;
if (!m_screensaver) if (!CScreenSaver::getInstance()->isActive())
updateScreen = true; updateScreen = true;
updateLcd = true; updateLcd = true;
} }
@@ -2272,7 +2273,7 @@ void CAudioPlayerGui::updateMetaData()
updateLcd = true; updateLcd = true;
} }
if (!m_screensaver) if (!CScreenSaver::getInstance()->isActive())
paintCover(); paintCover();
} }
if (CAudioPlayer::getInstance()->hasMetaDataChanged() != 0) if (CAudioPlayer::getInstance()->hasMetaDataChanged() != 0)
@@ -2320,7 +2321,7 @@ void CAudioPlayerGui::updateTimes(const bool force)
m_time_played = CAudioPlayer::getInstance()->getTimePlayed(); m_time_played = CAudioPlayer::getInstance()->getTimePlayed();
updatePlayed = true; updatePlayed = true;
} }
if (!m_screensaver) if (!CScreenSaver::getInstance()->isActive())
{ {
char total_time[17]; char total_time[17];
snprintf(total_time, sizeof(total_time), " / %ld:%02ld", m_time_total / 60, m_time_total % 60); snprintf(total_time, sizeof(total_time), " / %ld:%02ld", m_time_total / 60, m_time_total % 60);
@@ -2396,20 +2397,6 @@ void CAudioPlayerGui::paintLCD()
break; break;
} }
} }
void CAudioPlayerGui::screensaver(bool on)
{
if (on)
{
m_screensaver = true;
CScreenSaver::getInstance()->Start();
}
else
{
CScreenSaver::getInstance()->Stop();
m_screensaver = false;
m_idletime = time(NULL);
}
}
void CAudioPlayerGui::GetMetaData(CAudiofileExt &File) void CAudioPlayerGui::GetMetaData(CAudiofileExt &File)
{ {

View File

@@ -128,8 +128,6 @@ class CAudioPlayerGui : public CMenuTarget
int m_title_w; int m_title_w;
int m_LastMode; int m_LastMode;
int m_idletime;
bool m_screensaver;
bool m_inetmode; bool m_inetmode;
CComponentsDetailsLine *m_detailsline; CComponentsDetailsLine *m_detailsline;
CComponentsInfoBox *m_infobox; CComponentsInfoBox *m_infobox;
@@ -158,7 +156,6 @@ class CAudioPlayerGui : public CMenuTarget
void updateMetaData(); void updateMetaData();
void updateTimes(const bool force = false); void updateTimes(const bool force = false);
void showMetaData(); void showMetaData();
void screensaver(bool on);
bool getNumericInput(neutrino_msg_t& msg, int& val); bool getNumericInput(neutrino_msg_t& msg, int& val);
void addToPlaylist(CAudiofileExt &file); void addToPlaylist(CAudiofileExt &file);