infoviewer_bb.cpp,h: fix determination of hdd-usage in thread

Origin commit data
------------------
Commit: 24ffee6bb2
Author: defans <defans@bluepeercrew.us>
Date: 2012-11-06 (Tue, 06 Nov 2012)

Origin message was:
------------------
- infoviewer_bb.cpp,h: fix determination of hdd-usage in thread
This commit is contained in:
defans
2012-11-06 22:05:45 +01:00
committed by vanhofen
parent 8549bf695d
commit 5678d88b81
2 changed files with 17 additions and 13 deletions

View File

@@ -87,6 +87,7 @@ CInfoViewerBB::CInfoViewerBB()
pthread_detach(scrambledT); pthread_detach(scrambledT);
} }
#endif #endif
hddpercent = 0;
hddperT = 0; hddperT = 0;
hddperTflag = false; hddperTflag = false;
bbIconInfo[0].x = 0; bbIconInfo[0].x = 0;
@@ -612,20 +613,17 @@ void CInfoViewerBB::showSysfsHdd()
percent = (u * 100ULL) / t; percent = (u * 100ULL) / t;
showBarSys(percent); showBarSys(percent);
#if 0
//HDD info in a seperate thread //HDD info in a seperate thread
if(!hddperTflag) { if(!hddperTflag) {
hddperTflag=true; hddperTflag=true;
pthread_create(&hddperT, NULL, hddperThread, (void*) this); pthread_create(&hddperT, NULL, hddperThread, (void*) this);
pthread_detach(hddperT); pthread_detach(hddperT);
} }
#else
if (!check_dir(g_settings.network_nfs_recordingdir)) { if (check_dir(g_settings.network_nfs_recordingdir) == 0)
if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) showBarHdd(hddpercent);
percent = (u * 100ULL) / t; else
showBarHdd(percent); showBarHdd(-1);
}
#endif
} }
} }
@@ -633,11 +631,10 @@ void* CInfoViewerBB::hddperThread(void *arg)
{ {
CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg;
int percent = 0; infoViewerBB->hddpercent = 0;
long t, u; long t, u;
if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u))
percent = (u * 100ULL) / t; infoViewerBB->hddpercent = (u * 100ULL) / t;
infoViewerBB->showBarHdd(percent);
infoViewerBB->hddperTflag=false; infoViewerBB->hddperTflag=false;
pthread_exit(NULL); pthread_exit(NULL);
@@ -651,8 +648,14 @@ void CInfoViewerBB::showBarSys(int percent)
void CInfoViewerBB::showBarHdd(int percent) void CInfoViewerBB::showBarHdd(int percent)
{ {
if (is_visible) if (is_visible) {
hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); 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) void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset)

View File

@@ -124,6 +124,7 @@ class CInfoViewerBB
void showBarSys(int percent = 0); void showBarSys(int percent = 0);
void showBarHdd(int percent = 0); void showBarHdd(int percent = 0);
int hddpercent;
pthread_t hddperT; pthread_t hddperT;
static void* hddperThread(void *arg); static void* hddperThread(void *arg);
bool hddperTflag; bool hddperTflag;