diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index e03621c76..3ef336473 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -86,6 +86,8 @@ CInfoViewerBB::CInfoViewerBB() pthread_detach(scrambledT); } #endif + hddperT = 0; + hddperTflag = false; Init(); } @@ -117,6 +119,10 @@ CInfoViewerBB::~CInfoViewerBB() pthread_cancel(scrambledT); scrambledT = 0; } + if(hddperT) { + pthread_cancel(hddperT); + hddperT = 0; + } } CInfoViewerBB* CInfoViewerBB::getInstance() @@ -589,28 +595,47 @@ void CInfoViewerBB::showIcon_Tuner() void CInfoViewerBB::showSysfsHdd() { - if ((g_settings.infobar_show_sysfs_hdd) && (is_visible)) { - long blocks_used; - struct statfs s; - int per = 0; - if (::statfs("/", &s) == 0 && s.f_blocks) { -// per = (s.f_blocks - s.f_bfree) / (s.f_blocks/100); - blocks_used = s.f_blocks - s.f_bfree; - per = (blocks_used * 100ULL) / s.f_blocks; + if (g_settings.infobar_show_sysfs_hdd) { + //sysFS info + int sysper = 0; + sysper = get_fs_usage("/"); + showBarSys(sysper); + + //HDD info in a seperate thread + if(!hddperTflag) { + hddperTflag=true; + pthread_create(&hddperT, NULL, hddperThread, (void*) this); + pthread_detach(hddperT); } - varscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth , 6, per, 100); - per = 0; - //HD info - if(!check_dir(g_settings.network_nfs_recordingdir)){ - if (::statfs(g_settings.network_nfs_recordingdir, &s) == 0 && s.f_blocks) { - blocks_used = s.f_blocks - s.f_bfree; - per = (blocks_used * 100ULL) / s.f_blocks; - } - } - hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2, hddwidth, 6, per, 100); } } +void* CInfoViewerBB::hddperThread(void *arg) +{ + CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; + + int hddper = 0; + hddper = get_fs_usage(g_settings.network_nfs_recordingdir); + infoViewerBB->showBarHdd(hddper); + + infoViewerBB->hddperTflag=false; + pthread_exit(NULL); +} + +void CInfoViewerBB::showBarSys(int percent) +{ + if (is_visible) + varscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 - 2 - 6, hddwidth, 6, percent, 100); +} + +void CInfoViewerBB::showBarHdd(int percent) +{ + if (percent < 0) + percent = 0; + if (is_visible) + hddscale->paintProgressBar(bbIconMinX, BBarY + InfoHeightY_Info / 2 + 2 + 0, hddwidth, 6, percent, 100); +} + void CInfoViewerBB::paint_ca_icons(int caid, char * icon, int &icon_space_offset) { char buf[20]; diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h index 349be1a7a..84353c6b9 100644 --- a/src/gui/infoviewer_bb.h +++ b/src/gui/infoviewer_bb.h @@ -121,6 +121,13 @@ class CInfoViewerBB static void* scrambledThread(void *arg); void scrambledCheck(bool force=false); + void showBarSys(int percent = 0); + void showBarHdd(int percent = 0); + + pthread_t hddperT; + static void* hddperThread(void *arg); + bool hddperTflag; + public: CInfoViewerBB(); ~CInfoViewerBB(); diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index ec730e2f8..334163f51 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -158,11 +158,11 @@ int safe_mkdir(char * path) return ret; } -int check_dir(const char * newdir) +int check_dir(const char * dir) { - - struct statfs s; - if (::statfs(newdir, &s) == 0) { + int ret = 0; + struct statfs s; + if (::statfs(dir, &s) == 0) { switch (s.f_type) /* f_type is long */ { case 0xEF53L: /*EXT2 & EXT3*/ @@ -174,12 +174,29 @@ int check_dir(const char * newdir) case 0x58465342L: /*xfs*/ case 0x4d44L: /*msdos*/ case 0x0187: /* AUTOFS_SUPER_MAGIC */ - case 0x858458f6: /*ramfs*/ - return 0;//ok + case 0x858458f6L: /*ramfs*/ + case 0x72b6L: /*jffs2*/ + break; //ok default: - fprintf( stderr,"%s Unknow File system type: %i\n",newdir ,s.f_type); - break; + fprintf(stderr, "%s Unknow File system type: %i\n" ,dir ,s.f_type); + ret = -1; + break; // error } } - return 1; // error + return ret; +} + +int get_fs_usage(const char * dir) +{ + int ret = check_dir(dir); + long blocks_used; + struct statfs s; + + if (ret == 0) { + if (::statfs(dir, &s) == 0 && s.f_blocks) { + blocks_used = s.f_blocks - s.f_bfree; + ret = (blocks_used * 100ULL) / s.f_blocks; + } + } + return ret; } diff --git a/src/system/helpers.h b/src/system/helpers.h index 6b6b31ddc..ee1a09f8a 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -28,8 +28,9 @@ int my_system(const char * cmd); FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type); int safe_mkdir(char * path); -int check_dir(const char * newdir); bool file_exists(const char *filename); void wakeup_hdd(const char *hdd_dir); +int check_dir(const char * dir); +int get_fs_usage(const char * dir); #endif