source: mainline/uspace/srv/audio/hound/connection.h@ 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: 3.0 KB
Line 
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#ifndef CONNECTION_H_
37#define CONNECTION_H_
38
39#include <assert.h>
40#include <adt/list.h>
41#include <pcm/format.h>
42
43#include "audio_source.h"
44#include "audio_sink.h"
45
46typedef struct {
47 link_t source_link;
48 link_t sink_link;
49 link_t hound_link;
50 audio_sink_t *sink;
51 audio_source_t *source;
52} connection_t;
53
54static inline connection_t * connection_from_source_list(link_t *l)
55{
56 return list_get_instance(l, connection_t, source_link);
57}
58
59static inline connection_t * connection_from_sink_list(link_t *l)
60{
61 return list_get_instance(l, connection_t, sink_link);
62}
63
64static inline connection_t * connection_from_hound_list(link_t *l)
65{
66 return list_get_instance(l, connection_t, hound_link);
67}
68
69connection_t *connection_create(audio_source_t *source, audio_sink_t *sink);
70void connection_destroy(connection_t *connection);
71
72ssize_t connection_add_source_data(connection_t *connection, void *data,
73 size_t size, pcm_format_t format);
74
75int connection_new_data(connection_t *connection, const void *data, size_t size);
76
77static inline const char *connection_source_name(connection_t *connection)
78{
79 assert(connection);
80 if (connection->source && connection->source->name)
81 return connection->source->name;
82 return connection->source ? "unnamed source" : "no source";
83}
84
85static inline const char *connection_sink_name(connection_t *connection)
86{
87 assert(connection);
88 if (connection->sink && connection->sink->name)
89 return connection->sink->name;
90 return connection->source ? "unnamed source" : "no source";
91}
92
93
94#endif
95/**
96 * @}
97 */
Note: See TracBrowser for help on using the repository browser.