- add keys to control the audioplayer from pictureviewer

decode and view pictures in a seperate thread.
This commit is contained in:
defans
2012-11-30 22:06:27 +01:00
committed by svenhoefer
parent 91abca7d30
commit 031db7bae1
7 changed files with 131 additions and 12 deletions

View File

@@ -1452,6 +1452,12 @@ pictureviewer.help20 Sortierung andern
pictureviewer.help21 Bild unskaliert einlesen pictureviewer.help21 Bild unskaliert einlesen
pictureviewer.help22 Modus verlassen pictureviewer.help22 Modus verlassen
pictureviewer.help3 Sortierung andern pictureviewer.help3 Sortierung andern
pictureviewer.help30 Audioplayer-Modus
pictureviewer.help31 Startet die Wiedergabe
pictureviewer.help32 Pausiert die Wiedergabe
pictureviewer.help33 Stoppt die Wiedergabe
pictureviewer.help34 nächster Titel
pictureviewer.help35 vorheriger Titel
pictureviewer.help4 Bild unskaliert einlesen pictureviewer.help4 Bild unskaliert einlesen
pictureviewer.help5 Diashow-Modus pictureviewer.help5 Diashow-Modus
pictureviewer.help6 vorheriges Bild pictureviewer.help6 vorheriges Bild

View File

@@ -1452,6 +1452,12 @@ pictureviewer.help20 change sort order
pictureviewer.help21 reread image (no scaling) pictureviewer.help21 reread image (no scaling)
pictureviewer.help22 exit pictureviewer.help22 exit
pictureviewer.help3 change sort order pictureviewer.help3 change sort order
pictureviewer.help30 audioplayer mode
pictureviewer.help31 starts the playback
pictureviewer.help32 pauses the playback
pictureviewer.help33 stops the playback
pictureviewer.help34 next title
pictureviewer.help35 previous title
pictureviewer.help4 do not scale picture pictureviewer.help4 do not scale picture
pictureviewer.help5 diashow mode pictureviewer.help5 diashow mode
pictureviewer.help6 previous image pictureviewer.help6 previous image

View File

@@ -159,9 +159,6 @@ class CAudioPlayerGui : public CMenuTarget
CFileFilter audiofilefilter; CFileFilter audiofilefilter;
void paintItemID3DetailsLine (int pos); void paintItemID3DetailsLine (int pos);
void clearItemID3DetailsLine (); void clearItemID3DetailsLine ();
void play(unsigned int pos);
void stop();
void pause();
void ff(unsigned int seconds=0); void ff(unsigned int seconds=0);
void rev(unsigned int seconds=0); void rev(unsigned int seconds=0);
int getNext(); int getNext();
@@ -248,8 +245,6 @@ class CAudioPlayerGui : public CMenuTarget
bool openSCbrowser(void); bool openSCbrowser(void);
bool clearPlaylist(void); bool clearPlaylist(void);
bool shufflePlaylist(void); bool shufflePlaylist(void);
bool playNext(bool allow_rotate = false);
bool playPrev(bool allow_rotate = false);
bool pictureviewer; bool pictureviewer;
@@ -260,6 +255,12 @@ class CAudioPlayerGui : public CMenuTarget
int exec(CMenuTarget* parent, const std::string & actionKey); int exec(CMenuTarget* parent, const std::string & actionKey);
void wantNextPlay(); void wantNextPlay();
void pause();
void play(unsigned int pos);
void stop();
bool playNext(bool allow_rotate = false);
bool playPrev(bool allow_rotate = false);
int getAdioPayerM_currend() {return m_current;}
}; };

View File

