sad

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

sad.h (2631B)


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