2 * stdout output driver. This file is part of Shairport Sync.
3 * Copyright (c) Mike Brady 2015
5 * Based on pipe output driver
6 * Copyright (c) James Laird 2013
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or
14 * sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
40 static int warned
= 0;
42 static void start(__attribute__((unused
)) int sample_rate
,
43 __attribute__((unused
)) int sample_format
) {
48 static int play(void *buf
, int samples
, __attribute__((unused
)) int sample_type
,
49 __attribute__((unused
)) uint32_t timestamp
,
50 __attribute__((unused
)) uint64_t playtime
) {
51 char errorstring
[1024];
52 int rc
= write(fd
, buf
, samples
* 4);
53 if ((rc
< 0) && (warned
== 0)) {
54 strerror_r(errno
, (char *)errorstring
, 1024);
55 warn("Error %d writing to stdout (fd: %d): \"%s\".", errno
, fd
, errorstring
);
61 static void stop(void) {
62 // Do nothing when play stops
65 static int init(__attribute__((unused
)) int argc
, __attribute__((unused
)) char **argv
) {
66 // set up default values first
67 config
.audio_backend_buffer_desired_length
= 1.0;
68 config
.audio_backend_latency_offset
= 0;
70 // get settings from settings file
71 // do the "general" audio options. Note, these options are in the "general" stanza!
72 parse_general_audio_options();
76 static void deinit(void) {
80 audio_output audio_stdout
= {.name
= "stdout",