From bcd8da8b1a3d02a90b3c9c8ca73d8b26760bb219 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 27 Jul 2022 20:58:28 -0400 Subject: libmoc our previous attempt ran into issues where we have two loops, a GUI loop and the MOC loop. I rewrote this into lib_moc which has it's own thread that manages the MOC socket connection and exposes the interface to a client program via a moc object. all you need to do is call moc_init(); Pretty cool, still runs into issues regarding autoconnect and some other problems. --- moc_library.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 moc_library.h (limited to 'moc_library.h') diff --git a/moc_library.h b/moc_library.h new file mode 100644 index 0000000..60a9c09 --- /dev/null +++ b/moc_library.h @@ -0,0 +1,47 @@ +#include +#include +#include //Header file for sleep(). man 3 sleep for details. +#include + +#include +#include +#include + + +/* Flags for the info decoder function. */ +enum tags_select +{ + TAGS_COMMENTS = 0x01, /* artist, title, etc. */ + TAGS_TIME = 0x02 /* time of the file. */ +}; + +enum moc_state { + STOPPED, + PLAYING, + PAUSED +}; + +enum moc_status { + INITIALIZING, + CONNECTED, + FAILED_TO_CONNECT, + ERROR +}; + +struct moc { + pthread_mutex_t lock; + enum moc_status status; + enum moc_state state; + + char *filename; + char *title; + char *album; + char *artist; + int track; + int time; + int filled; +}; + +extern const char * moc_str_state(enum moc_state s); +extern struct moc * moc_init(); + -- cgit v1.2.3