source: mainline/uspace/srv/audio/hound/connection.h@ 5c98bb28

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

hound: switch connection to audio pipe

  • Property mode set to 100644
File size: 3.2 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_data.h"
44#include "audio_source.h"
45#include "audio_sink.h"
46
47typedef struct {
48 link_t source_link;
49 link_t sink_link;
50 link_t hound_link;
51 audio_pipe_t fifo;
52 audio_sink_t *sink;
53 audio_source_t *source;
54} connection_t;
55
56static inline connection_t * connection_from_source_list(link_t *l)
57{
58 return l ? list_get_instance(l, connection_t, source_link) : NULL;
59}
60
61static inline connection_t * connection_from_sink_list(link_t *l)
62{
63 return l ? list_get_instance(l, connection_t, sink_link) : NULL;
64}
65
66static inline connection_t * connection_from_hound_list(link_t *l)
67{
68 return l ? list_get_instance(l, connection_t, hound_link) : NULL;
69}
70
71connection_t *connection_create(audio_source_t *source, audio_sink_t *sink);
72void connection_destroy(connection_t *connection);
73
74ssize_t connection_add_source_data(connection_t *connection, void *data,
75 size_t size, pcm_format_t format);
76
77static inline int connection_push_data(connection_t *connection,
78 audio_data_t *adata)
79{
80 assert(connection);
81 assert(adata);
82 return audio_pipe_push(&connection->fifo, adata);
83}
84
85static inline const char *connection_source_name(connection_t *connection)
86{
87 assert(connection);
88 if (connection->source && connection->source->name)
89 return connection->source->name;
90 return connection->source ? "unnamed source" : "no source";
91}
92
93static inline const char *connection_sink_name(connection_t *connection)
94{
95 assert(connection);
96 if (connection->sink && connection->sink->name)
97 return connection->sink->name;
98 return connection->source ? "unnamed source" : "no source";
99}
100
101
102#endif
103/**
104 * @}
105 */
Note: See TracBrowser for help on using the repository browser.