Changeset 89d3946f in mainline
- Timestamp:
- 2013-03-16T23:46:59Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- abaef81
- Parents:
- 6b0cfa1
- Location:
- uspace/lib/hound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/include/hound/client.h
r6b0cfa1 r89d3946f 44 44 #define DEFAULT_SOURCE "default" 45 45 46 typedef struct hound_context hound_context_t; 47 typedef struct hound_stream hound_stream_t; 48 49 hound_context_t * hound_context_create_playback(const char *name, 50 unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize); 51 hound_context_t * hound_context_create_capture(const char *name, 52 unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize); 53 void hound_context_destroy(hound_context_t *hound); 54 55 int hound_context_enable(hound_context_t *hound); 56 int hound_context_disable(hound_context_t *hound); 57 58 int hound_context_set_main_stream_format(hound_context_t *hound, 59 unsigned channels, unsigned rate, pcm_sample_format_t format); 60 int hound_get_output_targets(const char **names, size_t *count); 61 int hound_get_input_targets(const char **names, size_t *count); 62 63 int hound_context_connect_target(hound_context_t *hound, const char* target); 64 int hound_context_disconnect_target(hound_context_t *hound, const char* target); 65 66 int hound_write_main_stream(hound_context_t *hound, 67 const void *data, size_t size); 68 int hound_read_main_stream(hound_context_t *hound, void *data, size_t size); 69 int hound_write_replace_main_stream(hound_context_t *hound, 70 const void *data, size_t size); 71 int hound_write_immediate_stream(hound_context_t *hound, 72 const void *data, size_t size); 73 74 hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags, 75 unsigned channels, unsigned rate, pcm_sample_format_t format); 76 void hound_stream_destroy(hound_stream_t *stream); 77 78 int hound_stream_write(hound_stream_t *stream, const void *data, size_t size); 79 int hound_stream_read(hound_stream_t *stream, void *data, size_t size); 80 81 82 83 84 46 85 typedef async_sess_t hound_sess_t; 47 86 -
uspace/lib/hound/src/protocol.c
r6b0cfa1 r89d3946f 34 34 * Common USB functions. 35 35 */ 36 #include <adt/list.h> 36 37 #include <errno.h> 37 38 #include <loc.h> 38 39 #include <str.h> 39 40 #include <stdlib.h> 41 #include <stdio.h> 42 #include <libarch/types.h> 40 43 41 44 #include "client.h" … … 47 50 * CLIENT SIDE 48 51 ***/ 52 53 typedef struct hound_stream { 54 link_t link; 55 async_exch_t *exch; 56 } hound_stream_t; 57 58 typedef struct hound_context { 59 async_sess_t *session; 60 const char *name; 61 bool record; 62 list_t stream_list; 63 hound_stream_t *main_stream; 64 struct { 65 pcm_sample_format_t sample; 66 unsigned channels; 67 unsigned rate; 68 size_t bsize; 69 } main_format; 70 unsigned id; 71 } hound_context_t; 72 73 async_sess_t *hound_get_session(void) 74 { 75 service_id_t id = 0; 76 const int ret = 77 loc_service_get_id(HOUND_SERVICE, &id, IPC_FLAG_BLOCKING); 78 if (ret != EOK) 79 return NULL; 80 return loc_service_connect(EXCHANGE_SERIALIZE, id, IPC_FLAG_BLOCKING); 81 } 82 83 void hound_release_session(async_sess_t *sess) 84 { 85 if (sess) 86 async_hangup(sess); 87 } 88 89 static hound_context_t *hound_context_create(const char *name, bool record, 90 unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize) 91 { 92 hound_context_t *new_context = malloc(sizeof(hound_context_t)); 93 if (new_context) { 94 char *cont_name; 95 int ret = asprintf(&cont_name, "%llu:%s", task_get_id(), name); 96 if (ret < 0) { 97 free(new_context); 98 return NULL; 99 } 100 list_initialize(&new_context->stream_list); 101 new_context->name = cont_name; 102 new_context->record = record; 103 new_context->session = hound_get_session(); 104 new_context->main_stream = NULL; 105 new_context->main_format.sample = format; 106 new_context->main_format.rate = rate; 107 new_context->main_format.channels = channels; 108 new_context->main_format.bsize = bsize; 109 if (!new_context->session) { 110 free(new_context->name); 111 free(new_context); 112 return NULL; 113 } 114 async_exch_t *exch = async_exchange_begin(new_context->session); 115 //TODO: register context 116 async_exchange_end(exch); 117 } 118 return new_context; 119 } 120 121 hound_context_t * hound_context_create_playback(const char *name, 122 unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize) 123 { 124 return hound_context_create(name, false, channels, rate, format, bsize); 125 } 126 127 hound_context_t * hound_context_create_capture(const char *name, 128 unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize) 129 { 130 return hound_context_create(name, true, channels, rate, format, bsize); 131 } 132 133 void hound_context_destroy(hound_context_t *hound) 134 { 135 assert(hound); 136 } 137 138 int hound_context_enable(hound_context_t *hound) 139 { 140 assert(hound); 141 return ENOTSUP; 142 } 143 int hound_context_disable(hound_context_t *hound) 144 { 145 assert(hound); 146 return ENOTSUP; 147 } 148 149 int hound_get_output_targets(const char **names, size_t *count) 150 { 151 assert(names); 152 assert(count); 153 return ENOTSUP; 154 } 155 156 int hound_get_input_targets(const char **names, size_t *count) 157 { 158 assert(names); 159 assert(count); 160 return ENOTSUP; 161 } 162 163 int hound_context_connect_target(hound_context_t *hound, const char* target) 164 { 165 assert(hound); 166 return ENOTSUP; 167 } 168 169 int hound_context_disconnect_target(hound_context_t *hound, const char* target) 170 { 171 assert(hound); 172 return ENOTSUP; 173 } 174 175 int hound_context_set_main_stream_format(hound_context_t *hound, 176 unsigned channels, unsigned rate, pcm_sample_format_t format); 177 int hound_write_main_stream(hound_context_t *hound, 178 const void *data, size_t size); 179 int hound_read_main_stream(hound_context_t *hound, void *data, size_t size); 180 int hound_write_replace_main_stream(hound_context_t *hound, 181 const void *data, size_t size); 182 int hound_write_immediate_stream(hound_context_t *hound, 183 const void *data, size_t size); 184 185 186 187 188 189 190 49 191 50 192 typedef struct { … … 64 206 65 207 66 hound_sess_t *hound_get_session(void)67 {68 service_id_t id = 0;69 const int ret = loc_service_get_id(HOUND_SERVICE, &id, 0);70 if (ret != EOK)71 return NULL;72 return loc_service_connect(EXCHANGE_SERIALIZE, id, 0);73 }74 void hound_release_session(hound_sess_t *sess)75 {76 if (sess)77 async_hangup(sess);78 }79 208 int hound_register_playback(hound_sess_t *sess, const char *name, 80 209 unsigned channels, unsigned rate, pcm_sample_format_t format,
Note:
See TracChangeset
for help on using the changeset viewer.