forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoreaudio_common.h
112 lines (88 loc) · 4 KB
/
coreaudio_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*****************************************************************************
* coreaudio_common.h: Common AudioUnit code for iOS and macOS
*****************************************************************************
* Copyright (C) 2005 - 2017 VLC authors and VideoLAN
*
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# import "config.h"
#endif
#import <vlc_common.h>
#import <vlc_aout.h>
#import <vlc_threads.h>
#import <AudioUnit/AudioUnit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <os/lock.h>
#define STREAM_FORMAT_MSG(pre, sfm) \
pre "[%f][%4.4s][%u][%u][%u][%u][%u][%u]", \
sfm.mSampleRate, (char *)&sfm.mFormatID, \
(unsigned int)sfm.mFormatFlags, (unsigned int)sfm.mBytesPerPacket, \
(unsigned int)sfm.mFramesPerPacket, (unsigned int)sfm.mBytesPerFrame, \
(unsigned int)sfm.mChannelsPerFrame, (unsigned int)sfm.mBitsPerChannel
#define ca_LogErr(fmt) msg_Err(p_aout, fmt ", OSStatus: %d", (int) err)
#define ca_LogWarn(fmt) msg_Warn(p_aout, fmt ", OSStatus: %d", (int) err)
struct aout_sys_common
{
/* The following is owned by common.c (initialized from ca_Init, cleaned
* from ca_Clean) */
size_t i_underrun_size;
bool b_paused;
bool b_do_flush;
size_t i_out_max_size;
size_t i_out_size;
block_t *p_out_chain;
block_t **pp_out_last;
uint64_t i_render_host_time;
uint32_t i_render_frames;
vlc_sem_t flush_sem;
union lock
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
os_unfair_lock unfair;
#pragma clang diagnostic pop
pthread_mutex_t mutex;
} lock;
int i_rate;
unsigned int i_bytes_per_frame;
unsigned int i_frame_length;
uint8_t chans_to_reorder;
uint8_t chan_table[AOUT_CHAN_MAX];
/* ca_TimeGet extra latency, in micro-seconds */
mtime_t i_dev_latency_us;
};
void ca_Open(audio_output_t *p_aout);
void ca_Close(audio_output_t *p_aout);
void ca_Render(audio_output_t *p_aout, uint32_t i_nb_samples, uint64_t i_host_time,
uint8_t *p_output, size_t i_requested);
int ca_TimeGet(audio_output_t *p_aout, mtime_t *delay);
void ca_Flush(audio_output_t *p_aout, bool wait);
void ca_Pause(audio_output_t * p_aout, bool pause, mtime_t date);
void ca_Play(audio_output_t * p_aout, block_t * p_block);
int ca_Initialize(audio_output_t *p_aout, const audio_sample_format_t *fmt,
mtime_t i_dev_latency_us);
void ca_Uninitialize(audio_output_t *p_aout);
void ca_SetAliveState(audio_output_t *p_aout, bool alive);
AudioUnit au_NewOutputInstance(audio_output_t *p_aout, OSType comp_sub_type);
int au_Initialize(audio_output_t *p_aout, AudioUnit au,
audio_sample_format_t *fmt,
const AudioChannelLayout *outlayout, mtime_t i_dev_latency_us,
bool *warn_configuration);
void au_Uninitialize(audio_output_t *p_aout, AudioUnit au);