From cb2b5c9df1be6a46cf87144eefddaecf48c2f752 Mon Sep 17 00:00:00 2001 From: BPanther Date: Mon, 19 Aug 2024 06:50:42 +0200 Subject: [PATCH] option for min size of record directory added (default 16 GB, 0 = off) --- data/locale/deutsch.locale | 2 ++ data/locale/english.locale | 2 ++ src/driver/record.cpp | 7 ++++++- src/gui/record_setup.cpp | 5 +++++ src/neutrino.cpp | 2 ++ src/system/helpers.cpp | 27 ++++++++++++++++++++++++++- src/system/helpers.h | 1 + src/system/locals.h | 2 ++ src/system/locals_intern.h | 2 ++ src/system/settings.h | 1 + 10 files changed, 49 insertions(+), 2 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 2ac714ba4..7d67dceb8 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -2116,6 +2116,7 @@ rclock.title Fernbedienung sperren rclock.unlockmsg Fernbedienung reaktiviert recording.already_found %s\nwurde bereits gefunden. Trotzdem aufnehmen? recording.already_found_check Prüfe Aufnahmen +recording.error Aufnahme nicht möglich.\nZu wenig Speicher (%llu GB), min. %llu GB frei erforderlich! recording.failed Aufzeichnung ist fehlgeschlagen! recording.is_running Folgende Aufnahme läuft bereits! Neue Aufnahme starten? recording.start Starte Aufnahme, bitte warten ... @@ -2132,6 +2133,7 @@ recordingmenu.apids_std Standard Tonspur aufnehmen recordingmenu.auto_cover Autom. Film-Vorschaubild recordingmenu.data_pids Daten-Spuren recordingmenu.defdir Aufnahmeverzeichnis +recordingmenu.dirsize Minimale Größe des Aufnahmeverzeichnisses (0=aus) recordingmenu.dvbsub_pids Untertitel aufnehmen recordingmenu.end_of_recording_epg EPG aktuelles Event recordingmenu.end_of_recording_max max. Aufnahmezeit diff --git a/data/locale/english.locale b/data/locale/english.locale index f4c10fd27..8cc7161f7 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -2116,6 +2116,7 @@ rclock.title Lock remote control rclock.unlockmsg Remote control unlocked recording.already_found %s\nwas already found. Nevertheless start record? recording.already_found_check Check recordings +recording.error Recording not possible.\nNo or space to low (%llu GB), min. %llu GB needed! recording.failed Recording failed! recording.is_running This channel already recording. Start new record? recording.start Start recording, please wait ... @@ -2132,6 +2133,7 @@ recordingmenu.apids_std record standard stream recordingmenu.auto_cover Auto-thumbnail recordingmenu.data_pids Data streams recordingmenu.defdir Recording directory +recordingmenu.dirsize Minimal size recording directory (0=off) recordingmenu.dvbsub_pids record dvbsub stream recordingmenu.end_of_recording_epg EPG act. Event recordingmenu.end_of_recording_max max. Recordingtime diff --git a/src/driver/record.cpp b/src/driver/record.cpp index fc5382a38..cdfe696a9 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -49,7 +49,6 @@ #include #include - #include #ifdef ENABLE_GRAPHLCD #include @@ -1137,6 +1136,9 @@ int CRecordManager::GetRecordMode(const t_channel_id channel_id) bool CRecordManager::Record(const t_channel_id channel_id, const char *dir, bool timeshift) { + if (!check_recdir(g_settings.network_nfs_recordingdir, g_settings.record_dirsize)) + return false; + CTimerd::RecordingInfo eventinfo; CEPGData epgData; @@ -1167,6 +1169,9 @@ bool CRecordManager::Record(const t_channel_id channel_id, const char *dir, bool bool CRecordManager::Record(const CTimerd::RecordingInfo *const eventinfo, const char *dir, bool timeshift) { + if (!check_recdir(g_settings.network_nfs_recordingdir, g_settings.record_dirsize)) + return false; + CRecordInstance *inst = NULL; record_error_msg_t error_msg = RECORD_OK; /* for now, empty eventinfo.recordingDir means this is direct record, FIXME better way ? diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 734741802..ba01c7e26 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -179,6 +179,11 @@ int CRecordSetup::showRecordSetup() fRecDir->setHint("", LOCALE_MENU_HINT_RECORD_DIR); recordingSettings->addItem(fRecDir); + //min. record dir size + CMenuOptionNumberChooser * rds = new CMenuOptionNumberChooser(LOCALE_RECORDINGMENU_DIRSIZE, &g_settings.record_dirsize, true, 0, 64, NULL); + rds->setNumberFormat("%d GB"); + recordingSettings->addItem(rds); + CMenuOptionChooser* channel_rec_dir = new CMenuOptionChooser(LOCALE_RECORDINGMENU_SAVE_IN_CHANNELDIR, &g_settings.recording_save_in_channeldir, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); channel_rec_dir->setHint("", LOCALE_MENU_HINT_RECORD_CHANDIR); recordingSettings->addItem(channel_rec_dir); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 5abea4ab8..a24dd215c 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -794,6 +794,7 @@ if (g_info.hw_caps->can_shutdown) g_settings.recording_stream_subtitle_pids = configfile.getBool("recordingmenu.stream_subtitle_pids", true); g_settings.recording_stream_pmt_pid = configfile.getBool("recordingmenu.stream_pmt_pid" , false); g_settings.recording_filename_template = configfile.getString("recordingmenu.filename_template" , "%C_%T_%d_%t"); + g_settings.record_dirsize = configfile.getInt32("record_dirsize", 16); #if HAVE_SH4_HARDWARE || HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE g_settings.recording_bufsize = configfile.getInt32("recording_bufsize", 4); g_settings.recording_bufsize_dmx = configfile.getInt32("recording_bufsize_dmx", 2); @@ -1541,6 +1542,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool ("recordingmenu.stream_subtitle_pids" , g_settings.recording_stream_subtitle_pids ); configfile.setBool ("recordingmenu.stream_pmt_pid" , g_settings.recording_stream_pmt_pid ); configfile.setString("recordingmenu.filename_template" , g_settings.recording_filename_template ); + configfile.getInt32 ("record_dirsize" , g_settings.record_dirsize ); #if HAVE_SH4_HARDWARE || HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE configfile.setInt32 ("recording_bufsize" , g_settings.recording_bufsize); configfile.setInt32 ("recording_bufsize_dmx" , g_settings.recording_bufsize_dmx); diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index a2043720e..e990f136a 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -52,6 +52,7 @@ #include #include //#include +#include #include #include #include @@ -98,7 +99,7 @@ bool file_exists(const char *filename) } } -void wakeup_hdd(const char *hdd_dir) +void wakeup_hdd(const char *hdd_dir) { if (!check_dir(hdd_dir) && hdd_get_standby(hdd_dir)) { @@ -394,6 +395,30 @@ bool get_mem_usage(unsigned long &kbtotal, unsigned long &kbfree) return true; } +bool check_recdir(std::string recdir, uint64_t minfree) +{ + if (minfree == 0) + return true; + + uint64_t recfree = 0; + struct statfs s; + if (::statfs(recdir.c_str(), &s) == 0) + { + if (s.f_blocks > 0) + recfree = s.f_bfree * s.f_bsize / 1024 / 1024 / 1024; + if (recfree < minfree) + { + char errmsg[512] = ""; + sprintf(errmsg, g_Locale->getText(LOCALE_RECORDING_ERROR), recfree, minfree); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, errmsg, CMsgBox::mbrOk, CMsgBox::mbOk, NEUTRINO_ICON_ERROR); + return false; + } + else + return true; + } + return false; +} + std::string find_executable(const char *name) { struct stat s; diff --git a/src/system/helpers.h b/src/system/helpers.h index 8e3ca731f..a6e65d8bc 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -62,6 +62,7 @@ bool get_fs_usage(const char *dir, uint64_t &btotal, uint64_t &bused, long *bsiz bool get_mem_usage(unsigned long &total, unsigned long &free); int mySleep(int sec); +bool check_recdir(std::string recdir, uint64_t minfree = 16); std::string find_executable(const char *name); bool exec_controlscript(std::string script); /* basically what "foo=`command`" does in the shell */ diff --git a/src/system/locals.h b/src/system/locals.h index c5016b24c..e4083677c 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -2143,6 +2143,7 @@ typedef enum LOCALE_RCLOCK_UNLOCKMSG, LOCALE_RECORDING_ALREADY_FOUND, LOCALE_RECORDING_ALREADY_FOUND_CHECK, + LOCALE_RECORDING_ERROR, LOCALE_RECORDING_FAILED, LOCALE_RECORDING_IS_RUNNING, LOCALE_RECORDING_START, @@ -2159,6 +2160,7 @@ typedef enum LOCALE_RECORDINGMENU_AUTO_COVER, LOCALE_RECORDINGMENU_DATA_PIDS, LOCALE_RECORDINGMENU_DEFDIR, + LOCALE_RECORDINGMENU_DIRSIZE, LOCALE_RECORDINGMENU_DVBSUB_PIDS, LOCALE_RECORDINGMENU_END_OF_RECORDING_EPG, LOCALE_RECORDINGMENU_END_OF_RECORDING_MAX, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index f96325097..286846834 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -2143,6 +2143,7 @@ const char *locale_real_names[] = "rclock.unlockmsg", "recording.already_found", "recording.already_found_check", + "recording.error", "recording.failed", "recording.is_running", "recording.start", @@ -2159,6 +2160,7 @@ const char *locale_real_names[] = "recordingmenu.auto_cover", "recordingmenu.data_pids", "recordingmenu.defdir", + "recordingmenu.dirsize", "recordingmenu.dvbsub_pids", "recordingmenu.end_of_recording_epg", "recordingmenu.end_of_recording_max", diff --git a/src/system/settings.h b/src/system/settings.h index 3b0d1f3c1..5a19724a3 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -515,6 +515,7 @@ struct SNeutrinoSettings int recording_stream_vtxt_pid; int recording_stream_subtitle_pids; int recording_stream_pmt_pid; + int record_dirsize; #if HAVE_SH4_HARDWARE || HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE int recording_bufsize; int recording_bufsize_dmx;