Skip to content

Commit

Permalink
option for min size of record directory added (default 16 GB, 0 = off)
Browse files Browse the repository at this point in the history
  • Loading branch information
BPanther committed Aug 19, 2024
1 parent 280d7d1 commit cb2b5c9
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/locale/deutsch.locale
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions data/locale/english.locale
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/driver/record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include <system/fsmounter.h>
#include <system/helpers.h>


#include <driver/record.h>
#ifdef ENABLE_GRAPHLCD
#include <driver/nglcd.h>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 ?
Expand Down
5 changes: 5 additions & 0 deletions src/gui/record_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/neutrino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
27 changes: 26 additions & 1 deletion src/system/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <neutrino.h>
#include <driver/fontrenderer.h>
//#include <driver/framebuffer.h>
#include <gui/widget/msgbox.h>
#include <system/helpers.h>
#include <system/helpers-json.h>
#include <driver/framebuffer.h>
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/system/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 2 additions & 0 deletions src/system/locals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/system/locals_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/system/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cb2b5c9

Please sign in to comment.