Index: uspace/app/wavplay/dplay.c
===================================================================
--- uspace/app/wavplay/dplay.c	(revision 76e863c889f2b3966fe2055d34e6956c9598ddd7)
+++ uspace/app/wavplay/dplay.c	(revision 8a7d78cce508b3191513ec7eee495006eb933f36)
@@ -52,4 +52,5 @@
 #define DEFAULT_FRAGMENTS 2
 
+/** Playback helper structure */
 typedef struct {
 	struct {
@@ -66,4 +67,10 @@
 } playback_t;
 
+/**
+ * Initialize playback helper structure.
+ * @param pb Pointer to helper structure to initialize
+ * @param sess Pointer to audio device IPC session
+ * @return
+ */
 static void playback_initialize(playback_t *pb, audio_pcm_sess_t *sess)
 {
@@ -80,5 +87,10 @@
 }
 
-
+/**
+ * Fragment playback callback function.
+ * @param iid IPC call id.
+ * @param icall Pointer to the call structure
+ * @param arg Argument, pointer to the playback helper function
+ */
 static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void* arg)
 {
@@ -125,4 +137,8 @@
 }
 
+/**
+ * Start event based playback.
+ * @param pb Playback helper structure.
+ */
 static void play_fragment(playback_t *pb)
 {
@@ -166,4 +182,10 @@
 }
 
+/**
+ * Count occupied space in a cyclic buffer.
+ * @param pb Playback helper structure.
+ * @param pos read pointer position.
+ * @return Occupied space size.
+ */
 static size_t buffer_occupied(const playback_t *pb, size_t pos)
 {
@@ -176,4 +198,10 @@
 }
 
+/**
+ * Count available space in a cyclic buffer.
+ * @param pb Playback helper structure.
+ * @param pos read pointer position.
+ * @return Free space size.
+ */
 static size_t buffer_avail(const playback_t *pb, size_t pos)
 {
@@ -185,4 +213,8 @@
 }
 
+/**
+ * Size of the space between write pointer and the end of a cyclic buffer
+ * @param pb Playback helper structure.
+ */
 static size_t buffer_remain(const playback_t *pb)
 {
@@ -191,4 +223,9 @@
 }
 
+/**
+ * Move write pointer forward. Wrap around the end.
+ * @param pb Playback helper structure.
+ * @param bytes NUmber of bytes to advance.
+ */
 static void buffer_advance(playback_t *pb, size_t bytes)
 {
@@ -202,5 +239,8 @@
 	printf("%.2lu:%.6lu   "f, time.tv_sec % 100, time.tv_usec, __VA_ARGS__)
 
-
+/**
+ * Start playback using buffer position api.
+ * @param pb Playback helper function.
+ */
 static void play(playback_t *pb)
 {
@@ -217,5 +257,6 @@
 	do {
 		size_t available = buffer_avail(pb, pos);
-		/* Writing might need wrap around the end */
+		/* Writing might need wrap around the end,
+		 * read directly to device buffer */
 		size_t bytes = fread(pb->buffer.write_ptr, sizeof(uint8_t),
 		    min(available, buffer_remain(pb)), pb->source);
@@ -225,4 +266,6 @@
 		    pb->buffer.write_ptr - pb->buffer.base);
 		available -= bytes;
+
+		/* continue if we wrapped around the end */
 		if (available) {
 			bytes = fread(pb->buffer.write_ptr,
@@ -254,4 +297,5 @@
 		    pcm_format_size_to_usec(to_play, &pb->f);
 
+		/* Compute delay time */
 		const useconds_t real_delay = (usecs > work_time)
 		    ? usecs - work_time : 0;
@@ -260,4 +304,5 @@
 		if (real_delay)
 			async_usleep(real_delay);
+		/* update buffer position */
 		const int ret = audio_pcm_get_buffer_pos(pb->device, &pos);
 		if (ret != EOK) {
@@ -265,4 +310,7 @@
 		}
 		getuptime(&time);
+
+		/* we did not use all the space we had,
+		 * that is the end */
 		if (available)
 			break;
@@ -272,4 +320,10 @@
 }
 
+/**
+ * Play audio file usign direct device access.
+ * @param device The device.
+ * @param file The file.
+ * @return Error code.
+ */
 int dplay(const char *device, const char *file)
 {
Index: uspace/app/wavplay/main.c
===================================================================
--- uspace/app/wavplay/main.c	(revision 76e863c889f2b3966fe2055d34e6956c9598ddd7)
+++ uspace/app/wavplay/main.c	(revision 8a7d78cce508b3191513ec7eee495006eb933f36)
@@ -51,4 +51,10 @@
 #define STREAM_BUFFER_SIZE   (64 * 1024)
 
+/**
+ * Play audio file using a new stream on provided context.
+ * @param ctx Provided context.
+ * @param filename File to play.
+ * @return Error code.
+ */
 static int hplay_ctx(hound_context_t *ctx, const char *filename)
 {
@@ -59,4 +65,6 @@
 		return EINVAL;
 	}
+
+	/* Read and parse WAV header */
 	wave_header_t header;
 	size_t read = fread(&header, sizeof(header), 1, source);
@@ -76,12 +84,14 @@
 	}
 
+	/* Allocate buffer and create new context */
+	char * buffer = malloc(READ_SIZE);
+	if (!buffer) {
+		fclose(source);
+		return ENOMEM;
+	}
 	hound_stream_t *stream = hound_stream_create(ctx,
 	    HOUND_STREAM_DRAIN_ON_EXIT, format, STREAM_BUFFER_SIZE);
 
-	char * buffer = malloc(READ_SIZE);
-	if (!buffer) {
-		fclose(source);
-		return ENOMEM;
-	}
+	/* Read and play */
 	while ((read = fread(buffer, sizeof(char), READ_SIZE, source)) > 0) {
 		ret = hound_stream_write(stream, buffer, read);
@@ -92,4 +102,6 @@
 		}
 	}
+
+	/* Cleanup */
 	free(buffer);
 	fclose(source);
@@ -97,4 +109,9 @@
 }
 
+/**
+ * Play audio file via hound server.
+ * @param filename File to play.
+ * @return Error code
+ */
 static int hplay(const char *filename)
 {
@@ -105,4 +122,6 @@
 		return EINVAL;
 	}
+
+	/* Read and parse WAV header */
 	wave_header_t header;
 	size_t read = fread(&header, sizeof(header), 1, source);
@@ -121,4 +140,6 @@
 		return EINVAL;
 	}
