summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-08-12 15:04:26 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-08-12 15:04:26 (GMT)
commita6834c1d08c294216460752b734a537586a740bb (patch)
tree4200d487cd0212f9907b9f6e359658ac9994f0f5
parente503f92019bf4ddb98c97e3c79e9a63c006ca0bd (diff)
day/month scheduling of different playlists
git-svn-id: svn://dyne.org/montevideo/ivysync@43 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--decoder.cpp21
-rw-r--r--utils.cpp12
-rw-r--r--utils.h2
3 files changed, 29 insertions, 6 deletions
diff --git a/decoder.cpp b/decoder.cpp
index 8f2004c..f7df7d8 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -318,6 +318,11 @@ bool Decoder::remove(int pos) {
}
int Decoder::load() {
+ // load the playlist from the .ivysync/ directory
+ // renders a date string of today in the format of DDMMM (12Aug)
+ // if the playlist .ivysync/DDMMM-videoNN is there load that one
+ // otherwise fallback on the .ivysync/videoNN playlist
+ // if that is not even there then we don't have a playlist.
FILE *fd;
char path[512];
char line[1024];
@@ -331,13 +336,19 @@ int Decoder::load() {
return -1;
}
- snprintf(path,511,"%s/.ivysync/video%u",home,device_num);
+ snprintf(path,511,"%s/.ivysync/%s-video%u",home,datemark(),device_num);
+ D("looking for time scheduled playlist of today: %s",path);
fd = fopen(path,"r");
- if(!fd) {
- E("can't load playlist %s: %s", path, strerror(errno));
- return -1;
+ if(!fd) { // today's playlist not found, go look for default one
+ snprintf(path,511,"%s/.ivysync/video%u",home,device_num);
+ fd = fopen(path,"r");
+ if(!fd) {
+ E("can't load playlist %s: %s", path, strerror(errno));
+ return -1;
+ }
}
- D("reading from configuration file %s",path);
+
+ A("reading from playlist file %s",path);
while( fgets(line,1023,fd) ) {
if( feof(fd) ) break;
diff --git a/utils.cpp b/utils.cpp
index 1e945d8..409238a 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -21,6 +21,7 @@
#include <cstdio>
#include <stdlib.h>
#include <stdarg.h>
+#include <time.h>
#include <utils.h>
@@ -127,8 +128,17 @@ void chomp(char *str) {
strncpy(str, tmp, MAX_CHOMP_SIZE);
}
+char *datemark() {
+ static char dm[7];
+ struct tm *tm;
+ time_t now;
-
+ now = time(NULL);
+ tm = localtime(&now);
+ strftime(dm,6,"%d%b",tm);
+ return(dm);
+}
+
#ifdef linux
#include <sched.h>
/* sets the process to "policy" policy, if max=1 then set at max priority,
diff --git a/utils.h b/utils.h
index df7ca37..6ac3039 100644
--- a/utils.h
+++ b/utils.h
@@ -34,6 +34,8 @@ void jsleep(int sec, long nsec);
void chomp(char *str);
+char *datemark();
+
bool set_rtpriority(bool max);
#endif