Index: uspace/lib/hound/include/hound/client.h
===================================================================
--- uspace/lib/hound/include/hound/client.h	(revision 504f1ea3f50f3bc6ccb462628723e8deff3baf60)
+++ uspace/lib/hound/include/hound/client.h	(revision 9e1800cd0d11714b8a9dd6d7e56a5e435315d57d)
@@ -39,5 +39,5 @@
 #include <async.h>
 #include <stdbool.h>
-#include <pcm/sample_format.h>
+#include <pcm/format.h>
 
 #define DEFAULT_SINK "default"
@@ -48,7 +48,7 @@
 
 hound_context_t * hound_context_create_playback(const char *name,
-    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize);
+    pcm_format_t format, size_t bsize);
 hound_context_t * hound_context_create_capture(const char *name,
-    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize);
+    pcm_format_t format, size_t bsize);
 void hound_context_destroy(hound_context_t *hound);
 
@@ -64,4 +64,11 @@
 int hound_context_disconnect_target(hound_context_t *hound, const char* target);
 
+hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags,
+    pcm_format_t format, size_t bsize);
+void hound_stream_destroy(hound_stream_t *stream);
+
+int hound_stream_write(hound_stream_t *stream, const void *data, size_t size);
+int hound_stream_read(hound_stream_t *stream, void *data, size_t size);
+
 int hound_write_main_stream(hound_context_t *hound,
     const void *data, size_t size);
@@ -69,13 +76,6 @@
 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);
-
-hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags,
-    unsigned channels, unsigned rate, pcm_sample_format_t format);
-void hound_stream_destroy(hound_stream_t *stream);
-
-int hound_stream_write(hound_stream_t *stream, const void *data, size_t size);
-int hound_stream_read(hound_stream_t *stream, void *data, size_t size);
+int hound_write_immediate(hound_context_t *hound,
+    pcm_format_t format, const void *data, size_t size);
 
 
Index: uspace/lib/hound/src/client.c
===================================================================
--- uspace/lib/hound/src/client.c	(revision 504f1ea3f50f3bc6ccb462628723e8deff3baf60)
+++ uspace/lib/hound/src/client.c	(revision 9e1800cd0d11714b8a9dd6d7e56a5e435315d57d)
@@ -42,6 +42,6 @@
 #include <libarch/types.h>
 
+#include "protocol.h"
 #include "client.h"
