From 24ffee6bb213a87c07cd373383e7edcd355e3682 Mon Sep 17 00:00:00 2001 From: "svenhoefer, snafed" Date: Tue, 6 Nov 2012 22:05:45 +0100 Subject: [PATCH] - infoviewer_bb.cpp,h: fix determination of hdd-usage in thread --- src/gui/infoviewer_bb.cpp | 29 ++++++++++++++++------------- src/gui/infoviewer_bb.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index b6036c647..cf033a766 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -87,6 +87,7 @@ CInfoViewerBB::CInfoViewerBB() pthread_detach(scrambledT); } #endif + hddpercent = 0; hddperT = 0; hddperTflag = false; bbIconInfo[0].x = 0; @@ -612,20 +613,17 @@ void CInfoViewerBB::showSysfsHdd() percent = (u * 100ULL) / t; showBarSys(percent); -#if 0 //HDD info in a seperate thread if(!hddperTflag) { hddperTflag=true; pthread_create(&hddperT, NULL, hddperThread, (void*) this); pthread_detach(hddperT); } -#else - if (!check_dir(g_settings.network_nfs_recordingdir)) { - if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) - percent = (u * 100ULL) / t; - showBarHdd(percent); - } -#endif + + if (check_dir(g_settings.network_nfs_recordingdir) == 0) + showBarHdd(hddpercent); + else + showBarHdd(-1); } } @@ -633,11 +631,10 @@ void* CInfoViewerBB::hddperThread(void *arg) { CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; - int percent = 0; + infoViewerBB->hddpercent = 0; long t, u; if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) - percent = (u * 100ULL) / t; - infoViewerBB->showBarHdd(percent); + infoViewerBB->hddpercent = (u * 100ULL) / t; infoViewerBB->hddperTflag=false; pthread_exit(NULL); @@ -651,8 +648,14 @@ void CInfoViewerBB::showBarSys(int percent) void CInfoViewerBB::showBarHdd(int percent) { - if (is_visible) - hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); + if (is_visible) { + if (percent >= 0) + hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); + else { + frameBuffer->paintBoxRel(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, COL_INFOBAR_BUTTONS_BACKGROUND); + hddscale->reset(); + } + } } void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset) diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index 41bb17cb0..d5f4230c5 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -124,6 +124,7 @@ class CInfoViewerBB void showBarSys(int percent = 0); void showBarHdd(int percent = 0); + int hddpercent; pthread_t hddperT; static void* hddperThread(void *arg); bool hddperTflag;