Changeset 5ffcbaf in mainline
- Timestamp:
- 2013-04-03T17:29:11Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eafc7b2
- Parents:
- 35ab943
- Location:
- uspace/srv/audio/hound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/hound.c
r35ab943 r5ffcbaf 97 97 if (!ctx) 98 98 return EINVAL; 99 fibril_mutex_lock(&hound->list_guard); 99 100 list_append(&ctx->link, &hound->contexts); 100 101 //TODO register sinks/sources 102 fibril_mutex_unlock(&hound->list_guard); 101 103 return EOK; 102 104 } … … 107 109 if (!ctx) 108 110 return EINVAL; 111 fibril_mutex_lock(&hound->list_guard); 109 112 list_remove(&ctx->link); 113 fibril_mutex_unlock(&hound->list_guard); 110 114 return EOK; 111 115 } … … 115 119 assert(hound); 116 120 117 //TODO locking118 121 fibril_mutex_lock(&hound->list_guard); 122 hound_ctx_t *res = NULL; 119 123 list_foreach(hound->contexts, it) { 120 124 hound_ctx_t *ctx = hound_ctx_from_link(it); 121 if (hound_ctx_get_id(ctx) == id) 122 return ctx; 123 } 124 return NULL; 125 if (hound_ctx_get_id(ctx) == id) { 126 res = ctx; 127 break; 128 } 129 } 130 fibril_mutex_unlock(&hound->list_guard); 131 return res; 125 132 } 126 133 … … 263 270 } 264 271 272 int hound_list_sources(hound_t *hound, const char ***list, size_t *size) 273 { 274 assert(hound); 275 if (!list || !size) 276 return EINVAL; 277 278 fibril_mutex_lock(&hound->list_guard); 279 const size_t count = list_count(&hound->sources); 280 if (count == 0) { 281 *list = NULL; 282 *size = 0; 283 fibril_mutex_unlock(&hound->list_guard); 284 return EOK; 285 } 286 const char **names = calloc(count, sizeof(char *)); 287 int ret = names ? EOK : ENOMEM; 288 for (size_t i = 0; i < count && ret == EOK; ++i) { 289 link_t *slink = list_nth(&hound->sources, i); 290 audio_source_t *source = audio_source_list_instance(slink); 291 names[i] = str_dup(source->name); 292 if (names[i]) 293 ret = ENOMEM; 294 } 295 if (ret == EOK) { 296 *size = count; 297 *list = names; 298 } else { 299 for (size_t i = 0; i < count; ++i) 300 free(names[i]); 301 free(names); 302 } 303 fibril_mutex_unlock(&hound->list_guard); 304 return ret; 305 } 306 307 int hound_list_sinks(hound_t *hound, const char ***list, size_t *size) 308 { 309 assert(hound); 310 log_verbose("Hound list sinks: %p %p %p", hound, list, size); 311 if (!list || !size) 312 return EINVAL; 313 314 fibril_mutex_lock(&hound->list_guard); 315 const size_t count = list_count(&hound->sinks); 316 if (count == 0) { 317 printf("ZERO SINKS!\n"); 318 *list = NULL; 319 *size = 0; 320 fibril_mutex_unlock(&hound->list_guard); 321 return EOK; 322 } 323 const char **names = calloc(count, sizeof(char *)); 324 int ret = names ? EOK : ENOMEM; 325 for (size_t i = 0; i < count && ret == EOK; ++i) { 326 link_t *slink = list_nth(&hound->sinks, i); 327 audio_sink_t *sink = audio_sink_list_instance(slink); 328 names[i] = str_dup(sink->name); 329 if (!names[i]) 330 ret = ENOMEM; 331 } 332 if (ret == EOK) { 333 *size = count; 334 *list = names; 335 printf("%zu SINKS %s!\n", count, names[0]); 336 } else { 337 for (size_t i = 0; i < count; ++i) 338 free(names[i]); 339 free(names); 340 } 341 fibril_mutex_unlock(&hound->list_guard); 342 return ret; 343 } 344 345 int hound_list_connections(hound_t *hound, const char ***sources, 346 const char ***sinks, size_t *size) 347 { 348 fibril_mutex_lock(&hound->list_guard); 349 fibril_mutex_unlock(&hound->list_guard); 350 return ENOTSUP; 351 } 352 265 353 int hound_connect(hound_t *hound, const char* source_name, const char* sink_name) 266 354 { -
uspace/srv/audio/hound/hound.h
r35ab943 r5ffcbaf 67 67 int hound_add_source(hound_t *hound, audio_source_t *source); 68 68 int hound_add_sink(hound_t *hound, audio_sink_t *sink); 69 int hound_list_sources(hound_t *hound, const char ***list, size_t *size); 70 int hound_list_sinks(hound_t *hound, const char ***list, size_t *size); 71 int hound_list_connections(hound_t *hound, const char ***sources, 72 const char ***sinks, size_t *size); 69 73 int hound_remove_source(hound_t *hound, audio_source_t *source); 70 74 int hound_remove_sink(hound_t *hound, audio_sink_t *sink);
Note:
See TracChangeset
for help on using the changeset viewer.