X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/460b9539a7c15580e41a71bbc0f47ae776238915..af4b13cae1f3755f6edef10c2d19a55b78018cb9:/driver/disorder.c diff --git a/driver/disorder.c b/driver/disorder.c index 8385ae8..e6b6575 100644 --- a/driver/disorder.c +++ b/driver/disorder.c @@ -1,43 +1,50 @@ - /* * This file is part of DisOrder. - * Copyright (C) 2005 Richard Kettlewell + * Copyright (C) 2005, 2007 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . + */ +/** @file driver/disorder.c + * @brief libao driver used by DisOrder + * + * The output from this driver is expected to be fed to @c + * disorder-normalize to convert to the confnigured target format. */ -#include +#include "common.h" -#include -#include #include #include #include #include #include +#include "speaker-protocol.h" + /* extra declarations to help out lazy */ int ao_plugin_test(void); ao_info *ao_plugin_driver_info(void); char *ao_plugin_file_extension(void); -/* private data structure for this driver */ +/** @brief Private data structure for this driver */ struct internal { int fd; /* output file descriptor */ int exit_on_error; /* exit on write error */ + + /** @brief Record of sample format */ + struct stream_header header; + }; /* like write() but never returns EINTR/EAGAIN or short */ @@ -126,10 +133,10 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format) { /* we would like native-order samples */ device->driver_byte_format = AO_FMT_NATIVE; - if(do_write(i->fd, format, sizeof *format) < 0) { - if(i->exit_on_error) exit(-1); - return 0; - } + i->header.rate = format->rate; + i->header.channels = format->channels; + i->header.bits = format->bits; + i->header.endian = ENDIAN_NATIVE; return 1; } @@ -138,6 +145,14 @@ int ao_plugin_play(ao_device *device, const char *output_samples, uint_32 num_bytes) { struct internal *i = device->internal; + /* Fill in and write the header */ + i->header.nbytes = num_bytes; + if(do_write(i->fd, &i->header, sizeof i->header) < 0) { + if(i->exit_on_error) _exit(-1); + return 0; + } + + /* Write the sample data */ if(do_write(i->fd, output_samples, num_bytes) < 0) { if(i->exit_on_error) _exit(-1); return 0; @@ -167,4 +182,3 @@ c-basic-offset:2 comment-column:40 End: */ -/* arch-tag:ru/Jqo0hseWMoSt/ba4Xlw */