source: mainline/uspace/srv/audio/hound/connection.c@ fa60cd69

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fa60cd69 was fa60cd69, checked in by Jan Vesely <jano.vesely@…>, 12 years ago

hound: add connection class

This will enable N to M routing in the future

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[fa60cd69]1/*
2 * Copyright (c) 2013 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/** @addtogroup audio
30 * @brief HelenOS sound server
31 * @{
32 */
33/** @file
34 */
35
36#include <malloc.h>
37#include <errno.h>
38
39#include "log.h"
40#include "connection.h"
41
42connection_t *connection_create(audio_source_t *source, audio_sink_t *sink)
43{
44 assert(source);
45 assert(sink);
46 connection_t *conn = malloc(sizeof(connection_t));
47 if (conn) {
48 link_initialize(&conn->source_link);
49 link_initialize(&conn->sink_link);
50 link_initialize(&conn->hound_link);
51 conn->sink = sink;
52 conn->source = source;
53 list_append(&conn->source_link, &source->connections);
54 list_append(&conn->sink_link, &sink->connections);
55 audio_sink_set_format(sink, audio_source_format(source));
56 source->connection_change(source, true);
57 sink->connection_change(sink, true);
58 }
59 return conn;
60}
61
62void connection_destroy(connection_t *connection)
63{
64 assert(connection);
65 assert(!link_in_use(&connection->hound_link));
66 list_remove(&connection->source_link);
67 list_remove(&connection->sink_link);
68 connection->sink->connection_change(connection->sink, false);
69 connection->source->connection_change(connection->source, false);
70 free(connection);
71}
72
73ssize_t connection_add_source_data(connection_t *connection, void *data,
74 size_t size, pcm_format_t format)
75{
76 assert(connection);
77 if (!data)
78 return EBADMEM;
79 return audio_source_add_self(connection->source, data, size, &format);
80}
81
82int connection_new_data(connection_t *connection, const void *data, size_t size)
83{
84 assert(connection);
85 return ENOTSUP;
86}
87
88
89/**
90 * @}
91 */
Note: See TracBrowser for help on using the repository browser.