[737b4c0] | 1 | /*
|
---|
| 2 | * Copyright (c) 2012 Jan Vesely
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * @addtogroup audio
|
---|
| 31 | * @brief HelenOS sound server.
|
---|
| 32 | * @{
|
---|
| 33 | */
|
---|
| 34 | /** @file
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | #include <assert.h>
|
---|
| 38 | #include <stdlib.h>
|
---|
| 39 |
|
---|
| 40 | #include "hound.h"
|
---|
[1df3018a] | 41 | #include "audio_client.h"
|
---|
[737b4c0] | 42 | #include "audio_device.h"
|
---|
| 43 | #include "audio_sink.h"
|
---|
| 44 | #include "audio_source.h"
|
---|
[fa60cd69] | 45 | #include "connection.h"
|
---|
[737b4c0] | 46 | #include "log.h"
|
---|
| 47 | #include "errno.h"
|
---|
| 48 | #include "str_error.h"
|
---|
| 49 |
|
---|
[1df3018a] | 50 | #define FIND_BY_NAME(type) \
|
---|
| 51 | do { \
|
---|
| 52 | assert(list); \
|
---|
| 53 | assert(name); \
|
---|
| 54 | list_foreach(*list, it) { \
|
---|
| 55 | audio_ ## type ## _t *dev = \
|
---|
| 56 | audio_ ## type ## _list_instance(it); \
|
---|
| 57 | if (str_cmp(name, dev->name) == 0) { \
|
---|
[f3fced0] | 58 | log_debug("%s with name '%s' is in the list", \
|
---|
[1df3018a] | 59 | #type, name); \
|
---|
[63d6ff9] | 60 | return dev; \
|
---|
[1df3018a] | 61 | } \
|
---|
| 62 | } \
|
---|
| 63 | return NULL; \
|
---|
| 64 | } while (0)
|
---|
| 65 |
|
---|
| 66 | static audio_device_t * find_device_by_name(list_t *list, const char *name)
|
---|
| 67 | {
|
---|
| 68 | FIND_BY_NAME(device);
|
---|
| 69 | }
|
---|
| 70 | static audio_source_t * find_source_by_name(list_t *list, const char *name)
|
---|
| 71 | {
|
---|
| 72 | FIND_BY_NAME(source);
|
---|
| 73 | }
|
---|
| 74 | static audio_sink_t * find_sink_by_name(list_t *list, const char *name)
|
---|
| 75 | {
|
---|
| 76 | FIND_BY_NAME(sink);
|
---|
| 77 | }
|
---|
[3b6c1d4] | 78 |
|
---|
[13df13c8] | 79 | static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name);
|
---|
[1df3018a] | 80 |
|
---|
[6da3baec] | 81 | static void hound_remove_sink_internal(hound_t *hound, audio_sink_t *sink)
|
---|
| 82 | {
|
---|
| 83 | assert(hound);
|
---|
| 84 | assert(sink);
|
---|
| 85 | log_verbose("Removing sink '%s'.", sink->name);
|
---|
| 86 | if (!list_empty(&sink->connections))
|
---|
| 87 | log_warning("Removing sink '%s' while still connected.", sink->name);
|
---|
| 88 | while (!list_empty(&sink->connections)) {
|
---|
| 89 | connection_t *conn =
|
---|
| 90 | connection_from_sink_list(list_first(&sink->connections));
|
---|
| 91 | list_remove(&conn->hound_link);
|
---|
| 92 | connection_destroy(conn);
|
---|
| 93 | }
|
---|
| 94 | list_remove(&sink->link);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | static void hound_remove_source_internal(hound_t *hound, audio_source_t *source)
|
---|
| 98 | {
|
---|
| 99 | assert(hound);
|
---|
| 100 | assert(source);
|
---|
| 101 | log_verbose("Removing source '%s'.", source->name);
|
---|
| 102 | if (!list_empty(&source->connections))
|
---|
| 103 | log_warning("Removing source '%s' while still connected.", source->name);
|
---|
| 104 | while (!list_empty(&source->connections)) {
|
---|
| 105 | connection_t *conn =
|
---|
| 106 | connection_from_source_list(list_first(&source->connections));
|
---|
| 107 | assert(conn);
|
---|
| 108 | list_remove(&conn->hound_link);
|
---|
| 109 | connection_destroy(conn);
|
---|
| 110 | }
|
---|
| 111 | list_remove(&source->link);
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[737b4c0] | 114 | int hound_init(hound_t *hound)
|
---|
| 115 | {
|
---|
| 116 | assert(hound);
|
---|
[1df3018a] | 117 | fibril_mutex_initialize(&hound->list_guard);
|
---|
[737b4c0] | 118 | list_initialize(&hound->devices);
|
---|
[3b6c1d4] | 119 | list_initialize(&hound->contexts);
|
---|
[1df3018a] | 120 | list_initialize(&hound->sources);
|
---|
[737b4c0] | 121 | list_initialize(&hound->sinks);
|
---|
[fa60cd69] | 122 | list_initialize(&hound->connections);
|
---|
[737b4c0] | 123 | return EOK;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
[3b6c1d4] | 126 | int hound_add_ctx(hound_t *hound, hound_ctx_t *ctx)
|
---|
| 127 | {
|
---|
| 128 | log_info("Trying to add context %p", ctx);
|
---|
| 129 | assert(hound);
|
---|
| 130 | if (!ctx)
|
---|
| 131 | return EINVAL;
|
---|
[5ffcbaf] | 132 | fibril_mutex_lock(&hound->list_guard);
|
---|
[3b6c1d4] | 133 | list_append(&ctx->link, &hound->contexts);
|
---|
[5ffcbaf] | 134 | fibril_mutex_unlock(&hound->list_guard);
|
---|
[8f8ec69] | 135 | int ret = EOK;
|
---|
| 136 | if (ret == EOK && ctx->source)
|
---|
| 137 | ret = hound_add_source(hound, ctx->source);
|
---|
| 138 | if (ret == EOK && ctx->sink)
|
---|
| 139 | ret = hound_add_sink(hound, ctx->sink);
|
---|
| 140 | if (ret != EOK)
|
---|
| 141 | hound_ctx_destroy(ctx);
|
---|
| 142 | return ret;
|
---|
[3b6c1d4] | 143 | }
|
---|
| 144 |
|
---|
| 145 | int hound_remove_ctx(hound_t *hound, hound_ctx_t *ctx)
|
---|
| 146 | {
|
---|
| 147 | assert(hound);
|
---|
| 148 | if (!ctx)
|
---|
| 149 | return EINVAL;
|
---|
[5ffcbaf] | 150 | fibril_mutex_lock(&hound->list_guard);
|
---|
[3b6c1d4] | 151 | list_remove(&ctx->link);
|
---|
[6da3baec] | 152 | if (ctx->source)
|
---|
| 153 | hound_remove_source_internal(hound, ctx->source);
|
---|
| 154 | if (ctx->sink)
|
---|
| 155 | hound_remove_sink_internal(hound, ctx->sink);
|
---|
[5ffcbaf] | 156 | fibril_mutex_unlock(&hound->list_guard);
|
---|
[3b6c1d4] | 157 | return EOK;
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | hound_ctx_t *hound_get_ctx_by_id(hound_t *hound, hound_context_id_t id)
|
---|
| 161 | {
|
---|
| 162 | assert(hound);
|
---|
| 163 |
|
---|
[5ffcbaf] | 164 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 165 | hound_ctx_t *res = NULL;
|
---|
[3b6c1d4] | 166 | list_foreach(hound->contexts, it) {
|
---|
| 167 | hound_ctx_t *ctx = hound_ctx_from_link(it);
|
---|
[5ffcbaf] | 168 | if (hound_ctx_get_id(ctx) == id) {
|
---|
| 169 | res = ctx;
|
---|
| 170 | break;
|
---|
| 171 | }
|
---|
[3b6c1d4] | 172 | }
|
---|
[5ffcbaf] | 173 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 174 | return res;
|
---|
[3b6c1d4] | 175 | }
|
---|
| 176 |
|
---|
[1df3018a] | 177 | int hound_add_device(hound_t *hound, service_id_t id, const char *name)
|
---|
[737b4c0] | 178 | {
|
---|
| 179 | log_verbose("Adding device \"%s\", service: %zu", name, id);
|
---|
| 180 |
|
---|
| 181 | assert(hound);
|
---|
| 182 | if (!name || !id) {
|
---|
| 183 | log_debug("Incorrect parameters.");
|
---|
| 184 | return EINVAL;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | list_foreach(hound->devices, it) {
|
---|
[1df3018a] | 188 | audio_device_t *dev = audio_device_list_instance(it);
|
---|
[737b4c0] | 189 | if (dev->id == id) {
|
---|
| 190 | log_debug("Device with id %zu is already present", id);
|
---|
| 191 | return EEXISTS;
|
---|
| 192 | }
|
---|
| 193 | }
|
---|
| 194 |
|
---|
[1df3018a] | 195 | audio_device_t *dev = find_device_by_name(&hound->devices, name);
|
---|
| 196 | if (dev) {
|
---|
| 197 | log_debug("Device with name %s is already present", name);
|
---|
| 198 | return EEXISTS;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | dev = malloc(sizeof(audio_device_t));
|
---|
[737b4c0] | 202 | if (!dev) {
|
---|
| 203 | log_debug("Failed to malloc device structure.");
|
---|
| 204 | return ENOMEM;
|
---|
| 205 | }
|
---|
[d93a5a6f] | 206 |
|
---|
[737b4c0] | 207 | const int ret = audio_device_init(dev, id, name);
|
---|
| 208 | if (ret != EOK) {
|
---|
| 209 | log_debug("Failed to initialize new audio device: %s",
|
---|
| 210 | str_error(ret));
|
---|
| 211 | free(dev);
|
---|
| 212 | return ret;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | list_append(&dev->link, &hound->devices);
|
---|
[1df3018a] | 216 | log_info("Added new device: '%s'", dev->name);
|
---|
[737b4c0] | 217 |
|
---|
| 218 | audio_source_t *source = audio_device_get_source(dev);
|
---|
| 219 | if (source) {
|
---|
[1df3018a] | 220 | const int ret = hound_add_source(hound, source);
|
---|
| 221 | if (ret != EOK) {
|
---|
| 222 | log_debug("Failed to add device source: %s",
|
---|
| 223 | str_error(ret));
|
---|
| 224 | audio_device_fini(dev);
|
---|
| 225 | return ret;
|
---|
| 226 | }
|
---|
[737b4c0] | 227 | log_verbose("Added source: '%s'.", source->name);
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | audio_sink_t *sink = audio_device_get_sink(dev);
|
---|
| 231 | if (sink) {
|
---|
[1df3018a] | 232 | const int ret = hound_add_sink(hound, sink);
|
---|
| 233 | if (ret != EOK) {
|
---|
| 234 | log_debug("Failed to add device sink: %s",
|
---|
| 235 | str_error(ret));
|
---|
| 236 | audio_device_fini(dev);
|
---|
| 237 | return ret;
|
---|
| 238 | }
|
---|
[737b4c0] | 239 | log_verbose("Added sink: '%s'.", sink->name);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | if (!source && !sink)
|
---|
| 243 | log_warning("Neither sink nor source on device '%s'.", name);
|
---|
| 244 |
|
---|
| 245 | return ret;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
[1df3018a] | 248 | int hound_add_source(hound_t *hound, audio_source_t *source)
|
---|
| 249 | {
|
---|
| 250 | assert(hound);
|
---|
[6906f61] | 251 | if (!source || !source->name || str_cmp(source->name, "default") == 0) {
|
---|
[1df3018a] | 252 | log_debug("Invalid source specified.");
|
---|
| 253 | return EINVAL;
|
---|
| 254 | }
|
---|
| 255 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 256 | if (find_source_by_name(&hound->sources, source->name)) {
|
---|
| 257 | log_debug("Source by that name already exists");
|
---|
| 258 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 259 | return EEXISTS;
|
---|
| 260 | }
|
---|
| 261 | list_append(&source->link, &hound->sources);
|
---|
| 262 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 263 | return EOK;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | int hound_add_sink(hound_t *hound, audio_sink_t *sink)
|
---|
| 267 | {
|
---|
| 268 | assert(hound);
|
---|
[6906f61] | 269 | if (!sink || !sink->name || str_cmp(sink->name, "default") == 0) {
|
---|
[1df3018a] | 270 | log_debug("Invalid source specified.");
|
---|
| 271 | return EINVAL;
|
---|
| 272 | }
|
---|
| 273 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 274 | if (find_sink_by_name(&hound->sinks, sink->name)) {
|
---|
| 275 | log_debug("Sink by that name already exists");
|
---|
| 276 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 277 | return EEXISTS;
|
---|
| 278 | }
|
---|
| 279 | list_append(&sink->link, &hound->sinks);
|
---|
| 280 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 281 | return EOK;
|
---|
| 282 | }
|
---|
| 283 |
|
---|
[6424800] | 284 | int hound_remove_source(hound_t *hound, audio_source_t *source)
|
---|
| 285 | {
|
---|
| 286 | assert(hound);
|
---|
| 287 | if (!source)
|
---|
| 288 | return EINVAL;
|
---|
| 289 | fibril_mutex_lock(&hound->list_guard);
|
---|
[6da3baec] | 290 | hound_remove_source_internal(hound, source);
|
---|
[6424800] | 291 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 292 | return EOK;
|
---|
| 293 | }
|
---|
| 294 |
|
---|
[6da3baec] | 295 |
|
---|
[6424800] | 296 | int hound_remove_sink(hound_t *hound, audio_sink_t *sink)
|
---|
| 297 | {
|
---|
| 298 | assert(hound);
|
---|
| 299 | if (!sink)
|
---|
| 300 | return EINVAL;
|
---|
| 301 | fibril_mutex_lock(&hound->list_guard);
|
---|
[6da3baec] | 302 | hound_remove_sink_internal(hound, sink);
|
---|
[6424800] | 303 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 304 | return EOK;
|
---|
| 305 | }
|
---|
| 306 |
|
---|
[5ffcbaf] | 307 | int hound_list_sources(hound_t *hound, const char ***list, size_t *size)
|
---|
| 308 | {
|
---|
| 309 | assert(hound);
|
---|
| 310 | if (!list || !size)
|
---|
| 311 | return EINVAL;
|
---|
| 312 |
|
---|
| 313 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 314 | const size_t count = list_count(&hound->sources);
|
---|
| 315 | if (count == 0) {
|
---|
| 316 | *list = NULL;
|
---|
| 317 | *size = 0;
|
---|
| 318 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 319 | return EOK;
|
---|
| 320 | }
|
---|
| 321 | const char **names = calloc(count, sizeof(char *));
|
---|
| 322 | int ret = names ? EOK : ENOMEM;
|
---|
| 323 | for (size_t i = 0; i < count && ret == EOK; ++i) {
|
---|
| 324 | link_t *slink = list_nth(&hound->sources, i);
|
---|
| 325 | audio_source_t *source = audio_source_list_instance(slink);
|
---|
| 326 | names[i] = str_dup(source->name);
|
---|
| 327 | if (names[i])
|
---|
| 328 | ret = ENOMEM;
|
---|
| 329 | }
|
---|
| 330 | if (ret == EOK) {
|
---|
| 331 | *size = count;
|
---|
| 332 | *list = names;
|
---|
| 333 | } else {
|
---|
| 334 | for (size_t i = 0; i < count; ++i)
|
---|
| 335 | free(names[i]);
|
---|
| 336 | free(names);
|
---|
| 337 | }
|
---|
| 338 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 339 | return ret;
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | int hound_list_sinks(hound_t *hound, const char ***list, size_t *size)
|
---|
| 343 | {
|
---|
| 344 | assert(hound);
|
---|
| 345 | if (!list || !size)
|
---|
| 346 | return EINVAL;
|
---|
| 347 |
|
---|
| 348 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 349 | const size_t count = list_count(&hound->sinks);
|
---|
| 350 | if (count == 0) {
|
---|
| 351 | *list = NULL;
|
---|
| 352 | *size = 0;
|
---|
| 353 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 354 | return EOK;
|
---|
| 355 | }
|
---|
| 356 | const char **names = calloc(count, sizeof(char *));
|
---|
| 357 | int ret = names ? EOK : ENOMEM;
|
---|
| 358 | for (size_t i = 0; i < count && ret == EOK; ++i) {
|
---|
| 359 | link_t *slink = list_nth(&hound->sinks, i);
|
---|
| 360 | audio_sink_t *sink = audio_sink_list_instance(slink);
|
---|
| 361 | names[i] = str_dup(sink->name);
|
---|
| 362 | if (!names[i])
|
---|
| 363 | ret = ENOMEM;
|
---|
| 364 | }
|
---|
| 365 | if (ret == EOK) {
|
---|
| 366 | *size = count;
|
---|
| 367 | *list = names;
|
---|
| 368 | } else {
|
---|
| 369 | for (size_t i = 0; i < count; ++i)
|
---|
| 370 | free(names[i]);
|
---|
| 371 | free(names);
|
---|
| 372 | }
|
---|
| 373 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 374 | return ret;
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | int hound_list_connections(hound_t *hound, const char ***sources,
|
---|
| 378 | const char ***sinks, size_t *size)
|
---|
| 379 | {
|
---|
| 380 | fibril_mutex_lock(&hound->list_guard);
|
---|
| 381 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 382 | return ENOTSUP;
|
---|
| 383 | }
|
---|
| 384 |
|
---|
[f3fced0] | 385 | int hound_connect(hound_t *hound, const char* source_name, const char* sink_name)
|
---|
| 386 | {
|
---|
| 387 | assert(hound);
|
---|
| 388 | log_verbose("Connecting '%s' to '%s'.", source_name, sink_name);
|
---|
| 389 | fibril_mutex_lock(&hound->list_guard);
|
---|
[6906f61] | 390 |
|
---|
[f3fced0] | 391 | audio_source_t *source =
|
---|
[6906f61] | 392 | audio_source_list_instance(list_first(&hound->sources));
|
---|
| 393 | if (str_cmp(source_name, "default") != 0)
|
---|
| 394 | source = find_source_by_name(&hound->sources, source_name);
|
---|
| 395 |
|
---|
| 396 | audio_sink_t *sink =
|
---|
| 397 | audio_sink_list_instance(list_first(&hound->sinks));
|
---|
| 398 | if (str_cmp(sink_name, "default") != 0)
|
---|
| 399 | sink = find_sink_by_name(&hound->sinks, sink_name);
|
---|
| 400 |
|
---|
[f3fced0] | 401 | if (!source || !sink) {
|
---|
| 402 | fibril_mutex_unlock(&hound->list_guard);
|
---|
[1c33539] | 403 | log_debug("Source (%p), or sink (%p) not found", source, sink);
|
---|
[f3fced0] | 404 | return ENOENT;
|
---|
| 405 | }
|
---|
[fa60cd69] | 406 | connection_t *conn = connection_create(source, sink);
|
---|
| 407 | if (!conn) {
|
---|
| 408 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 409 | log_debug("Failed to create connection");
|
---|
| 410 | return ENOMEM;
|
---|
[f3fced0] | 411 | }
|
---|
[fa60cd69] | 412 | list_append(&conn->hound_link, &hound->connections);
|
---|
[f3fced0] | 413 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 414 | return EOK;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | int hound_disconnect(hound_t *hound, const char* source_name, const char* sink_name)
|
---|
| 418 | {
|
---|
[1c33539] | 419 | assert(hound);
|
---|
| 420 | fibril_mutex_lock(&hound->list_guard);
|
---|
[13df13c8] | 421 | const int ret = hound_disconnect_internal(hound, source_name, sink_name);
|
---|
| 422 | fibril_mutex_unlock(&hound->list_guard);
|
---|
| 423 | return ret;
|
---|
| 424 | }
|
---|
| 425 |
|
---|
[6da3baec] | 426 | static int hound_disconnect_internal(hound_t *hound, const char* source_name,
|
---|
| 427 | const char* sink_name)
|
---|
[13df13c8] | 428 | {
|
---|
| 429 | assert(hound);
|
---|
| 430 | assert(fibril_mutex_is_locked(&hound->list_guard));
|
---|
[fa60cd69] | 431 | log_debug("Disconnecting '%s' to '%s'.", source_name, sink_name);
|
---|
| 432 |
|
---|
| 433 | list_foreach_safe(hound->connections, it, next) {
|
---|
| 434 | connection_t *conn = connection_from_hound_list(it);
|
---|
| 435 | if (str_cmp(connection_source_name(conn), source_name) == 0 ||
|
---|
| 436 | str_cmp(connection_sink_name(conn), sink_name) == 0) {
|
---|
| 437 | log_debug("Removing %s -> %s", connection_source_name(conn),
|
---|
| 438 | connection_sink_name(conn));
|
---|
| 439 | list_remove(it);
|
---|
| 440 | connection_destroy(conn);
|
---|
| 441 | }
|
---|
[1c33539] | 442 | }
|
---|
[fa60cd69] | 443 |
|
---|
[1c33539] | 444 | return EOK;
|
---|
[f3fced0] | 445 | }
|
---|
[737b4c0] | 446 | /**
|
---|
| 447 | * @}
|
---|
| 448 | */
|
---|