summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-09-25 11:00:57 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-09-25 11:00:57 +0200
commit9e8aac388237e7afff6cae5bbf5ee08756633f53 (patch)
tree33df2762c84b7c0981c06cb557097be0080eda1b /menu.c
parent83985eff479b0a287b747160b33458de38b10732 (diff)
downloadvdr-9e8aac388237e7afff6cae5bbf5ee08756633f53.tar.gz
vdr-9e8aac388237e7afff6cae5bbf5ee08756633f53.tar.bz2
The list of recordings is now read in a separate thread
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c74
1 files changed, 47 insertions, 27 deletions
diff --git a/menu.c b/menu.c
index 9709212d..ce415ea3 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.359 2005/09/03 11:42:27 kls Exp $
+ * $Id: menu.c 1.360 2005/09/25 09:45:01 kls Exp $
*/
#include "menu.h"
@@ -1506,35 +1506,12 @@ cMenuRecordings::cMenuRecordings(const char *Base, int Level, bool OpenSubMenus)
{
base = Base ? strdup(Base) : NULL;
level = Setup.RecordingDirs ? Level : -1;
+ Recordings.StateChanged(recordingsState); // just to get the current state
Display(); // this keeps the higher level menus from showing up briefly when pressing 'Back' during replay
- const char *LastReplayed = cReplayControl::LastReplayed();
- cMenuRecordingItem *LastItem = NULL;
- char *LastItemText = NULL;
- if (!Base)
- Recordings.Sort();
- for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
- if (!Base || (strstr(recording->Name(), Base) == recording->Name() && recording->Name()[strlen(Base)] == '~')) {
- cMenuRecordingItem *Item = new cMenuRecordingItem(recording, level);
- if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) {
- Add(Item);
- LastItem = Item;
- free(LastItemText);
- LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
- }
- else
- delete Item;
- if (LastItem) {
- if (LastReplayed && strcmp(LastReplayed, recording->FileName()) == 0)
- SetCurrent(LastItem);
- if (LastItem->IsDirectory())
- LastItem->IncrementCounter(recording->IsNew());
- }
- }
- }
- free(LastItemText);
+ Set();
if (Current() < 0)
SetCurrent(First());
- else if (OpenSubMenus && Open(true))
+ else if (OpenSubMenus && cReplayControl::LastReplayed() && Open(true))
return;
SetHelpKeys();
}
@@ -1570,6 +1547,45 @@ void cMenuRecordings::SetHelpKeys(void)
}
}
+void cMenuRecordings::Set(bool Refresh)
+{
+ const char *CurrentRecording = cReplayControl::LastReplayed();
+ cMenuRecordingItem *LastItem = NULL;
+ char *LastItemText = NULL;
+ cThreadLock RecordingsLock(&Recordings);
+ if (Refresh) {
+ cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
+ if (ri) {
+ cRecording *Recording = GetRecording(ri);
+ if (Recording)
+ CurrentRecording = Recording->FileName();
+ }
+ }
+ Clear();
+ Recordings.Sort();
+ for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) {
+ if (!base || (strstr(recording->Name(), base) == recording->Name() && recording->Name()[strlen(base)] == '~')) {
+ cMenuRecordingItem *Item = new cMenuRecordingItem(recording, level);
+ if (*Item->Text() && (!LastItem || strcmp(Item->Text(), LastItemText) != 0)) {
+ Add(Item);
+ LastItem = Item;
+ free(LastItemText);
+ LastItemText = strdup(LastItem->Text()); // must use a copy because of the counters!
+ }
+ else
+ delete Item;
+ if (LastItem) {
+ if (CurrentRecording && strcmp(CurrentRecording, recording->FileName()) == 0)
+ SetCurrent(LastItem);
+ if (LastItem->IsDirectory())
+ LastItem->IncrementCounter(recording->IsNew());
+ }
+ }
+ }
+ free(LastItemText);
+ Display();
+}
+
cRecording *cMenuRecordings::GetRecording(cMenuRecordingItem *Item)
{
cRecording *recording = Recordings.GetByName(Item->FileName());
@@ -1716,6 +1732,9 @@ eOSState cMenuRecordings::ProcessKey(eKeys Key)
case kYellow: return Delete();
case kBlue: return Info();
case k1...k9: return Commands(Key);
+ case kNone: if (Recordings.StateChanged(recordingsState))
+ Set(true);
+ break;
default: break;
}
}
@@ -2597,6 +2616,7 @@ static void SetTrackDescriptions(bool Live)
}
}
else if (cReplayControl::LastReplayed()) {
+ cThreadLock RecordingsLock(&Recordings);
cRecording *Recording = Recordings.GetByName(cReplayControl::LastReplayed());
if (Recording)
Components = Recording->Info()->Components();