]> Johnzone git - FakeRadio.git/commitdiff
small changes and service file for pi
authorJohn Janus <mail@johnzone.org>
Wed, 20 Sep 2017 06:18:05 +0000 (08:18 +0200)
committerJohn Janus <mail@johnzone.org>
Wed, 20 Sep 2017 06:18:05 +0000 (08:18 +0200)
fakeradio.service [new file with mode: 0644]
mp3player.c
mp3player.h
simple_try.c

diff --git a/fakeradio.service b/fakeradio.service
new file mode 100644 (file)
index 0000000..bfdcffa
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=A fake radio
+
+[Service]
+Type=simple
+WorkingDirectory=/home/pi/devel/FakeRadio
+ExecStart=/home/pi/devel/FakeRadio/fakeradio
+
+[Install]
+WantedBy=multi-user.target
index 5e91ba62eedda5e24a4ea90f178e15501045e131..2b5b7d8ce9d1344af04826d11bc4083519a62ad1 100644 (file)
@@ -4,10 +4,10 @@
 #include <mpg123.h>
 #define BITS 8
 
-pthread_t startPlayThread(const char* file)
+pthread_t startPlayThread(const char* file, bool loop)
 {
     pthread_t thread;
-    pthread_create(&thread, NULL, playFunc, (void*) file);
+    pthread_create(&thread, NULL, playFunc, (void*) file, loop);
     return thread;
 }
 
index ae3dfdf36ac7616fbbe934fe72b5b68d52c1d620..5217cdd52e8b701673839a35dd81e00f0511ff3f 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef _MY_MP3PLAYER
 #define _MY_MP3PLAYER
 #include <pthread.h>
+#include <stdbool.h>
 
-pthread_t startPlayThread(const char*);
+pthread_t startPlayThread(const char*, bool);
 
-void* playFunc(void*);
+void* playFunc(void*, bool);
 
 #endif
index 64c0bcd4f0eb4bad0560eb5d7cbc753f3fd2bc2c..01b021b900820ef80b9debe403aabf292f4e2cd1 100644 (file)
@@ -120,7 +120,7 @@ int main(void) {
             digitalWrite(CHNL2LED, HIGH);
             chnl1=true;
             if (intro) {
-                playThread = startPlayThread("intro.mp3");
+                playThread = startPlayThread("intro.mp3", true);
                 digitalWrite(INTROLED, LOW);
             } else {
                 digitalWrite(INTROLED, HIGH);
@@ -131,11 +131,11 @@ int main(void) {
             if (chnl1) {
                 digitalWrite(CHNL1LED, LOW);
                 digitalWrite(CHNL2LED, HIGH);
-                playThread = startPlayThread("platt01.mp3");
+                playThread = startPlayThread("platt01.mp3",false);
             } else {
                 digitalWrite(CHNL2LED, LOW);
                 digitalWrite(CHNL1LED, HIGH);
-                playThread = startPlayThread("dansk01.mp3");
+                playThread = startPlayThread("dansk01.mp3",false);
             }
         }
         delay(500);