@@ -101,6 +101,9 @@ CPictureViewerGui::CPictureViewerGui()
picture_filter.addFilter("jpeg"); picture_filter.addFilter("jpeg");
picture_filter.addFilter("gif"); picture_filter.addFilter("gif");
picture_filter.addFilter("crw"); picture_filter.addFilter("crw");
decodeT = 0;
decodeTflag = false;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@@ -109,6 +112,12 @@ CPictureViewerGui::~CPictureViewerGui()
{ {
playlist.clear(); playlist.clear();
delete m_viewer; delete m_viewer;
if (decodeT)
{
pthread_cancel(decodeT);
decodeT = 0;
}
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@@ -225,6 +234,9 @@ int CPictureViewerGui::show()
bool loop=true; bool loop=true;
bool update=true; bool update=true;
if (audioplayer)
m_currentTitle = m_audioPlayer->getAdioPayerM_currend();
while (loop) while (loop)
{ {
if (update) if (update)
@@ -544,6 +556,35 @@ int CPictureViewerGui::show()
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_PICTUREVIEWER_HEAD)); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_PICTUREVIEWER_HEAD));
} }
} }
else if (((msg==CRCInput::RC_plus) || (msg==CRCInput::RC_minus)) && decodeTflag)
{
// FIXME: do not accept volume-keys while decoding
}
// control keys for audioplayer
else if (audioplayer && msg==CRCInput::RC_pause)
{
m_currentTitle = m_audioPlayer->getAdioPayerM_currend();
m_audioPlayer->pause();
}
else if (audioplayer && msg==CRCInput::RC_stop)
{
m_currentTitle = m_audioPlayer->getAdioPayerM_currend();
m_audioPlayer->stop();
}
else if (audioplayer && msg==CRCInput::RC_play)
{
m_currentTitle = m_audioPlayer->getAdioPayerM_currend();
if (m_currentTitle > -1)
m_audioPlayer->play((unsigned int)m_currentTitle);
}
else if (audioplayer && msg==CRCInput::RC_forward)
{
m_audioPlayer->playNext();
}
else if (audioplayer && msg==CRCInput::RC_rewind)
{
m_audioPlayer->playPrev();
}
else if (msg == NeutrinoMessages::CHANGEMODE) else if (msg == NeutrinoMessages::CHANGEMODE)
{ {
if ((data & NeutrinoMessages::mode_mask) !=NeutrinoMessages::mode_pic) if ((data & NeutrinoMessages::mode_mask) !=NeutrinoMessages::mode_pic)
@@ -726,6 +767,10 @@ void CPictureViewerGui::paint()
void CPictureViewerGui::view(unsigned int index, bool unscaled) void CPictureViewerGui::view(unsigned int index, bool unscaled)
{ {
if (decodeTflag)
return;
m_unscaled = unscaled;
selected=index; selected=index;
CVFD::getInstance()->showMenuText(0, playlist[index].Name.c_str()); CVFD::getInstance()->showMenuText(0, playlist[index].Name.c_str());
@@ -733,26 +778,59 @@ void CPictureViewerGui::view(unsigned int index, bool unscaled)
strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&playlist[index].Date)); strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&playlist[index].Date));
//CVFD::getInstance()->showMenuText(1, timestring); //FIXME //CVFD::getInstance()->showMenuText(1, timestring); //FIXME
if (unscaled) if (m_state==MENU)
m_viewer->DecodeImage(playlist[index].Filename, true, unscaled); m_state=VIEW;
m_viewer->ShowImage(playlist[index].Filename, unscaled);
//decode and view in a seperate thread
if (!decodeTflag) {
decodeTflag=true;
pthread_create(&decodeT, NULL, decodeThread, (void*) this);
pthread_detach(decodeT);
}
}
void* CPictureViewerGui::decodeThread(void *arg)
{
CPictureViewerGui *PictureViewerGui = (CPictureViewerGui*) arg;
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
PictureViewerGui->thrView();
PictureViewerGui->decodeTflag=false;
pthread_exit(NULL);
}
void CPictureViewerGui::thrView()
{
if (m_unscaled)
m_viewer->DecodeImage(playlist[selected].Filename, true, m_unscaled);
m_viewer->ShowImage(playlist[selected].Filename, m_unscaled);
#if 0
//Decode next //Decode next
unsigned int next=selected+1; unsigned int next=selected+1;
if (next > playlist.size()-1) if (next > playlist.size()-1)
next=0; next=0;
if (m_state==MENU)
m_state=VIEW;
if (m_state==VIEW) if (m_state==VIEW)
m_viewer->DecodeImage(playlist[next].Filename,true); m_viewer->DecodeImage(playlist[next].Filename,true);
else else
m_viewer->DecodeImage(playlist[next].Filename,false); m_viewer->DecodeImage(playlist[next].Filename,false);
#endif
} }
void CPictureViewerGui::endView() void CPictureViewerGui::endView()
{ {
if (m_state != MENU) if (m_state != MENU)
m_state=MENU; m_state=MENU;
if (decodeTflag)
{
decodeTflag=false;
pthread_cancel(decodeT);
}
} }
void CPictureViewerGui::deletePicFile(unsigned int index, bool mode) void CPictureViewerGui::deletePicFile(unsigned int index, bool mode)
@@ -798,8 +876,16 @@ void CPictureViewerGui::showHelp()
helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP20)); helpbox.addLine(NEUTRINO_ICON_BUTTON_5, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP20));
helpbox.addLine(NEUTRINO_ICON_BUTTON_0, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP21)); helpbox.addLine(NEUTRINO_ICON_BUTTON_0, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP21));
helpbox.addLine(NEUTRINO_ICON_BUTTON_HOME, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP22)); helpbox.addLine(NEUTRINO_ICON_BUTTON_HOME, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP22));
if(audioplayer)
helpbox.addLine("Version: $Revision: 1.57 $"); {
helpbox.addPagebreak();
helpbox.addLine(g_Locale->getText(LOCALE_PICTUREVIEWER_HELP30));
helpbox.addLine(NEUTRINO_ICON_BUTTON_PLAY, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP31));
helpbox.addLine(NEUTRINO_ICON_BUTTON_PAUSE, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP32));
helpbox.addLine(NEUTRINO_ICON_BUTTON_STOP, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP33));
helpbox.addLine(NEUTRINO_ICON_BUTTON_FORWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP34));
helpbox.addLine(NEUTRINO_ICON_BUTTON_BACKWARD, g_Locale->getText(LOCALE_PICTUREVIEWER_HELP35));
}
hide(); hide();
helpbox.show(LOCALE_MESSAGEBOX_INFO); helpbox.show(LOCALE_MESSAGEBOX_INFO);
} }

