mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 17:01:08 +02:00
CScreenSaver: add class CScreenSaver
Origin commit data
------------------
Branch: ni/coolstream
Commit: 6a23a1c36a
Author: defans <defans@bluepeercrew.us>
Date: 2014-12-29 (Mon, 29 Dec 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -97,6 +97,7 @@ libneutrino_gui_a_SOURCES = \
|
||||
record_setup.cpp \
|
||||
scan.cpp \
|
||||
scan_setup.cpp \
|
||||
screensaver.cpp \
|
||||
screensetup.cpp \
|
||||
settings_manager.cpp \
|
||||
sleeptimer.cpp \
|
||||
|
@@ -65,7 +65,7 @@
|
||||
#include <gui/widget/stringinput.h>
|
||||
#include <gui/widget/stringinput_ext.h>
|
||||
#include <gui/widget/keyboard_input.h>
|
||||
|
||||
#include <gui/screensaver.h>
|
||||
#include "gui/pictureviewer.h"
|
||||
extern CPictureViewer * g_PicViewer;
|
||||
|
||||
@@ -172,7 +172,6 @@ CAudioPlayerGui::CAudioPlayerGui(bool inetmode)
|
||||
|
||||
void CAudioPlayerGui::Init(void)
|
||||
{
|
||||
stimer = 0;
|
||||
m_selected = 0;
|
||||
m_metainfo.clear();
|
||||
|
||||
@@ -329,8 +328,6 @@ int CAudioPlayerGui::show()
|
||||
neutrino_msg_t msg;
|
||||
neutrino_msg_data_t data;
|
||||
|
||||
int pic_index = 0;
|
||||
|
||||
int ret = menu_return::RETURN_REPAINT;
|
||||
|
||||
// clear whole screen
|
||||
@@ -378,28 +375,8 @@ int CAudioPlayerGui::show()
|
||||
{
|
||||
int timeout = time(NULL) - m_idletime;
|
||||
int screensaver_timeout = g_settings.audioplayer_screensaver;
|
||||
if (screensaver_timeout !=0 && timeout > screensaver_timeout*60 && !m_screensaver)
|
||||
if (screensaver_timeout != 0 && timeout > screensaver_timeout*60 && !m_screensaver)
|
||||
screensaver(true);
|
||||
|
||||
if (msg == NeutrinoMessages::EVT_TIMER && data == stimer) {
|
||||
if (m_screensaver) {
|
||||
char fname[255];
|
||||
|
||||
sprintf(fname, "%s/mp3-%d.jpg", DATADIR "/neutrino/icons", pic_index);
|
||||
|
||||
int lret = access(fname, F_OK);
|
||||
printf("CAudioPlayerGui::show: new pic %s: %s\n", fname, lret ? "not found" : "found");
|
||||
if (lret == 0) {
|
||||
pic_index++;
|
||||
videoDecoder->StopPicture();
|
||||
videoDecoder->ShowPicture(fname);
|
||||
} else if (pic_index) {
|
||||
pic_index = 0;
|
||||
}
|
||||
} else
|
||||
pic_index = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2224,18 +2201,16 @@ void CAudioPlayerGui::paintLCD()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CAudioPlayerGui::screensaver(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
m_screensaver = true;
|
||||
m_frameBuffer->Clear();
|
||||
stimer = g_RCInput->addTimer(10*1000*1000, false);
|
||||
CScreenSaver::getInstance()->Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_RCInput->killTimer(stimer);
|
||||
CScreenSaver::getInstance()->Stop();
|
||||
m_screensaver = false;
|
||||
videoDecoder->StopPicture();
|
||||
videoDecoder->ShowPicture(DATADIR "/neutrino/icons/mp3.jpg");
|
||||
|
@@ -140,7 +140,6 @@ class CAudioPlayerGui : public CMenuTarget
|
||||
int m_idletime;
|
||||
bool m_screensaver;
|
||||
bool m_inetmode;
|
||||
uint32_t stimer;
|
||||
CComponentsDetailLine *dline;
|
||||
CComponentsInfoBox *ibox;
|
||||
|
||||
|
193
src/gui/screensaver.cpp
Normal file
193
src/gui/screensaver.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
Copyright (C) 2012-2013 defans@bluepeercrew.us
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include <pthread.h>
|
||||
#include <algorithm> // std::sort
|
||||
#include <ctype.h>
|
||||
#include "audiomute.h"
|
||||
#include "screensaver.h"
|
||||
|
||||
#include <video.h>
|
||||
extern cVideo * videoDecoder;
|
||||
|
||||
|
||||
CScreenSaver::CScreenSaver()
|
||||
{
|
||||
thrScreenSaver = 0;
|
||||
m_frameBuffer = CFrameBuffer::getInstance();
|
||||
index = 0;
|
||||
}
|
||||
|
||||
CScreenSaver::~CScreenSaver()
|
||||
{
|
||||
if(thrScreenSaver)
|
||||
pthread_cancel(thrScreenSaver);
|
||||
thrScreenSaver = 0;
|
||||
}
|
||||
|
||||
|
||||
CScreenSaver* CScreenSaver::getInstance()
|
||||
{
|
||||
static CScreenSaver * screenSaver = NULL;
|
||||
if (!screenSaver)
|
||||
screenSaver = new CScreenSaver();
|
||||
|
||||
return screenSaver;
|
||||
}
|
||||
|
||||
|
||||
void CScreenSaver::Start()
|
||||
{
|
||||
CAudioMute::getInstance()->enableMuteIcon(false);
|
||||
|
||||
if(!thrScreenSaver)
|
||||
{
|
||||
//printf("[%s] %s: starting thread\n", __FILE__, __FUNCTION__);
|
||||
pthread_create(&thrScreenSaver, NULL, ScreenSaverPrg, (void*) this);
|
||||
pthread_detach(thrScreenSaver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CScreenSaver::Stop()
|
||||
{
|
||||
if(thrScreenSaver)
|
||||
{
|
||||
pthread_cancel(thrScreenSaver);
|
||||
thrScreenSaver = 0;
|
||||
}
|
||||
|
||||
if(thrScreenSaver)
|
||||
pthread_cancel(thrScreenSaver);
|
||||
thrScreenSaver = 0;
|
||||
|
||||
CAudioMute::getInstance()->enableMuteIcon(true);
|
||||
}
|
||||
|
||||
void* CScreenSaver::ScreenSaverPrg(void* arg)
|
||||
{
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
||||
|
||||
CScreenSaver * PScreenSaver = static_cast<CScreenSaver*>(arg);
|
||||
|
||||
PScreenSaver->ReadDir(); //TODO kill Screensaver if false
|
||||
PScreenSaver->m_frameBuffer->Clear();
|
||||
|
||||
while(1)
|
||||
{
|
||||
PScreenSaver->PaintPicture();
|
||||
sleep(10);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CScreenSaver::ReadDir()
|
||||
{
|
||||
char* dir_name = (char *) g_settings.screensaver_dir.c_str();
|
||||
struct dirent *dirpointer;
|
||||
DIR *dir;
|
||||
char curr_ext[5];
|
||||
int curr_lenght;
|
||||
char* p;
|
||||
bool ret = false;
|
||||
|
||||
v_bg_files.clear();
|
||||
|
||||
/* open dir */
|
||||
if((dir=opendir(dir_name)) == NULL) {
|
||||
fprintf(stderr,"[CScreenSaver] Error opendir ...\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* read complete dir */
|
||||
while((dirpointer=readdir(dir)) != NULL)
|
||||
{
|
||||
curr_lenght = strlen((*dirpointer).d_name);
|
||||
string str = dir_name;
|
||||
// printf("%d\n",curr_lenght);
|
||||
if(curr_lenght > 4)
|
||||
{
|
||||
strncpy(curr_ext,(*dirpointer).d_name+(curr_lenght-4),5);
|
||||
|
||||
for (p = curr_ext; *p; ++p)
|
||||
*p = (char)tolower(*p);
|
||||
// printf("%s\n",curr_ext);
|
||||
|
||||
if((strcmp(".jpg",curr_ext))
|
||||
//|| (strcmp(".png",curr_ext))
|
||||
//|| (strcmp(".bmp",curr_ext))
|
||||
)
|
||||
continue;
|
||||
|
||||
str += "/";
|
||||
str += (*dirpointer).d_name;
|
||||
v_bg_files.push_back(str);
|
||||
}
|
||||
}
|
||||
|
||||
sort(v_bg_files.begin(), v_bg_files.end());
|
||||
|
||||
/* close pointer */
|
||||
if(closedir(dir) == -1)
|
||||
printf("[CScreenSaver] Error no closed %s\n", dir_name);
|
||||
|
||||
if(!v_bg_files.empty())
|
||||
ret = true;
|
||||
else
|
||||
printf("[CScreenSaver] no picture found\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void CScreenSaver::PaintPicture()
|
||||
{
|
||||
if(v_bg_files.empty())
|
||||
return;
|
||||
|
||||
if( (index >= v_bg_files.size()) || (access(v_bg_files.at(index).c_str(), F_OK)) )
|
||||
{
|
||||
ReadDir();
|
||||
index = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
printf("[CScreenSaver] ShowPicture: %s\n", v_bg_files.at(index).c_str());
|
||||
videoDecoder->StopPicture();
|
||||
videoDecoder->ShowPicture(v_bg_files.at(index).c_str());
|
||||
index++;
|
||||
|
||||
if(index == v_bg_files.size())
|
||||
index = 0;
|
||||
}
|
55
src/gui/screensaver.h
Normal file
55
src/gui/screensaver.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Neutrino-GUI - DBoxII-Project
|
||||
|
||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
Copyright (C) 2012-2013 defans@bluepeercrew.us
|
||||
|
||||
License: GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CSCREENSAVER_H__
|
||||
#define __CSCREENSAVER_H__
|
||||
|
||||
#include <driver/framebuffer.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CScreenSaver
|
||||
{
|
||||
private:
|
||||
CFrameBuffer *m_frameBuffer;
|
||||
pthread_t thrScreenSaver;
|
||||
static void* ScreenSaverPrg(void *arg);
|
||||
vector<string> v_bg_files;
|
||||
unsigned int index;
|
||||
|
||||
bool ReadDir();
|
||||
void PaintPicture();
|
||||
|
||||
public:
|
||||
CScreenSaver();
|
||||
~CScreenSaver();
|
||||
static CScreenSaver* getInstance();
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
};
|
||||
|
||||
#endif // __CSCREENSAVER_H__
|
Reference in New Issue
Block a user