chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge config aliasing bug fix.
[disorder]
/
driver
/
disorder.c
diff --git
a/driver/disorder.c
b/driver/disorder.c
index 8385ae8a86ef390a8943ca64cdf3445003e09fd4..e6b65752f3fb7eef2189b98abad25d4843990e66 100644
(file)
--- a/
driver/disorder.c
+++ b/
driver/disorder.c
@@
-1,43
+1,50
@@
-
/*
* This file is part of DisOrder.
/*
* 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
* 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.
*
* (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
+ * G
NU G
eneral Public License for more details.
+ *
* You should have received a copy of the GNU General Public License
* 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 <http://www.gnu.org/licenses/>.
+ */
+/** @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
<config.h>
+#include
"common.h"
-#include <string.h>
-#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <poll.h>
#include <ao/ao.h>
#include <ao/plugin.h>
#include <errno.h>
#include <unistd.h>
#include <poll.h>
#include <ao/ao.h>
#include <ao/plugin.h>
+#include "speaker-protocol.h"
+
/* extra declarations to help out lazy <ao/plugin.h> */
int ao_plugin_test(void);
ao_info *ao_plugin_driver_info(void);
char *ao_plugin_file_extension(void);
/* extra declarations to help out lazy <ao/plugin.h> */
int ao_plugin_test(void);
ao_info *ao_plugin_driver_info(void);
char *ao_plugin_file_extension(void);
-/*
p
rivate data structure for this driver */
+/*
* @brief P
rivate data structure for this driver */
struct internal {
int fd; /* output file descriptor */
int exit_on_error; /* exit on write error */
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 */
};
/* 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;
/* we would like native-order samples */
device->driver_byte_format = AO_FMT_NATIVE;
- i
f(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;
}
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;
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;
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:
*/
comment-column:40
End:
*/
-/* arch-tag:ru/Jqo0hseWMoSt/ba4Xlw */