+
+	/* Connect new playback context */
 	hound_context_t *hound = hound_context_create_playback(filename,
 	    format, STREAM_BUFFER_SIZE);
@@ -137,4 +158,6 @@
 		return ret;
 	}
+
+	/* Read and play */
 	static char buffer[READ_SIZE];
 	while ((read = fread(buffer, sizeof(char), READ_SIZE, source)) > 0) {
@@ -146,4 +169,6 @@
 		}
 	}
+
+	/* Cleanup */
 	hound_context_destroy(hound);
 	fclose(source);
@@ -151,4 +176,7 @@
 }
 
+/**
+ * Helper structure for playback in separate fibrils
+ */
 typedef struct {
 	hound_context_t *ctx;
@@ -157,4 +185,9 @@
 } fib_play_t;
 
+/**
+ * Fibril playback wrapper.
+ * @param arg Argument, pointer to playback helper structure.
+ * @return Error code.
+ */
 static int play_wrapper(void *arg)
 {
@@ -167,4 +200,7 @@
 }
 
+/**
+ * Array of supported commandline options
+ */
 static const struct option opts[] = {
 	{"device", required_argument, 0, 'd'},
@@ -175,4 +211,8 @@
 };
 
+/**
+ * Print usage help.
+ * @param name Name of the program.
+ */
 static void print_help(const char* name)
 {
@@ -195,4 +235,6 @@
 	optind = 0;
 	int ret = 0;
+
+	/* Parse command line options */
 	while (ret != -1) {
 		ret = getopt_long(argc, argv, "d:prh", opts, &idx);
@@ -227,7 +269,10 @@
 	}
 
+	/* Init parallel playback variables */
 	hound_context_t *hound_ctx = NULL;
 	atomic_t playcount;
 	atomic_set(&playcount, 0);
+
+	/* Init parallel playback context if necessary */
 	if (parallel) {
 		hound_ctx = hound_context_create_playback("wavplay",
@@ -247,4 +292,5 @@
 	}
 
+	/* play or record all files */
 	for (int i = optind; i < argc; ++i) {
 		const char *file = argv[i];
@@ -261,8 +307,10 @@
 			}
 		}
+
 		if (direct) {
 			dplay(device, file);
 		} else {
 			if (parallel) {
+				/* Start new fibril for parallel playback */
 				fib_play_t *data = malloc(sizeof(fib_play_t));
 				if (!data) {
@@ -283,7 +331,9 @@
 	}
 
+	/* Wait for all fibrils to finish */
 	while (atomic_get(&playcount) > 0)
 		async_usleep(1000000);
 
+	/* Destroy parallel playback context, if initialized */
 	if (hound_ctx)
 		hound_context_destroy(hound_ctx);
