moved access to cControl to main thread to avoid crash in onpauseview

This commit is contained in:
louis 2015-03-19 16:31:39 +01:00
parent 19dfd1af7b
commit db54050b5e
5 changed files with 22 additions and 12 deletions

View File

@ -1,4 +1,5 @@
#define __STL_CONFIG_H
#include <vdr/player.h>
#include "displayreplay.h"
cSDDisplayReplay::cSDDisplayReplay(cTemplate *replayTemplate, bool ModeOnly) {
@ -41,7 +42,14 @@ void cSDDisplayReplay::SetMode(bool Play, bool Forward, int Speed) {
if (!doOutput)
return;
if (!Play && Speed < 0) {
replayView->DrawOnPause(modeOnly);
string recFileName = "";
cControl *control = cControl::Control();
if (control) {
const cRecording *recording = control->GetRecording();
if (recording && recording->FileName())
recFileName = recording->FileName();
}
replayView->DrawOnPause(recFileName, modeOnly);
} else {
replayView->ClearOnPause();
}

View File

@ -1,8 +1,8 @@
#define __STL_CONFIG_H
#include <vdr/player.h>
#include "displayreplayonpauseview.h"
cDisplayReplayOnPauseView::cDisplayReplayOnPauseView(cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
cDisplayReplayOnPauseView::cDisplayReplayOnPauseView(string recFileName, cTemplateViewElement *tmplViewElement) : cView(tmplViewElement) {
this->recFileName = recFileName;
tmplViewElement->SetPixOffset(0);
delay = tmplViewElement->GetNumericParameter(ptDelay) * 1000;
SetFadeTime(tmplViewElement->GetNumericParameter(ptFadeTime));
@ -18,11 +18,10 @@ void cDisplayReplayOnPauseView::Render(void) {
map < string, string > stringTokens;
map < string, int > intTokens;
map < string, vector< map< string, string > > > loopTokens;
const cRecording *recording = NULL;
cControl *control = cControl::Control();
if (control) {
recording = control->GetRecording();
}
if (recFileName.size() == 0)
return;
const cRecording *recording = new cRecording(recFileName.c_str());
if (recording) {
string name = recording->Name() ? recording->Name() : "";
stringTokens.insert(pair<string,string>("name", name));
@ -81,6 +80,8 @@ void cDisplayReplayOnPauseView::Render(void) {
}
SetScraperTokens(NULL, recording, stringTokens, intTokens, loopTokens);
DrawViewElement(veOnPause, &stringTokens, &intTokens, &loopTokens);
if (recording)
delete recording;
}
void cDisplayReplayOnPauseView::Action(void) {

View File

@ -9,9 +9,10 @@ class cDisplayReplayOnPauseView : public cView, public cViewHelpers {
private:
int delay;
bool resetSleep;
string recFileName;
virtual void Action(void);
public:
cDisplayReplayOnPauseView(cTemplateViewElement *tmplViewElement);
cDisplayReplayOnPauseView(string recFileName, cTemplateViewElement *tmplViewElement);
virtual ~cDisplayReplayOnPauseView();
void ResetSleep(void) { resetSleep = true; };
void Render(void);

View File

@ -376,12 +376,12 @@ void cDisplayReplayView::DrawMessage(eMessageType type, const char *text) {
DrawViewElement(veMessage, &stringTokens, &intTokens);
}
void cDisplayReplayView::DrawOnPause(bool modeOnly) {
void cDisplayReplayView::DrawOnPause(string recFileName, bool modeOnly) {
eViewElement veTmplOnPause = modeOnly ? veOnPauseModeOnly : veOnPause;
cTemplateViewElement *tmplOnPause = tmplView->GetViewElement(veTmplOnPause);
if (!tmplOnPause)
return;
onPauseView = new cDisplayReplayOnPauseView(tmplOnPause);
onPauseView = new cDisplayReplayOnPauseView(recFileName, tmplOnPause);
onPauseView->Start();
}

View File

@ -32,7 +32,7 @@ public:
void DrawControlIcons(bool play, bool forward, int speed, bool modeOnly);
void DrawJump(const char *jump);
void DrawMessage(eMessageType type, const char *text);
void DrawOnPause(bool modeOnly);
void DrawOnPause(string recFileName, bool modeOnly);
void ClearOnPause(void);
void DelayOnPause(void);
void DrawCustomTokens(void);