-#include "protocol.h"
 
 /***
@@ -51,5 +51,7 @@
 typedef struct hound_stream {
 	link_t link;
+	pcm_format_t format;
 	async_exch_t *exch;
+	hound_context_t *context;
 } hound_stream_t;
 
@@ -59,17 +61,15 @@
 	bool record;
 	list_t stream_list;
-	hound_stream_t *main_stream;
 	struct {
-		pcm_sample_format_t sample;
-		unsigned channels;
-		unsigned rate;
+		hound_stream_t *stream;
+		pcm_format_t format;
 		size_t bsize;
-	} main_format;
-	unsigned id;
+	} main;
+	hound_context_id_t id;
 } hound_context_t;
 
 
 static hound_context_t *hound_context_create(const char *name, bool record,
-    unsigned channels, unsigned rate, pcm_sample_format_t format, size_t bsize)
+    pcm_format_t format, size_t bsize)
 {
 	hound_context_t *new_context = malloc(sizeof(hound_context_t));
@@ -85,9 +85,7 @@
 		new_context->record = record;
 		new_context->session = hound_service_connect(HOUND_SERVICE);
-		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;
+		new_context->main.stream = NULL;
+		new_context->main.format = format;
+		new_context->main.bsize = bsize;
 		if (!new_context->session) {
 			free(new_context->name);
@@ -95,7 +93,11 @@
 			return NULL;
 		}
-		async_exch_t *exch = async_exchange_begin(new_context->session);
-		//TODO: register context
-		async_exchange_end(exch);
+		new_context->id = hound_service_register_context(
+		    new_context->session, new_context->name);
+		if (new_context->id <= 0) {
+			free(new_context->name);
+			free(new_context);
+			return NULL;
+		}
 	}
 	return new_context;
@@ -103,13 +105,13 @@
 
 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);
+    pcm_format_t format, size_t bsize)
+{
+	return hound_context_create(name, false, 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);
+    pcm_format_t format, size_t bsize)
+{
+	return hound_context_create(name, true, format, bsize);
 }
 
@@ -117,4 +119,8 @@
 {
 	assert(hound);
+	hound_service_unregister_context(hound->session, hound->id);
+	hound_service_disconnect(hound->session);
+	free(hound->name);
+	free(hound);
 }
 
@@ -156,13 +162,118 @@
 }
 
+hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags,
+    pcm_format_t format, size_t bsize)
+{
+	assert(hound);
+	async_exch_t *stream_exch = async_exchange_begin(hound->session);
+	if (!stream_exch)
+		return NULL;
+	hound_stream_t *new_stream = malloc(sizeof(hound_stream_t));
+	if (new_stream) {
+		link_initialize(&new_stream->link);
+		new_stream->exch = stream_exch;
+		new_stream->format = format;
+		new_stream->context = hound;
+		int ret = hound_service_stream_enter(new_stream->exch,
+		    hound->id, flags, format, bsize);
+		if (ret != EOK) {
+			async_exchange_end(new_stream->exch);
+			free(new_stream);
+			return NULL;
+		}
+		list_append(&new_stream->link, &hound->stream_list);
+	}
+	return new_stream;
+}
+
+void hound_stream_destroy(hound_stream_t *stream)
+{
+	if (stream) {
+		// TODO drain?
+		hound_service_stream_exit(stream->exch);
+		async_exchange_end(stream->exch);
+		list_remove(&stream->link);
+		free(stream);
+	}
+}
+
+int hound_stream_write(hound_stream_t *stream, const void *data, size_t size)
+{
+	assert(stream);
+	if (!data || size == 0)
+		return EBADMEM;
+	return hound_service_stream_write(stream->exch, data, size);
+}
+
+int hound_stream_read(hound_stream_t *stream, void *data, size_t size)
+{
+	assert(stream);
+	if (!data || size == 0)
+		return EBADMEM;
+	return hound_service_stream_read(stream->exch, data, size);
+}
+
+static hound_stream_t * hound_get_main_stream(hound_context_t *hound)
+{
+	assert(hound);
+	if (!hound->main.stream)
+		hound->main.stream = hound_stream_create(hound, 0,
+		    hound->main.format, hound->main.bsize);
+	return hound->main.stream;
+}
+
+int hound_write_main_stream(hound_context_t *hound,
+    const void *data, size_t size)
+{
+	assert(hound);
+	hound_stream_t *mstream = hound_get_main_stream(hound);
+	if (!mstream)
+		return ENOMEM;
+	return hound_stream_write(mstream, data, size);
+}
+
+int hound_read_main_stream(hound_context_t *hound, void *data, size_t size)
+{
+	assert(hound);
+	hound_stream_t *mstream = hound_get_main_stream(hound);
+	if (!mstream)
+		return ENOMEM;
+	return hound_stream_read(mstream, data, size);
+}
+
+int hound_write_replace_main_stream(hound_context_t *hound,
+    const void *data, size_t size)
+{
+	assert(hound);
+	if (!data || size == 0)
+		return EBADMEM;
+	// TODO implement
+	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);
+    unsigned channels, unsigned rate, pcm_sample_format_t format)
+{
+	assert(hound);
+	// TODO implement
+	return ENOTSUP;
+}
+
+int hound_write_immediate(hound_context_t *hound, pcm_format_t format,
+    const void *data, size_t size)
+{
+	assert(hound);
+	hound_stream_t *tmpstream = hound_stream_create(hound, 0, format, size);
+	if (!tmpstream)
+		return ENOMEM;
+	const int ret = hound_stream_write(tmpstream, data, size);
+	if (ret == EOK) {
+		//TODO drain?
+		hound_service_stream_drain(tmpstream->exch);
+	}
+	hound_stream_destroy(tmpstream);
+	return ret;
+}
+
 
 /**
