Skip to content
Snippets Groups Projects
Commit 150583b9 authored by Stan Seibert's avatar Stan Seibert
Browse files

The null driver should not be printing junk to stderr unless it is

requested.  Thanks to Joe Drew <hoserhead@woot.net> for pointing this out.


git-svn-id: http://svn.xiph.org/trunk/ao@2365 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent f5a5bd7b
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,11 @@ Null driver. This is just a test device which does not write the
audio data anywhere.
<p>
<b>Option keys:</b> None.
<b>Option keys:</b>
<ul>
<li>"debug" - Print the number of bytes written to the device to stderr
when the device is closed. The option value is ignored.
</ul>
<p>
<hr width="50%">
......
......@@ -25,6 +25,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <ao/ao.h>
static ao_info ao_null_info = {
......@@ -42,6 +43,7 @@ static ao_info ao_null_info = {
typedef struct ao_null_internal {
unsigned long byte_counter;
int debug_output;
} ao_null_internal;
......@@ -67,7 +69,8 @@ static int ao_null_device_init(ao_device *device)
return 0; /* Could not initialize device memory */
internal->byte_counter = 0;
internal->debug_output = 0;
device->internal = internal;
return 1; /* Memory alloc successful */
......@@ -77,7 +80,13 @@ static int ao_null_device_init(ao_device *device)
static int ao_null_set_option(ao_device *device, const char *key,
const char *value)
{
return 1; /* No options! */
ao_null_internal *internal = (ao_null_internal *) device->internal;
if (!strcmp(key, "debug")) {
internal->debug_output = 1;
}
return 1;
}
......@@ -106,8 +115,10 @@ static int ao_null_close(ao_device *device)
{
ao_null_internal *internal = (ao_null_internal *) device->internal;
fprintf(stderr, "ao_null: %ld bytes sent to null device.\n",
internal->byte_counter);
if (internal->debug_output) {
fprintf(stderr, "ao_null: %ld bytes sent to null device.\n",
internal->byte_counter);
}
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment