Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2012-11-02 13:06:50 +0400
committerHendrik Leppkes <h.leppkes@gmail.com>2012-11-02 13:06:50 +0400
commit5e546db8914664a5a0b6b60bd00f0689b0d81273 (patch)
tree003758a9bb7268c4e2ab9dca4bff3ece3ed94201
parent224c816cf29c5243064e7047a96a16e7c6b12304 (diff)
Introduce a worker thread for image redraw.
Performing the image redraw from the main thread (which calls the DVD HLI function) will easily result in a deadlock. Instead, perform the redraw from a dedicated worker thread, which allows the main thread to release all locks and the app to remain functional.
-rw-r--r--decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp25
-rw-r--r--decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h6
2 files changed, 29 insertions, 2 deletions
diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp
index 7252d767..95c81d3a 100644
--- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp
+++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp
@@ -48,10 +48,15 @@ CLAVSubtitleConsumer::CLAVSubtitleConsumer(CLAVVideo *pLAVVideo)
context.name = TEXT(LAV_VIDEO);
context.version = TEXT(LAV_VERSION_STR);
m_evFrame.Reset();
+
+ CAMThread::Create();
}
CLAVSubtitleConsumer::~CLAVSubtitleConsumer(void)
{
+ CAMThread::CallWorker(CMD_EXIT);
+ CAMThread::Close();
+
if (m_pProvider) {
m_pProvider->Disconnect();
}
@@ -338,10 +343,28 @@ STDMETHODIMP CLAVSubtitleConsumer::ProcessSubtitleBitmap(LAVPixelFormat pixFmt,
STDMETHODIMP CLAVSubtitleConsumer::OnSubOptionSet(LPCSTR field)
{
if (strcmp(field, "redraw") == 0) {
- m_pLAVVideo->RedrawStillImage();
+ CAMThread::CallWorker(CMD_REDRAW);
} else if (strcmp(field, "menu") == 0) {
m_pLAVVideo->SetInDVDMenu(context.menu);
}
return S_OK;
}
+
+DWORD CLAVSubtitleConsumer::ThreadProc()
+{
+ DWORD cmd;
+ while(1) {
+ cmd = GetRequest();
+ switch(cmd) {
+ case CMD_EXIT:
+ Reply(S_OK);
+ return 0;
+ case CMD_REDRAW:
+ Reply(S_OK);
+ m_pLAVVideo->RedrawStillImage();
+ break;
+ }
+ }
+ return 1;
+}
diff --git a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h
index 1ad5fc36..cc64b855 100644
--- a/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h
+++ b/decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h
@@ -43,7 +43,7 @@ typedef struct LAVSubtitleConsumerContext {
class CLAVVideo;
-class CLAVSubtitleConsumer : public ISubRenderConsumer, public CSubRenderOptionsImpl, public CUnknown
+class CLAVSubtitleConsumer : public ISubRenderConsumer, public CSubRenderOptionsImpl, public CUnknown, protected CAMThread
{
public:
CLAVSubtitleConsumer(CLAVVideo *pLAVVideo);
@@ -69,6 +69,10 @@ public:
BOOL HasProvider() const { return m_pProvider != NULL; }
void SetVideoSize(LONG w, LONG h) { context.originalVideoSize.cx = w; context.originalVideoSize.cy = h; }
+
+protected:
+ DWORD ThreadProc();
+ enum {CMD_EXIT, CMD_REDRAW};
private:
STDMETHODIMP ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect, BYTE *videoData[4], int videoStride[4], RECT subRect, POINT subPosition, SIZE subSize, const uint8_t *rgbData, int pitch);