View File

@@ -111,6 +111,14 @@ class CPictureViewerGui : public CMenuTarget
void deletePicFile(unsigned int index, bool mode); void deletePicFile(unsigned int index, bool mode);
bool audioplayer; bool audioplayer;
int m_currentTitle;
pthread_t decodeT;
static void* decodeThread(void *arg);
bool decodeTflag;
void thrView();
bool m_unscaled;
public: public:
CPictureViewerGui(); CPictureViewerGui();

View File

@@ -1479,6 +1479,12 @@ typedef enum
LOCALE_PICTUREVIEWER_HELP21, LOCALE_PICTUREVIEWER_HELP21,
LOCALE_PICTUREVIEWER_HELP22, LOCALE_PICTUREVIEWER_HELP22,
LOCALE_PICTUREVIEWER_HELP3, LOCALE_PICTUREVIEWER_HELP3,
LOCALE_PICTUREVIEWER_HELP30,
LOCALE_PICTUREVIEWER_HELP31,
LOCALE_PICTUREVIEWER_HELP32,
LOCALE_PICTUREVIEWER_HELP33,
LOCALE_PICTUREVIEWER_HELP34,
LOCALE_PICTUREVIEWER_HELP35,
LOCALE_PICTUREVIEWER_HELP4, LOCALE_PICTUREVIEWER_HELP4,
LOCALE_PICTUREVIEWER_HELP5, LOCALE_PICTUREVIEWER_HELP5,
LOCALE_PICTUREVIEWER_HELP6, LOCALE_PICTUREVIEWER_HELP6,

View File

@@ -1479,6 +1479,12 @@ const char * locale_real_names[] =
"pictureviewer.help21", "pictureviewer.help21",
"pictureviewer.help22", "pictureviewer.help22",
"pictureviewer.help3", "pictureviewer.help3",
"pictureviewer.help30",
"pictureviewer.help31",
"pictureviewer.help32",
"pictureviewer.help33",
"pictureviewer.help34",
"pictureviewer.help35",
"pictureviewer.help4", "pictureviewer.help4",
"pictureviewer.help5", "pictureviewer.help5",
"pictureviewer.help6", "pictureviewer.help6",