Changeset 5879:d014ed05a65f in roaraudio for include
- Timestamp:
- 01/25/13 03:17:45 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/services.h
r5836 r5879 39 39 #include "libroar.h" 40 40 41 enum roar_service_num { 42 // Error value in case any function returns this type. 43 // roar_error must be set on return. 44 ROAR_SERVICE_NUM_ERROR = -1, 45 #define ROAR_SERVICE_NUM_ERROR ROAR_SERVICE_NUM_ERROR 46 // reserved for future use. 47 ROAR_SERVICE_NUM_DEFAULT = 0, 48 //#define ROAR_SERVICE_NUM_DEFAULT ROAR_SERVICE_NUM_DEFAULT 49 // current number of objects. 50 ROAR_SERVICE_NUM_CURRENT = 1, 51 #define ROAR_SERVICE_NUM_CURRENT ROAR_SERVICE_NUM_CURRENT 52 // minumum number of objects. Optional. 53 ROAR_SERVICE_NUM_MIN, 54 #define ROAR_SERVICE_NUM_MIN ROAR_SERVICE_NUM_MIN 55 // maximum number of objects. Optional. 56 ROAR_SERVICE_NUM_MAX, 57 #define ROAR_SERVICE_NUM_MAX ROAR_SERVICE_NUM_MAX 58 // average number of objects. Optional. 59 ROAR_SERVICE_NUM_AVG, 60 #define ROAR_SERVICE_NUM_AVG ROAR_SERVICE_NUM_AVG 61 // Hint for buffer size used to list(). list() can still return 'buffer to short'. 62 ROAR_SERVICE_NUM_BUFFER, 63 #define ROAR_SERVICE_NUM_BUFFER ROAR_SERVICE_NUM_BUFFER 64 }; 65 41 66 // clients: 42 67 struct roar_client; 43 68 struct roar_service_clients { 69 // get list of client IDs. 70 // buffer is passed as ids, buffer size (in elements) is passed as len. 71 // returns the number of elements stored in ids or -1 on error. 44 72 ssize_t (*list)(int * ids, size_t len); 45 ssize_t (*num)(void); 73 // get the number of clients. See also comments above on what. 74 ssize_t (*num)(enum roar_service_num what); 75 // get a client by ID. The object returned is a copy and must not be motified. 46 76 int (*get)(int id, struct roar_client * client); 47 int (*kick)(int id); 77 // kick a client by ID. The reason for the kick is stored in error and msg. 78 // if msg is NULL it defaults to roar_error2str(error). 79 int (*kick)(int id, int error, const char * msg); 80 // return status of client as returned by CPI's status() callback. 81 int (*status)(int id); 82 83 // optional functions follow: 84 85 // set PID, UID and/or GID for client. 86 // if any ID is -1 the old value is not touched if clear is false. 87 // if clear is false IDs passed as -1 are reset to 'not set'. 88 // if altering IDs changes the permissions of a given client is up to the 89 // provider. 90 int (*set_ids)(int id, int clear, int pid, int uid, int gid); 91 // set the name of the client. 92 // the name is copied within this call so the bufer holding it can be freed. 93 int (*set_name)(int id, const char * name); 94 // this will change the protocol of the client. 95 int (*set_proto)(int id, int proto); 96 // this execes the stream. 97 // the stream must be owned by the client. 98 // if stream is -1 the client is execed. 99 // This will result in the client be completly reset to a state 100 // as directly after accept(). This must be followed by a call to set_proto(). 101 int (*exec)(int id, int stream); 48 102 }; 49 103 50 104 // streams: 51 105 struct roar_service_streams { 106 // get list of stream IDs. 107 // buffer is passed as ids, buffer size (in elements) is passed as len. 108 // returns the number of elements stored in ids or -1 on error. 52 109 ssize_t (*list)(int * ids, size_t len); 53 ssize_t (*num)(void); 54 int (*get)(int id, ...); 55 int (*kick)(int id); 110 // get the number of streams. See also comments above on what. 111 ssize_t (*num)(enum roar_service_num what); 112 // get a stream by ID. The object returned is a copy and must not be motified. 113 int (*get)(int id, struct roar_stream * s, struct roar_stream_info * info); 114 // kick a stream by ID. The reason for the kick is stored in error and msg. 115 // if msg is NULL it defaults to roar_error2str(error). 116 int (*kick)(int id, int error, const char * msg); 117 118 // optional functions follow: 119 120 // create a new stream. 121 // if parent is set to -1 a normal stream is created. 122 // if it is set to the ID of an existing stream it is created as child/virtual stream. 123 // if mixer is set to -1 the default mixer is used. 124 int (*new)(const struct roar_audio_info * info, int dir, int parent, int mixer); 125 // get the ID of the client owning the stream. 126 int (*get_client)(int id); 127 // set the owner of the stream. 128 // if the stream is already owned by a client it is moved if possible. 129 int (*set_client)(int id, int client); 130 // set role of stream. 131 // if role is passed as -1 the role is cleared. 132 int (*set_role)(int id, int role); 133 // alter stream flags. 134 int (*set_flag)(int id, uint32_t flags, int action); 135 // get name of stream. 136 // the buffer returned in *name must be freed using roar_mm_free(). 137 int (*get_name)(int id, char ** name); 138 // set name of stream. 139 // stream name will be copied so the buffer can be freed after this call. 140 // passing NULL will unset the stream name. 141 int (*set_name)(int id, const char * name); 142 // set volume and rpg settings. 143 // If mixer or rpg is NULL the corresponding setting is not touched. 144 // if both are NULL this does nothing. 145 int (*set_volume)(int id, const struct roar_mixer_settings * mixer, const struct roar_stream_rpg * rpg); 56 146 }; 57 147 … … 72 162 // prefs: 73 163 // procctl: 164 #define ROAR_SERVICE_PROCCTL_ERROR ((uint_least32_t)0xFFFFFFFFUL) 165 #define ROAR_SERVICE_PROCCTL_NONE ((uint_least32_t)0x00000000UL) 166 #define ROAR_SERVICE_PROCCTL_ALL ((uint_least32_t)0x7FFFFFFFUL) 167 #define ROAR_SERVICE_PROCCTL_CONFIG ((uint_least32_t)0x00000001UL) 168 #define ROAR_SERVICE_PROCCTL_LOGFILE ((uint_least32_t)0x00000002UL) 169 #define ROAR_SERVICE_PROCCTL_PIDFILE ((uint_least32_t)0x00000004UL) 170 74 171 struct roar_service_procctl { 172 // terminate the process. 173 // rv is the return POSIX return code. 174 // a value of zero means no error. 175 // a value smaller than zero is not allowed. 176 // all other values indicate some kind of error. 75 177 int (*exit)(int rv); 178 179 // optional functions follow: 180 181 // restart the process. 76 182 int (*restart)(void); 77 int (*reload)(int what); 183 // daemonize the process. 184 // the process is moved into background, detaching from the console. 78 185 int (*daemonize)(void); 79 int (*reopen)(int what); 186 // reload config or other parts. See above. 187 int (*reload)(uint_least32_t what); 188 // reopen logfiles or other parts. See above. 189 int (*reopen)(uint_least32_t what); 80 190 }; 81 191 … … 83 193 struct roar_service_queue { 84 194 ssize_t (*list)(int * ids, size_t len); 85 ssize_t (*num)( void);86 int (*get_name)(int id, char * buf, size_t len);195 ssize_t (*num)(enum roar_service_num what); 196 int (*get_name)(int id, char ** name); 87 197 // status? 88 198 int (*play)(int id);
Note: See TracChangeset
for help on using the changeset viewer.