Index: uspace/lib/hound/src/protocol.c
===================================================================
--- uspace/lib/hound/src/protocol.c	(revision a9aae16e62a6d224ed168129b4de751cdac35a49)
+++ uspace/lib/hound/src/protocol.c	(revision 89d3946f2bd69be149361dc978ecd1d251f48c76)
@@ -34,8 +34,11 @@
  * Common USB functions.
  */
+#include <adt/list.h>
 #include <errno.h>
 #include <loc.h>
 #include <str.h>
 #include <stdlib.h>
+#include <stdio.h>
+#include <libarch/types.h>
 
 #include "client.h"
@@ -47,4 +50,143 @@
  * CLIENT SIDE
  ***/
+
+typedef struct hound_stream {
+	link_t link;
+	async_exch_t *exch;
+} hound_stream_t;
+
+typedef struct hound_context {
+	async_sess_t *session;
+	const char *name;
+	bool record;
+	list_t stream_list;
+	hound_stream_t *main_stream;
+	struct {
+		pcm_sample_format_t sample;
+		unsigned channels;
+		unsigned rate;
+		size_t bsize;
+	} main_format;
+	unsigned id;
+} hound_context_t;
+
+async_sess_t *hound_get_session(void)
+{
+	service_id_t id = 0;
+	const int ret =
+	    loc_service_get_id(HOUND_SERVICE, &id, IPC_FLAG_BLOCKING);
+	if (ret != EOK)
+		return NULL;
+	return loc_service_connect(EXCHANGE_SERIALIZE, id, IPC_FLAG_BLOCKING);
+}
+
+void hound_release_session(async_sess_t *sess)
+{
+	if (sess)
+		async_hangup(sess);
+}
+
+static hound_context_t *hound_context_create(const char *name, bool record,
+    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize)
+{
+	hound_context_t *new_context = malloc(sizeof(hound_context_t));
+	if (new_context) {
+		char *cont_name;
+		int ret = asprintf(&cont_name, "%llu:%s", task_get_id(), name);
+		if (ret < 0) {
+			free(new_context);
+			return NULL;
+		}
+		list_initialize(&new_context->stream_list);
+		new_context->name = cont_name;
+		new_context->record = record;
+		new_context->session = hound_get_session();
+		new_context->main_stream = NULL;
+		new_context->main_format.sample = format;
+		new_context->main_format.rate = rate;
+		new_context->main_format.channels = channels;
+		new_context->main_format.bsize = bsize;
+		if (!new_context->session) {
+			free(new_context->name);
+			free(new_context);
+			return NULL;
+		}
+		async_exch_t *exch = async_exchange_begin(new_context->session);
+		//TODO: register context
+		async_exchange_end(exch);
+	}
+	return new_context;
+}
+
+hound_context_t * hound_context_create_playback(const char *name,
+    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize)
+{
+	return hound_context_create(name, false, channels, rate, format, bsize);
+}
+
+hound_context_t * hound_context_create_capture(const char *name,
+    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize)
+{
+	return hound_context_create(name, true, channels, rate, format, bsize);
+}
+
+void hound_context_destroy(hound_context_t *hound)
+{
+	assert(hound);
+}
+
+int hound_context_enable(hound_context_t *hound)
+{
+	assert(hound);
+	return ENOTSUP;
+}
+int hound_context_disable(hound_context_t *hound)
+{
+	assert(hound);
+	return ENOTSUP;
+}
+
+int hound_get_output_targets(const char **names, size_t *count)
+{
+	assert(names);
+	assert(count);
+	return ENOTSUP;
+}
+
+int hound_get_input_targets(const char **names, size_t *count)
+{
+	assert(names);
+	assert(count);
+	return ENOTSUP;
+}
+
+int hound_context_connect_target(hound_context_t *hound, const char* target)
+{
+	assert(hound);
+	return ENOTSUP;
+}
+
+int hound_context_disconnect_target(hound_context_t *hound, const char* target)
+{
+	assert(hound);
+	return ENOTSUP;
+}
+
+int hound_context_set_main_stream_format(hound_context_t *hound,
+    unsigned channels, unsigned rate, pcm_sample_format_t format);
+int hound_write_main_stream(hound_context_t *hound,
+    const void *data, size_t size);
+int hound_read_main_stream(hound_context_t *hound, void *data, size_t size);
+int hound_write_replace_main_stream(hound_context_t *hound,
+    const void *data, size_t size);
+int hound_write_immediate_stream(hound_context_t *hound,
+    const void *data, size_t size);
+
+
+
+
+
+
+
 
 typedef struct {
@@ -64,17 +206,4 @@
 
 
-hound_sess_t *hound_get_session(void)
-{
-	service_id_t id = 0;
-	const int ret = loc_service_get_id(HOUND_SERVICE, &id, 0);
-	if (ret != EOK)
-		return NULL;
-	return loc_service_connect(EXCHANGE_SERIALIZE, id, 0);
-}
-void hound_release_session(hound_sess_t *sess)
-{
-	if (sess)
-		async_hangup(sess);
-}
 int hound_register_playback(hound_sess_t *sess, const char *name,
     unsigned channels, unsigned rate, pcm_sample_format_t format,
