CC = gcc
CFLAGS = -std=gnu11 -Wall
-LDFLAGS = -lpthread -lao -lmpg123
-fakeradio: simple_try.c
- $(CC) $(CFLAGS) -o ledtest simple_try.c $(LDFLAGS)
+LDFLAGS = -lpthread -lao -lmpg123 -lwiringPi
+fakeradio: main.o mp3player.o
+ $(CC) $(CFLAGS) -o fakeradio main.o mp3player.o $(LDFLAGS)
+
+main.o: simple_try.c
+ $(CC) $(CFLAGS) -o main.o simple_try.c $(LDFLAGS)
mp3player.o: mp3player.h mp3player.c
$(CC) $(CFLAGS) -o mp3player.o mp3player.c $(LDFLAGS)
-mp3test: mp3player.o
- $(CC) $(CFLAGS) -o mp3test mp3player.o $(LDFLAGS)
#include "mp3player.h"
#include <stdbool.h>
+#include <ao/ao.h>
+#include <mpg123.h>
#define BITS 8
pthread_t startPlayThread(const char* file)
-#ifndef MP3PLAYER
-#define MP3PLAYER
+#ifndef _MY_MP3PLAYER
+#define _MY_MP3PLAYER
#include <pthread.h>
-#include <mpg123.h>
-#include <ao/ao.h>
-#include <stdio.h>
-#include <stdlib.h>
-pthread_t startPlayThread(const char* file);
+pthread_t startPlayThread(const char*);
-void* playFunc(void* file);
+void* playFunc(void*);
#endif
#include <signal.h>
#include <unistd.h>
#include <pthread.h>
+
#include "mp3player.h"
#define PWRLED 8
pinMode(CHNL1LED, OUTPUT);
pinMode(CHNL2LED, OUTPUT);
- printf("initialize mutex and condition variable");
+ printf("initialize mutex and condition variable\n");
mut = malloc (sizeof(pthread_mutex_t));
pthread_mutex_init(mut, NULL);
wakeup = malloc(sizeof(pthread_cond_t));
playThread = startPlayThread("dansk01.mp3");
}
}
+ delay(500);
pthread_mutex_unlock(mut);
}