From: John Janus Date: Wed, 20 Sep 2017 06:18:05 +0000 (+0200) Subject: small changes and service file for pi X-Git-Url: https://git.johnzone.org/?a=commitdiff_plain;h=77d655c526a3c394cb8aa1045b6ac234d4401b9e;p=FakeRadio.git small changes and service file for pi --- diff --git a/fakeradio.service b/fakeradio.service new file mode 100644 index 0000000..bfdcffa --- /dev/null +++ b/fakeradio.service @@ -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 diff --git a/mp3player.c b/mp3player.c index 5e91ba6..2b5b7d8 100644 --- a/mp3player.c +++ b/mp3player.c @@ -4,10 +4,10 @@ #include #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; } diff --git a/mp3player.h b/mp3player.h index ae3dfdf..5217cdd 100644 --- a/mp3player.h +++ b/mp3player.h @@ -1,9 +1,10 @@ #ifndef _MY_MP3PLAYER #define _MY_MP3PLAYER #include +#include -pthread_t startPlayThread(const char*); +pthread_t startPlayThread(const char*, bool); -void* playFunc(void*); +void* playFunc(void*, bool); #endif diff --git a/simple_try.c b/simple_try.c index 64c0bcd..01b021b 100644 --- a/simple_try.c +++ b/simple_try.c @@ -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);