summaryrefslogtreecommitdiff
path: root/displayvolume.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2012-12-05 21:06:52 +0100
committerlouis <louis.braun@gmx.de>2012-12-05 21:06:52 +0100
commit5dff51292c2d08b38db010dfe291c1e829e1945f (patch)
tree080b36357be6465827ab667ddaba9516ac345f1a /displayvolume.c
parent85b83b42ae87dff1ce984a88779d03698978460b (diff)
downloadskin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.gz
skin-nopacity-5dff51292c2d08b38db010dfe291c1e829e1945f.tar.bz2
Fix Ticket 1147, cancelling threads in a safer way
Diffstat (limited to 'displayvolume.c')
-rw-r--r--displayvolume.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/displayvolume.c b/displayvolume.c
index 46eba0c..ae541bd 100644
--- a/displayvolume.c
+++ b/displayvolume.c
@@ -45,6 +45,9 @@ cNopacityDisplayVolume::cNopacityDisplayVolume(void) {
}
cNopacityDisplayVolume::~cNopacityDisplayVolume() {
+ Cancel(-1);
+ while (Active())
+ cCondWait::SleepMs(10);
osd->DestroyPixmap(pixmapBackgroundTop);
osd->DestroyPixmap(pixmapBackgroundBottom);
osd->DestroyPixmap(pixmapLabel);
@@ -114,7 +117,7 @@ tColor cNopacityDisplayVolume::DrawProgressbarBackground(int left, int top, int
void cNopacityDisplayVolume::Flush(void) {
if (initial)
- if (FadeTime)
+ if (config.volumeFadeTime)
Start();
initial = false;
osd->Flush();
@@ -122,21 +125,22 @@ void cNopacityDisplayVolume::Flush(void) {
void cNopacityDisplayVolume::Action(void) {
uint64_t Start = cTimeMs::Now();
- while (true) {
+ while (Running()) {
uint64_t Now = cTimeMs::Now();
cPixmap::Lock();
double t = min(double(Now - Start) / FadeTime, 1.0);
- int Alpha = t * ALPHA_OPAQUE;
+ int Alpha = t * ALPHA_OPAQUE;
pixmapBackgroundTop->SetAlpha(Alpha);
pixmapBackgroundBottom->SetAlpha(Alpha);
pixmapProgressBar->SetAlpha(Alpha);
pixmapLabel->SetAlpha(Alpha);
- osd->Flush();
+ if (Running())
+ osd->Flush();
cPixmap::Unlock();
- int Delta = cTimeMs::Now() - Now;
- if (Delta < FrameTime)
- cCondWait::SleepMs(FrameTime - Delta);
+ int Delta = cTimeMs::Now() - Now;
+ if (Running() && (Delta < FrameTime))
+ cCondWait::SleepMs(FrameTime - Delta);
if ((int)(Now - Start) > FadeTime)
break;
- }
+ }
}