]>
git.ipfire.org Git - thirdparty/shairport-sync.git/blob - audio_dummy.c
2 * dummy output driver. This file is part of Shairport.
3 * Copyright (c) James Laird 2013
6 * Modifications for audio synchronisation
7 * and related work, copyright (c) Mike Brady 2014 -- 2022
10 * Permission is hereby granted, free of charge, to any person
11 * obtaining a copy of this software and associated documentation
12 * files (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use,
14 * copy, modify, merge, publish, distribute, sublicense, and/or
15 * sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
33 #include <inttypes.h> // for PRId64 and friends
38 static int init ( __attribute__ (( unused
)) int argc
, __attribute__ (( unused
)) char ** argv
) { return 0 ; }
40 static void deinit ( void ) {}
42 static void start ( int sample_rate
, __attribute__ (( unused
)) int sample_format
) {
43 debug ( 1 , "dummy audio output started at %d frames per second." , sample_rate
);
46 // Here is a brief explanation of the parameters:
47 // sample_type is 'play_samples_are_untimed' or 'play_samples_are_timed' defined in audio.h.
48 // untimed samples are typically silence used by Shairport Sync itself to set up synchronisation or to fill for missing packets of audio -- the timestamp and playtime are zero.
49 // timed samples come from the client.
50 // timestamp is the RTP timestamp given to the first frame by the client
51 // playtime is when the first frame should to be played. It is given in "local time".
52 // local time is CLOCK_MONOTONIC_RAW if available, or CLOCK_MONOTONIC otherwise, expressed in nanoseconds as an unsigned 64-bit integer (See get_absolute_time_in_ns() in common.c)
55 static int play ( __attribute__ (( unused
)) void * buf
, __attribute__ (( unused
)) int samples
,
56 int sample_type
, uint32_t timestamp
, uint64_t playtime
) {
58 // sample code using some of the extra information
59 if ( sample_type
== play_samples_are_timed
) {
60 int64_t lead_time
= playtime
- get_absolute_time_in_ns ();
61 debug ( 2 , "leadtime for frame %u is %" PRId64
" nanoseconds, i.e. %f seconds." , timestamp
,
62 lead_time
, 0.000000001 * lead_time
);
68 static void stop ( void ) { debug ( 1 , "dummy audio stopped \n " ); }
70 audio_output audio_dummy
= {. name
= "dummy" ,