Changeset 1df3018a in mainline
- Timestamp:
- 2012-07-13T03:24:17Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d93a5a6f
- Parents:
- d01e635
- Location:
- uspace/srv/audio/hound
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/Makefile
rd01e635 r1df3018a 38 38 39 39 SOURCES = \ 40 audio_client.c \ 40 41 audio_device.c \ 41 42 audio_format.c \ -
uspace/srv/audio/hound/audio_device.c
rd01e635 r1df3018a 49 49 #define BUFFER_BLOCKS 2 50 50 51 static int device_sink_connection_callback( void* arg);52 static int device_source_connection_callback( void* arg, const audio_format_t *f);51 static int device_sink_connection_callback(audio_sink_t *sink); 52 static int device_source_connection_callback(audio_source_t *source); 53 53 static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg); 54 54 static int get_buffer(audio_device_t *dev); … … 72 72 } 73 73 74 audio_sink_init(&dev->sink, name); 75 audio_source_init(&dev->source, name); 76 77 audio_sink_set_connected_callback(&dev->sink, 78 device_sink_connection_callback, dev); 79 audio_source_set_connected_callback(&dev->source, 80 device_source_connection_callback, dev); 74 audio_sink_init(&dev->sink, name, dev, device_sink_connection_callback, 75 &AUDIO_FORMAT_ANY); 76 audio_source_init(&dev->source, name, dev, 77 device_source_connection_callback, NULL, &AUDIO_FORMAT_ANY); 81 78 82 79 /* Init buffer members */ … … 93 90 return EOK; 94 91 } 95 96 static int device_sink_connection_callback(void* arg) 97 { 98 audio_device_t *dev = arg; 99 if (list_count(&dev->sink.sources) == 1) { 92 void audio_device_fini(audio_device_t *dev) 93 { 94 //TODO implement; 95 } 96 97 static int device_sink_connection_callback(audio_sink_t* sink) 98 { 99 assert(sink); 100 audio_device_t *dev = sink->private_data; 101 if (list_count(&sink->sources) == 1) { 100 102 int ret = get_buffer(dev); 101 103 if (ret != EOK) { … … 112 114 } 113 115 } 114 if (list_count(& dev->sink.sources) == 0) {116 if (list_count(&sink->sources) == 0) { 115 117 int ret = stop_playback(dev); 116 118 if (ret != EOK) { … … 130 132 } 131 133 132 static int device_source_connection_callback(void* arg, const audio_format_t *f) 133 { 134 audio_device_t *dev = arg; 135 if (f) { /* Connected, f points to sink format */ 134 static int device_source_connection_callback(audio_source_t *source) 135 { 136 assert(source); 137 audio_device_t *dev = source->private_data; 138 if (source->connected_sink) { 136 139 int ret = get_buffer(dev); 137 140 if (ret != EOK) { … … 147 150 return ret; 148 151 } 149 dev->source.format = *f; 150 } else { /* Disconnected, f is NULL */ 152 } else { /* Disconnected */ 151 153 int ret = stop_recording(dev); 152 154 if (ret != EOK) { … … 155 157 return ret; 156 158 } 157 dev->sink.format = AUDIO_FORMAT_ANY;159 source->format = AUDIO_FORMAT_ANY; 158 160 ret = release_buffer(dev); 159 161 if (ret != EOK) { -
uspace/srv/audio/hound/audio_device.h
rd01e635 r1df3018a 44 44 #include <ipc/loc.h> 45 45 46 #include "audio_format.h"47 46 #include "audio_source.h" 48 47 #include "audio_sink.h" … … 65 64 } audio_device_t; 66 65 67 static inline audio_device_t * list_audio_device_instance(link_t *l)66 static inline audio_device_t * audio_device_list_instance(link_t *l) 68 67 { 69 68 return list_get_instance(l, audio_device_t, link); … … 71 70 72 71 int audio_device_init(audio_device_t *dev, service_id_t id, const char *name); 73 72 void audio_device_fini(audio_device_t *dev); 74 73 static inline audio_source_t * audio_device_get_source(audio_device_t *dev) 75 74 { … … 87 86 int audio_device_available_buffer(audio_device_t *dev, void **base, size_t *size); 88 87 89 int audio_device_playback_start(audio_device_t *dev, const audio_format_t *format, unsigned latency);90 int audio_device_record_start(audio_device_t *dev, const audio_format_t *format, unsigned latency);91 int audio_device_playback_stop(audio_device_t *dev);92 int audio_device_record_stop(audio_device_t *dev);93 94 88 #endif 95 89 -
uspace/srv/audio/hound/audio_sink.c
rd01e635 r1df3018a 43 43 #include "log.h" 44 44 45 #if 046 static int loop(void* arg)47 {48 audio_sink_t *sink = arg;49 assert(sink);50 while (sink->device) {51 while (sink->running) {52 //wait for usable buffer53 audio_sink_mix_inputs(sink,54 sink->device->buffer.available_base,55 sink->device->buffer.available_size);56 }57 //remove ready58 sleep(1);59 }60 return 0;61 }62 #endif63 45 64 65 int audio_sink_init(audio_sink_t *sink, const char* name) 46 int audio_sink_init(audio_sink_t *sink, const char *name, 47 void *private_data,int (*connection_change)(audio_sink_t *sink), 48 const audio_format_t *f) 66 49 { 67 50 assert(sink); … … 73 56 list_initialize(&sink->sources); 74 57 sink->name = str_dup(name); 75 sink-> format = AUDIO_FORMAT_ANY;76 log_verbose("Initialized sink (%p) '%s' with ANY audio format",77 58 sink->private_data = private_data; 59 sink->format = *f; 60 log_verbose("Initialized sink (%p) '%s'", sink, sink->name); 78 61 return EOK; 79 62 } 63 64 void audio_sink_fini(audio_sink_t *sink) 65 { 66 assert(sink); 67 assert(!sink->private_data); 68 free(sink->name); 69 sink->name = NULL; 70 } 71 80 72 81 73 int audio_sink_add_source(audio_sink_t *sink, audio_source_t *source) … … 111 103 } 112 104 113 if (sink->connected_change.hook) { 114 const int ret = 115 sink->connected_change.hook(sink->connected_change.arg); 105 if (sink->connection_change) { 106 const int ret = sink->connection_change(sink); 116 107 if (ret != EOK) { 117 log_debug("Connect edhook failed.");108 log_debug("Connection hook failed."); 118 109 list_remove(&source->link); 119 110 sink->format = old_format; … … 131 122 assert(list_member(&source->link, &sink->sources)); 132 123 list_remove(&source->link); 133 if (sink->connected_change.hook) { 134 const int ret = 135 sink->connected_change.hook(sink->connected_change.arg); 124 if (sink->connection_change) { 125 const int ret = sink->connection_change(sink); 136 126 if (ret != EOK) { 137 127 log_debug("Connected hook failed."); 128 list_append(&source->link, &sink->sources); 129 return ret; 138 130 } 139 131 } -
uspace/srv/audio/hound/audio_sink.h
rd01e635 r1df3018a 37 37 #define AUDIO_SINK_H_ 38 38 39 #include <adt/list.h> 40 #include <async.h> 39 41 #include <bool.h> 40 #include <adt/list.h>41 42 #include <pcm_sample_format.h> 42 43 #include <fibril.h> 43 44 45 #include "audio_source.h" 44 46 #include "audio_format.h" 45 #include "audio_source.h"46 47 47 typedef struct audio_sink { 48 typedef struct audio_sink audio_sink_t; 49 50 struct audio_sink { 48 51 link_t link; 49 52 list_t sources; 50 c har *name;53 const char *name; 51 54 audio_format_t format; 52 struct { 53 int (*hook)(void* arg); 54 void *arg; 55 } connected_change; 56 } audio_sink_t; 55 void *private_data; 56 int (*connection_change)(audio_sink_t *sink); 57 }; 57 58 58 static inline void audio_sink_set_connected_callback(audio_sink_t *sink, 59 int (*hook)(void* arg), void* arg) 59 static inline audio_sink_t * audio_sink_list_instance(link_t *l) 60 60 { 61 assert(sink); 62 sink->connected_change.arg = arg; 63 sink->connected_change.hook = hook; 64 }; 65 int audio_sink_init(audio_sink_t *sink, const char* name); 61 return list_get_instance(l, audio_sink_t, link); 62 } 63 64 int audio_sink_init(audio_sink_t *sink, const char *name, 65 void *private_data, int (*connection_change)(audio_sink_t *sink), 66 const audio_format_t *f); 67 void audio_sink_fini(audio_sink_t *sink); 68 66 69 int audio_sink_add_source(audio_sink_t *sink, audio_source_t *source); 67 70 int audio_sink_remove_source(audio_sink_t *sink, audio_source_t *source); -
uspace/srv/audio/hound/audio_source.c
rd01e635 r1df3018a 42 42 43 43 #include "audio_source.h" 44 #include "audio_sink.h" 44 45 #include "log.h" 45 46 46 47 47 int audio_source_init(audio_source_t *source, const char* name) 48 int audio_source_init(audio_source_t *source, const char *name, void *data, 49 int (*connection_change)(audio_source_t *), 50 int (*update_available_data)(audio_source_t *, size_t), 51 const audio_format_t *f) 48 52 { 49 53 assert(source); 50 if (!name ) {54 if (!name || !f) { 51 55 log_debug("Incorrect parameters."); 52 56 return EINVAL; … … 54 58 link_initialize(&source->link); 55 59 source->name = str_dup(name); 56 source-> connected_change.hook = NULL;57 source->connect ed_change.arg = NULL;58 source-> get_data.hook = NULL;59 source-> get_data.arg= NULL;60 source-> available.base = NULL;61 source->available .size = 0;62 log_verbose("Initialized source (%p) '%s' with ANY audio format",63 60 source->private_data = data; 61 source->connection_change = connection_change; 62 source->update_available_data = update_available_data; 63 source->connected_sink = NULL; 64 source->format = *f; 65 source->available_data.base = NULL; 66 source->available_data.size = 0; 67 log_verbose("Initialized source (%p) '%s'", source, source->name); 64 68 return EOK; 65 69 } 66 70 67 int audio_source_connected(audio_source_t *source, const audio_format_t *f) 71 void audio_source_fini(audio_source_t *source) 72 { 73 if (!source) 74 return; 75 assert(source->connected_sink == NULL); 76 free(source->name); 77 free(source); 78 } 79 80 int audio_source_connected(audio_source_t *source, struct audio_sink *sink) 68 81 { 69 82 assert(source); 70 if (!f) { 71 log_debug("Incorrect parameters."); 72 return EINVAL; 83 audio_sink_t *old_sink = source->connected_sink; 84 const audio_format_t old_format = source->format; 85 86 source->connected_sink = sink; 87 if (audio_format_is_any(&source->format)) { 88 assert(sink); 89 assert(!audio_format_is_any(&sink->format)); 90 source->format = sink->format; 73 91 } 74 if (source->connected_change.hook) 75 source->connected_change.hook(source->connected_change.arg, f); 92 if (source->connection_change) { 93 const int ret = source->connection_change(source); 94 if (ret != EOK) { 95 source->format = old_format; 96 source->connected_sink = old_sink; 97 return ret; 98 } 99 } 76 100 return EOK; 77 101 } … … 96 120 return ENOTSUP; 97 121 } 98 99 if (source->available.size == 0) { 100 log_debug("No data to add"); 101 return EOVERFLOW; /* In fact this is underflow... */ 122 if (source->available_data.base == NULL || 123 source->available_data.size == 0) { 124 int ret = EOVERFLOW; /* In fact this is underflow... */ 125 if (source->update_available_data) 126 ret = source->update_available_data(source, size); 127 if (ret != EOK) { 128 log_debug("No data to add"); 129 return ret; 130 } 102 131 } 103 132 104 const size_t real_size = min(size, source->available .size);133 const size_t real_size = min(size, source->available_data.size); 105 134 const int ret = 106 audio_format_mix(buffer, source->available .base, real_size, f);135 audio_format_mix(buffer, source->available_data.base, real_size, f); 107 136 if (ret != EOK) { 108 137 log_debug("Mixing failed"); 109 138 return ret; 110 139 } 111 source->available.base += real_size; 112 source->available.size -= real_size; 140 source->available_data.base += real_size; 141 source->available_data.size -= real_size; 142 buffer += real_size; 143 size -= real_size; 144 145 //TODO update data again 146 if (size) 147 log_warning("not enough data"); 148 113 149 return EOK; 114 150 } -
uspace/srv/audio/hound/audio_source.h
rd01e635 r1df3018a 41 41 #include <pcm_sample_format.h> 42 42 43 43 44 #include "audio_format.h" 44 45 46 struct audio_sink; 47 typedef struct audio_source audio_source_t; 45 48 46 typedef struct{49 struct audio_source { 47 50 link_t link; 48 char *name; 49 struct { 50 int (*hook)(void* arg, const audio_format_t *f); 51 void *arg; 52 } connected_change; 53 struct { 54 int (*hook)(void* arg); 55 void *arg; 56 } get_data; 51 const char *name; 52 audio_format_t format; 53 void *private_data; 54 int (*connection_change)(audio_source_t *source); 55 int (*update_available_data)(audio_source_t *source, size_t size); 56 struct audio_sink *connected_sink; 57 57 struct { 58 58 void *base; 59 59 size_t size; 60 } available; 61 audio_format_t format; 62 } audio_source_t; 60 } available_data; 61 }; 63 62 64 63 static inline audio_source_t * audio_source_list_instance(link_t *l) … … 67 66 } 68 67 69 int audio_source_init(audio_source_t *source, const char *name); 70 static inline void audio_source_set_connected_callback(audio_source_t *source, 71 int (*hook)(void* arg, const audio_format_t *f), void* arg) 72 { 73 assert(source); 74 source->connected_change.arg = arg; 75 source->connected_change.hook = hook; 76 } 77 int audio_source_connected(audio_source_t *source, const audio_format_t *f); 68 int audio_source_init(audio_source_t *source, const char *name, void *data, 69 int (*connection_change)(audio_source_t *), 70 int (*update_available_data)(audio_source_t *, size_t), 71 const audio_format_t *f); 72 void audio_source_fini(audio_source_t *source); 73 int audio_source_connected(audio_source_t *source, struct audio_sink *sink); 78 74 int audio_source_add_self(audio_source_t *source, void *buffer, size_t size, 79 75 const audio_format_t *f); -
uspace/srv/audio/hound/hound.c
rd01e635 r1df3018a 39 39 40 40 #include "hound.h" 41 #include "audio_client.h" 41 42 #include "audio_device.h" 42 43 #include "audio_sink.h" … … 46 47 #include "str_error.h" 47 48 49 #define FIND_BY_NAME(type) \ 50 do { \ 51 assert(list); \ 52 assert(name); \ 53 list_foreach(*list, it) { \ 54 audio_ ## type ## _t *dev = \ 55 audio_ ## type ## _list_instance(it); \ 56 if (str_cmp(name, dev->name) == 0) { \ 57 log_debug("%s with name %s is already present", \ 58 #type, name); \ 59 return NULL; \ 60 } \ 61 } \ 62 return NULL; \ 63 } while (0) 64 65 static audio_device_t * find_device_by_name(list_t *list, const char *name) 66 { 67 FIND_BY_NAME(device); 68 } 69 static audio_source_t * find_source_by_name(list_t *list, const char *name) 70 { 71 FIND_BY_NAME(source); 72 } 73 static audio_sink_t * find_sink_by_name(list_t *list, const char *name) 74 { 75 FIND_BY_NAME(sink); 76 } 77 48 78 int hound_init(hound_t *hound) 49 79 { 50 80 assert(hound); 81 fibril_mutex_initialize(&hound->list_guard); 51 82 list_initialize(&hound->devices); 83 list_initialize(&hound->sources); 52 84 list_initialize(&hound->available_sources); 53 85 list_initialize(&hound->sinks); 54 list_initialize(&hound->clients);55 86 return EOK; 56 87 } 57 88 58 int hound_add_device(hound_t *hound, service_id_t id, const char *name)89 int hound_add_device(hound_t *hound, service_id_t id, const char *name) 59 90 { 60 91 log_verbose("Adding device \"%s\", service: %zu", name, id); … … 67 98 68 99 list_foreach(hound->devices, it) { 69 audio_device_t *dev = list_audio_device_instance(it);100 audio_device_t *dev = audio_device_list_instance(it); 70 101 if (dev->id == id) { 71 102 log_debug("Device with id %zu is already present", id); … … 74 105 } 75 106 76 audio_device_t *dev = malloc(sizeof(audio_device_t)); 107 audio_device_t *dev = find_device_by_name(&hound->devices, name); 108 if (dev) { 109 log_debug("Device with name %s is already present", name); 110 return EEXISTS; 111 } 112 113 dev = malloc(sizeof(audio_device_t)); 77 114 if (!dev) { 78 115 log_debug("Failed to malloc device structure."); … … 80 117 } 81 118 const int ret = audio_device_init(dev, id, name); 119 free(name); 82 120 if (ret != EOK) { 83 121 log_debug("Failed to initialize new audio device: %s", … … 88 126 89 127 list_append(&dev->link, &hound->devices); 90 log_info("Added new device: '%s'", name);128 log_info("Added new device: '%s'", dev->name); 91 129 92 130 audio_source_t *source = audio_device_get_source(dev); 93 131 if (source) { 132 const int ret = hound_add_source(hound, source); 133 if (ret != EOK) { 134 log_debug("Failed to add device source: %s", 135 str_error(ret)); 136 audio_device_fini(dev); 137 return ret; 138 } 94 139 log_verbose("Added source: '%s'.", source->name); 95 list_append(&source->link, &hound->available_sources);96 140 } 97 141 98 142 audio_sink_t *sink = audio_device_get_sink(dev); 99 143 if (sink) { 144 const int ret = hound_add_sink(hound, sink); 145 if (ret != EOK) { 146 log_debug("Failed to add device sink: %s", 147 str_error(ret)); 148 audio_device_fini(dev); 149 return ret; 150 } 100 151 log_verbose("Added sink: '%s'.", sink->name); 101 list_append(&sink->link, &hound->sinks);102 152 } 103 153 … … 108 158 } 109 159 160 int hound_add_source(hound_t *hound, audio_source_t *source) 161 { 162 assert(hound); 163 if (!source || !source->name) { 164 log_debug("Invalid source specified."); 165 return EINVAL; 166 } 167 fibril_mutex_lock(&hound->list_guard); 168 if (find_source_by_name(&hound->sources, source->name)) { 169 log_debug("Source by that name already exists"); 170 fibril_mutex_unlock(&hound->list_guard); 171 return EEXISTS; 172 } 173 list_foreach(hound->sinks, it) { 174 audio_sink_t *sink = audio_sink_list_instance(it); 175 if (find_source_by_name(&sink->sources, source->name)) { 176 log_debug("Source by that name already exists"); 177 fibril_mutex_unlock(&hound->list_guard); 178 return EEXISTS; 179 } 180 } 181 list_append(&source->link, &hound->sources); 182 fibril_mutex_unlock(&hound->list_guard); 183 return EOK; 184 } 185 186 int hound_add_sink(hound_t *hound, audio_sink_t *sink) 187 { 188 assert(hound); 189 if (!sink || !sink->name) { 190 log_debug("Invalid source specified."); 191 return EINVAL; 192 } 193 fibril_mutex_lock(&hound->list_guard); 194 if (find_sink_by_name(&hound->sinks, sink->name)) { 195 log_debug("Sink by that name already exists"); 196 fibril_mutex_unlock(&hound->list_guard); 197 return EEXISTS; 198 } 199 list_append(&sink->link, &hound->sinks); 200 fibril_mutex_unlock(&hound->list_guard); 201 return EOK; 202 } 203 110 204 /** 111 205 * @} -
uspace/srv/audio/hound/hound.h
rd01e635 r1df3018a 41 41 #include <ipc/loc.h> 42 42 #include <errno.h> 43 #include <fibril_synch.h> 44 45 #include "audio_source.h" 46 #include "audio_sink.h" 47 #include "audio_format.h" 48 43 49 44 50 typedef struct { 51 fibril_mutex_t list_guard; 45 52 list_t devices; 46 list_t clients;53 list_t sources; 47 54 list_t available_sources; 48 55 list_t sinks; … … 51 58 int hound_init(hound_t *hound); 52 59 int hound_add_device(hound_t *hound, service_id_t id, const char* name); 53 int hound_add_playback_client(hound_t *hound, const char* name); 54 int hound_add_record_client(hound_t *hound, const char* name); 60 int hound_add_source(hound_t *hound, audio_source_t *source); 61 int hound_add_sink(hound_t *hound, audio_sink_t *sink); 62 int hound_connect(const char* source_name, const char* sink_name); 63 int hound_disconnect(const char* source_name, const char* sink_name); 55 64 56 65 #endif -
uspace/srv/audio/hound/main.c
rd01e635 r1df3018a 47 47 #define NAMESPACE "audio" 48 48 #define NAME "hound" 49 50 49 #define CATEGORY "audio-pcm" 51 50 51 #include "audio_client.h" 52 52 #include "log.h" 53 54 hound_t hound; 53 #include "protocol.h" 54 55 static hound_t hound; 56 57 static inline audio_format_t read_format(const ipc_call_t *call) 58 { 59 audio_format_t format = { 60 .channels = IPC_GET_ARG1(*call), 61 .sampling_rate = IPC_GET_ARG2(*call), 62 .sample_format = IPC_GET_ARG3(*call), 63 }; 64 return format; 65 } 66 static inline const char *get_name() 67 { 68 size_t size = 0; 69 ipc_callid_t callid; 70 async_data_read_receive(&callid, &size); 71 char *buffer = malloc(size); 72 if (buffer) { 73 async_data_read_finalize(callid, buffer, size); 74 buffer[size - 1] = 0; 75 log_verbose("Got name from client: %s", buffer); 76 } 77 return buffer; 78 } 79 static inline async_sess_t *get_session() 80 { 81 ipc_call_t call; 82 ipc_callid_t callid = async_get_call(&call); 83 async_sess_t *s = async_callback_receive_start(EXCHANGE_ATOMIC, &call); 84 async_answer_0(callid, s ? EOK : ENOMEM); 85 log_verbose("Received callback session"); 86 return s; 87 } 88 55 89 56 90 static void scan_for_devices(void) … … 96 130 97 131 free(svcs); 98 99 } 100 132 } 133 134 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 135 { 136 async_answer_0(iid, EOK); 137 138 LIST_INITIALIZE(local_playback); 139 LIST_INITIALIZE(local_recording); 140 141 while (1) { 142 ipc_call_t call; 143 ipc_callid_t callid = async_get_call(&call); 144 log_debug("Got method %u", IPC_GET_IMETHOD(call)); 145 switch (IPC_GET_IMETHOD(call)) { 146 case HOUND_REGISTER_PLAYBACK: { 147 const audio_format_t format = read_format(&call); 148 const char *name = get_name(); 149 async_sess_t *sess = get_session(); 150 audio_client_t * client = 151 audio_client_get_playback(name, &format, sess); 152 if (!client) { 153 log_error("Failed to create playback client"); 154 async_answer_0(callid, ENOMEM); 155 } 156 int ret = hound_add_source(&hound, &client->source); 157 if (ret != EOK){ 158 audio_client_destroy(client); 159 log_error("Failed to add audio source: %s", 160 str_error(ret)); 161 async_answer_0(callid, ret); 162 break; 163 } 164 async_answer_0(callid, EOK); 165 list_append(&client->link, &local_playback); 166 break; 167 } 168 case HOUND_REGISTER_RECORDING: { 169 const audio_format_t format = read_format(&call); 170 const char *name = get_name(); 171 async_sess_t *sess = get_session(); 172 audio_client_t * client = 173 audio_client_get_recording(name, &format, sess); 174 if (!client) { 175 log_error("Failed to create recording client"); 176 async_answer_0(callid, ENOMEM); 177 break; 178 } 179 int ret = hound_add_sink(&hound, &client->sink); 180 if (ret != EOK){ 181 audio_client_destroy(client); 182 log_error("Failed to add audio sink: %s", 183 str_error(ret)); 184 async_answer_0(callid, ret); 185 break; 186 } 187 async_answer_0(callid, EOK); 188 list_append(&client->link, &local_recording); 189 break; 190 } 191 case HOUND_UNREGISTER_PLAYBACK: { 192 //const char *name = get_name(); 193 //TODO unregister in hound 194 //TODO remove from local 195 break; 196 } 197 case HOUND_UNREGISTER_RECORDING: { 198 //TODO Get Name 199 //TODO unregister in hound 200 //TODO remove from local 201 break; 202 } 203 case HOUND_CONNECT: { 204 //TODO Get Name 205 //TODO Get Name 206 //TODO connect in hound 207 break; 208 } 209 case HOUND_DISCONNECT: { 210 //TODO Get Name 211 //TODO Get Name 212 //TODO disconnect in hound 213 break; 214 } 215 default: 216 async_answer_0(callid, ENOTSUP); 217 break; 218 case 0: 219 return; 220 } 221 } 222 } 101 223 102 224 int main(int argc, char **argv) … … 106 228 int ret = hound_init(&hound); 107 229 if (ret != EOK) { 108 log_error("Failed to initialize hound structure: %s\n", 109 str_error(ret)); 110 return 1; 230 log_fatal("Failed to initialize hound structure: %s", 231 str_error(ret)); 232 return -ret; 233 } 234 235 async_set_client_connection(client_connection); 236 ret = loc_server_register(NAME); 237 if (ret != EOK) { 238 log_fatal("Failed to register sound server: %s", 239 str_error(ret)); 240 return -ret; 241 } 242 243 char fqdn[LOC_NAME_MAXLEN + 1]; 244 snprintf(fqdn, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 245 service_id_t id = 0; 246 ret = loc_service_register(fqdn, &id); 247 if (ret != EOK) { 248 log_fatal("Failed to register sound service: %s", 249 str_error(ret)); 250 return -ret; 111 251 } 112 252 113 253 ret = loc_register_cat_change_cb(scan_for_devices); 254 if (ret != EOK) { 255 log_fatal("Failed to register for category changes: %s", 256 str_error(ret)); 257 loc_service_unregister(id); 258 return -ret; 259 } 260 log_info("Running with service id %u", id); 114 261 115 262 scan_for_devices(); 116 117 263 118 264 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.