demux: mkv: ProcessNavAction: negate if to prevent nesting
[vlc.git] / modules / audio_output / coreaudio_common.h
blobead0c34e9e2d12b82ac3bbd155713c565da91ea1
1 /*****************************************************************************
2 * coreaudio_common.h: Common AudioUnit code for iOS and macOS
3 *****************************************************************************
4 * Copyright (C) 2005 - 2017 VLC authors and VideoLAN
6 * Authors: Derk-Jan Hartman <hartman at videolan dot org>
7 * Felix Paul Kühne <fkuehne at videolan dot org>
8 * David Fuhrmann <david dot fuhrmann at googlemail dot com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifdef HAVE_CONFIG_H
26 # import "config.h"
27 #endif
29 #import <vlc_common.h>
30 #import <vlc_aout.h>
31 #import <vlc_threads.h>
33 #import <AudioUnit/AudioUnit.h>
34 #import <AudioToolbox/AudioToolbox.h>
35 #import <os/lock.h>
37 #define STREAM_FORMAT_MSG(pre, sfm) \
38 pre "[%f][%4.4s][%u][%u][%u][%u][%u][%u]", \
39 sfm.mSampleRate, (char *)&sfm.mFormatID, \
40 (unsigned int)sfm.mFormatFlags, (unsigned int)sfm.mBytesPerPacket, \
41 (unsigned int)sfm.mFramesPerPacket, (unsigned int)sfm.mBytesPerFrame, \
42 (unsigned int)sfm.mChannelsPerFrame, (unsigned int)sfm.mBitsPerChannel
44 #define ca_LogErr(fmt) msg_Err(p_aout, fmt ", OSStatus: %d", (int) err)
45 #define ca_LogWarn(fmt) msg_Warn(p_aout, fmt ", OSStatus: %d", (int) err)
47 struct aout_sys_common
49 /* The following is owned by common.c (initialized from ca_Init, cleaned
50 * from ca_Clean) */
52 size_t i_underrun_size;
53 bool b_paused;
54 bool b_do_flush;
56 size_t i_out_max_size;
57 size_t i_out_size;
58 block_t *p_out_chain;
59 block_t **pp_out_last;
60 uint64_t i_render_host_time;
61 uint32_t i_render_frames;
63 vlc_sem_t flush_sem;
65 union lock
67 #pragma clang diagnostic push
68 #pragma clang diagnostic ignored "-Wpartial-availability"
69 os_unfair_lock unfair;
70 #pragma clang diagnostic pop
71 pthread_mutex_t mutex;
72 } lock;
74 int i_rate;
75 unsigned int i_bytes_per_frame;
76 unsigned int i_frame_length;
77 uint8_t chans_to_reorder;
78 uint8_t chan_table[AOUT_CHAN_MAX];
79 /* ca_TimeGet extra latency, in micro-seconds */
80 vlc_tick_t i_dev_latency_us;
83 void ca_Open(audio_output_t *p_aout);
85 void ca_Close(audio_output_t *p_aout);
87 void ca_Render(audio_output_t *p_aout, uint32_t i_nb_samples, uint64_t i_host_time,
88 uint8_t *p_output, size_t i_requested);
90 int ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay);
92 void ca_Flush(audio_output_t *p_aout, bool wait);
94 void ca_Pause(audio_output_t * p_aout, bool pause, vlc_tick_t date);
96 void ca_Play(audio_output_t * p_aout, block_t * p_block, vlc_tick_t date);
98 int ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
99 vlc_tick_t i_dev_latency_us);
101 void ca_Uninitialize(audio_output_t *p_aout);
103 void ca_SetAliveState(audio_output_t *p_aout, bool alive);
105 AudioUnit au_NewOutputInstance(audio_output_t *p_aout, OSType comp_sub_type);
107 int au_Initialize(audio_output_t *p_aout, AudioUnit au,
108 audio_sample_format_t *fmt,
109 const AudioChannelLayout *outlayout, vlc_tick_t i_dev_latency_us,
110 bool *warn_configuration);
112 void au_Uninitialize(audio_output_t *p_aout, AudioUnit au);