Changeset 36774cf in mainline for uspace/lib/hound/src/protocol.c
- Timestamp:
- 2013-03-17T12:50:32Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fe0b448
- Parents:
- abaef81
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/src/protocol.c
rabaef81 r36774cf 45 45 #include "server.h" 46 46 47 const char *HOUND_SERVICE = "audio/hound";47 static const char *HOUND_SERVICE = "audio/hound"; 48 48 49 49 /*** 50 50 * CLIENT SIDE 51 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 context116 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 191 52 192 53 typedef struct {
Note:
See TracChangeset
for help on using the changeset viewer.