sad

simple audio daemon
git clone git://git.2f30.org/sad.git
Log | Files | Refs | LICENSE

sad.h (2503B)


      1 #ifdef COMPAT
      2 #include "compat.h"
      3 #endif
      4 
      5 #define LEN(x) (sizeof (x) / sizeof *(x))
      6 #define PROTOCOLVERSION "0.0"
      7 
      8 typedef struct {
      9 	char  *name;
     10 	void (*fn)(int, char *);
     11 } Cmd;
     12 
     13 enum {
     14 	NONE,
     15 	PREPARE,
     16 	PLAYING,
     17 	PAUSED
     18 };
     19 
     20 enum {
     21 	REPEAT = 1 << 0,
     22 	RANDOM = 1 << 1,
     23 	SINGLE = 1 << 2
     24 };
     25 
     26 enum {
     27 	EVSONGFINISHED,
     28 };
     29 
     30 typedef struct {
     31 	unsigned int bits;
     32 	unsigned int rate;
     33 	unsigned int channels;
     34 } Format;
     35 
     36 typedef struct {
     37 	int (*open)(Format *, const char *);
     38 	int (*decode)(void *, int);
     39 	int (*close)(void);
     40 } Decoder;
     41 
     42 typedef struct {
     43 	int (*vol)(int);
     44 	int (*open)(Format *);
     45 	int (*play)(void *, size_t);
     46 	int (*close)(void);
     47 } Output;
     48 
     49 typedef struct {
     50 	char     path[PATH_MAX];
     51 	int      id;
     52 	int      state;
     53 	Decoder *decoder;
     54 	Format   fmt;
     55 } Song;
     56 
     57 typedef struct {
     58 	Song **songs;
     59 	Song  *cursong;
     60 	size_t nsongs;
     61 	size_t maxsongs;
     62 	int    mode;
     63 } Playlist;
     64 
     65 typedef struct {
     66 	int   event;
     67 	char *name;
     68 } Eventdesc;
     69 
     70 /* sad.c */
     71 extern fd_set   master;
     72 extern fd_set   rfds;
     73 extern int      fdmax;
     74 
     75 /* cmd.c */
     76 int docmd(int);
     77 
     78 /* playlist.c */
     79 Song *addplaylist(const char *);
     80 int rmplaylist(int);
     81 Song *findsong(const char *);
     82 Song *findsongid(int);
     83 Song *getnextsong(void);
     84 Song *getprevsong(void);
     85 Song *getcursong(void);
     86 void putcursong(Song *);
     87 void dumpplaylist(int);
     88 void clearplaylist(void);
     89 Song *picknextsong(void);
     90 void playsong(Song *);
     91 void stopsong(Song *);
     92 void playlistmode(int);
     93 int getplaylistmode(void);
     94 int searchplaylist(int, const char *);
     95 
     96 /* wav.c */
     97 extern Decoder wavdecoder;
     98 
     99 /* mp3.c */
    100 extern Decoder mp3decoder;
    101 
    102 /* vorbis.c */
    103 extern Decoder vorbisdecoder;
    104 
    105 /* sndio.c */
    106 extern Output sndiooutput;
    107 
    108 /* alsa.c */
    109 extern Output alsaoutput;
    110 
    111 /* fifo.c */
    112 extern Output fifooutput;
    113 
    114 /* tokenizer.c */
    115 int gettokens(char *, char **, int, char *);
    116 int tokenize(char *, char **, int);
    117 
    118 /* decoder.c */
    119 Decoder *matchdecoder(const char *);
    120 
    121 /* output.c */
    122 int initoutputs(void);
    123 int initresamplers(Format *);
    124 int openoutputs(void);
    125 int closeoutputs(void);
    126 int enableoutput(const char *);
    127 int disableoutput(const char *);
    128 int playoutputs(Format *, void *, size_t);
    129 int setvol(int);
    130 
    131 /* notify.c */
    132 extern Eventdesc Eventmap[];
    133 
    134 int initnotifier(void);
    135 int addsubscriber(int, int);
    136 int addsubscribername(int, const char *);
    137 int notify(int);
    138 void removesubscriber(int);
    139 
    140 /* pcm.c */
    141 void s16monotostereo(short *, short *, size_t);
    142 void s16stereotomono(short *, short *, size_t);
    143 void s16tofloat(short *, float *, size_t);
    144 void floattos16(float *, short *, size_t);