Changeset 3392:842c8d8f99a9 in roaraudio for libroarpulse
- Timestamp:
- 02/11/10 14:57:22 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroarpulse/context.c
r3391 r3392 56 56 char * name; 57 57 int state; 58 int errnum; 58 59 struct { 59 60 struct _roar_pa_cb_st set_name; … … 87 88 c->state = PA_CONTEXT_UNCONNECTED; 88 89 90 c->errnum = PA_OK; 91 89 92 return NULL; 90 93 } … … 123 126 return -1; 124 127 125 if ( c->state != PA_CONTEXT_UNCONNECTED ) 126 return -1; 128 if ( c->state != PA_CONTEXT_UNCONNECTED ) { 129 c->errnum = PA_ERR_BADSTATE; 130 pa_context_set_state(c, PA_CONTEXT_FAILED); 131 return -1; 132 } 127 133 128 134 // we do currently not support to spawn a daemon, so we ignore flags and api. … … 132 138 if ( roar_simple_connect(&(c->con), (char*)server, 133 139 c->name != NULL ? c->name : "libroarpulse [pa_context_connect()]") == -1 ) { 140 c->errnum = PA_ERR_CONNECTIONREFUSED; 134 141 pa_context_set_state(c, PA_CONTEXT_FAILED); 135 142 return -1; … … 177 184 178 185 /** Return the error number of the last failed operation */ 179 int pa_context_errno(pa_context *c); 186 int pa_context_errno(pa_context *c) { 187 if ( c == NULL ) 188 return PA_ERR_INVALID; 189 190 return c->errnum; 191 } 180 192 181 193 /** Return non-zero if some data is pending to be written to the connection */ … … 204 216 * complete succesfully, since the daemon probably died before 205 217 * returning a success notification */ 206 pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb, void *userdata); 218 pa_operation* pa_context_exit_daemon(pa_context *c, pa_context_success_cb_t cb, void *userdata) { 219 int s = 1; 220 221 if ( c == NULL ) 222 return NULL; 223 224 if ( c->state == PA_CONTEXT_READY ) { 225 if ( roar_exit(&(c->con)) == -1 ) { 226 c->errnum = PA_ERR_INTERNAL; 227 s = 0; 228 } 229 } else { 230 c->errnum = PA_ERR_BADSTATE; 231 s = 0; 232 } 233 234 if ( cb != NULL ) 235 cb(c, s, userdata); 236 237 return NULL; 238 } 207 239 208 240 /** Set the name of the default sink. \since 0.4 */ 209 241 pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) { 242 if ( c != NULL ) 243 c->errnum = PA_ERR_NOTSUPPORTED; 244 210 245 if ( cb != NULL ) 211 246 cb(c, 0, userdata); … … 216 251 /** Set the name of the default source. \since 0.4 */ 217 252 pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata) { 253 if ( c != NULL ) 254 c->errnum = PA_ERR_NOTSUPPORTED; 255 218 256 if ( cb != NULL ) 219 257 cb(c, 0, userdata); … … 239 277 return NULL; 240 278 241 if ( c->state != PA_CONTEXT_UNCONNECTED ) 242 return NULL; 279 if ( c->state != PA_CONTEXT_UNCONNECTED ) { 280 c->errnum = PA_ERR_BADSTATE; 281 282 if ( cb != NULL ) 283 cb(c, 0, userdata); 284 285 return NULL; 286 } 243 287 244 288 c->name = roar_mm_strdup(name);
Note: See TracChangeset
for help on using the changeset viewer.