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

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

Fix printf compile issues

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