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

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

hound: remove unused audio_client code

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