source: mainline/uspace/srv/audio/hound/main.c@ abf2dfd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since abf2dfd was b688fd8, checked in by Martin Decky <martin@…>, 10 years ago

gradually introduce async ports, initial phase

The initial phase is to reimplement the traditional async client connections as an untyped fallback port. This creates the possibility to introduce ports typed by interface type gradually in later changesets.

  • Property mode set to 100644
File size: 3.0 KB
Line 
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 <async.h>
38#include <errno.h>
39#include <inttypes.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <str_error.h>
43#include <hound/server.h>
44#include <hound/protocol.h>
45#include <task.h>
46
47#include "hound.h"
48
49#define NAMESPACE "audio"
50#define NAME "hound"
51#define CATEGORY "audio-pcm"
52
53#include "log.h"
54
55extern hound_server_iface_t hound_iface;
56
57static hound_t hound;
58
59static int device_callback(service_id_t id, const char *name)
60{
61 return hound_add_device(&hound, id, name);
62}
63
64static void scan_for_devices(void)
65{
66 hound_server_devices_iterate(device_callback);
67}
68
69int main(int argc, char **argv)
70{
71 printf("%s: HelenOS sound service\n", NAME);
72
73 if (log_init(NAME) != EOK) {
74 printf(NAME ": Failed to initialize logging.\n");
75 return 1;
76 }
77
78 int ret = hound_init(&hound);
79 if (ret != EOK) {
80 log_fatal("Failed to initialize hound structure: %s",
81 str_error(ret));
82 return -ret;
83 }
84
85 hound_iface.server = &hound;
86 hound_service_set_server_iface(&hound_iface);
87 async_set_fallback_port_handler(hound_connection_handler, NULL);
88
89 service_id_t id = 0;
90 ret = hound_server_register(NAME, &id);
91 if (ret != EOK) {
92 log_fatal("Failed to register server: %s", str_error(ret));
93 return -ret;
94 }
95
96 ret = hound_server_set_device_change_callback(scan_for_devices);
97 if (ret != EOK) {
98 log_fatal("Failed to register for device changes: %s",
99 str_error(ret));
100 hound_server_unregister(id);
101 return -ret;
102 }
103 log_info("Running with service id %" PRIun, id);
104
105 scan_for_devices();
106 task_retval(0);
107 async_manager();
108 return 0;
109}
110
111/**
112 * @}
113 */
Note: See TracBrowser for help on using the repository browser.