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