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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 80d9d83 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
RevLine 
[737b4c0]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>
[e5bc912]39#include <inttypes.h>
[737b4c0]40#include <stdio.h>
41#include <stdlib.h>
42#include <str_error.h>
[eceb300]43#include <hound/server.h>
[4389076]44#include <hound/protocol.h>
[737b4c0]45
46#include "hound.h"
47
48#define NAMESPACE "audio"
49#define NAME "hound"
50#define CATEGORY "audio-pcm"
51
52#include "log.h"
[1df3018a]53
[4389076]54extern hound_server_iface_t hound_iface;
55
[1df3018a]56static hound_t hound;
57
[eceb300]58static int device_callback(service_id_t id, const char *name)
[1df3018a]59{
[eceb300]60 return hound_add_device(&hound, id, name);
[1df3018a]61}
[737b4c0]62
63static void scan_for_devices(void)
64{
[eceb300]65 hound_server_devices_iterate(device_callback);
[737b4c0]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) {
[1df3018a]74 log_fatal("Failed to initialize hound structure: %s",
75 str_error(ret));
76 return -ret;
77 }
78
[4389076]79 hound_iface.server = &hound;
80 hound_service_set_server_iface(&hound_iface);
81 async_set_client_connection(hound_connection_handler);
[1df3018a]82
83 service_id_t id = 0;
[eceb300]84 ret = hound_server_register(NAME, &id);
[1df3018a]85 if (ret != EOK) {
[eceb300]86 log_fatal("Failed to register server: %s", str_error(ret));
[1df3018a]87 return -ret;
[737b4c0]88 }
89
[eceb300]90 ret = hound_server_set_device_change_callback(scan_for_devices);
[1df3018a]91 if (ret != EOK) {
[eceb300]92 log_fatal("Failed to register for device changes: %s",
[1df3018a]93 str_error(ret));
[eceb300]94 hound_server_unregister(id);
[1df3018a]95 return -ret;
96 }
[e5bc912]97 log_info("Running with service id %" PRIun, id);
[737b4c0]98
99 scan_for_devices();
[bb2a5b2]100 task_retval(0);
[737b4c0]101 async_manager();
102 return 0;
103}
104
105/**
106 * @}
107 */
Note: See TracBrowser for help on using the repository browser.