VLC 4.0.0-dev
vlc_aout.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_aout.h : audio output interface
3 *****************************************************************************
4 * Copyright (C) 2002-2011 VLC authors and VideoLAN
5 *
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22
23#ifndef VLC_AOUT_H
24#define VLC_AOUT_H 1
25
26#include <assert.h>
27#include <vlc_list.h>
28#include <vlc_es.h>
29#include <vlc_threads.h>
30
31/* FIXME to remove once aout.h is cleaned a bit more */
32#include <vlc_block.h>
33
34/**
35 * \defgroup audio_output Audio output
36 * \ingroup output
37 * @{
38 * \file
39 * Audio output modules interface
40 */
41
42/* Buffers which arrive in advance of more than AOUT_MAX_ADVANCE_TIME
43 * will be considered as bogus and be trashed */
44#define AOUT_MAX_ADVANCE_TIME (AOUT_MAX_PREPARE_TIME + VLC_TICK_FROM_SEC(1))
46/* Buffers which arrive in advance of more than AOUT_MAX_PREPARE_TIME
47 * will cause the calling thread to sleep */
48#define AOUT_MAX_PREPARE_TIME VLC_TICK_FROM_SEC(2)
50/* Buffers which arrive after pts - AOUT_MIN_PREPARE_TIME will be trashed
51 * to avoid too heavy resampling */
52#define AOUT_MIN_PREPARE_TIME AOUT_MAX_PTS_ADVANCE
54/* Tolerance values from EBU Recommendation 37 */
55/** Maximum advance of actual audio playback time to coded PTS,
56 * above which downsampling will be performed */
57#define AOUT_MAX_PTS_ADVANCE VLC_TICK_FROM_MS(40)
59/** Maximum delay of actual audio playback time from coded PTS,
60 * above which upsampling will be performed */
61#define AOUT_MAX_PTS_DELAY VLC_TICK_FROM_MS(60)
63/* Max acceptable resampling (in %) */
64#define AOUT_MAX_RESAMPLING 10
66#define AOUT_FMTS_IDENTICAL( p_first, p_second ) ( \
67 ((p_first)->i_format == (p_second)->i_format) \
68 && AOUT_FMTS_SIMILAR(p_first, p_second) )
69
70/* Check if i_rate == i_rate and i_channels == i_channels */
71#define AOUT_FMTS_SIMILAR( p_first, p_second ) ( \
72 ((p_first)->i_rate == (p_second)->i_rate) \
73 && ((p_first)->channel_type == (p_second)->channel_type) \
74 && ((p_first)->i_physical_channels == (p_second)->i_physical_channels)\
75 && ((p_first)->i_chan_mode == (p_second)->i_chan_mode) )
76
77#define AOUT_FMT_LINEAR( p_format ) \
78 (aout_BitsPerSample((p_format)->i_format) != 0)
79
80#define VLC_CODEC_SPDIFL VLC_FOURCC('s','p','d','i')
81#define VLC_CODEC_SPDIFB VLC_FOURCC('s','p','d','b')
83#define AOUT_FMT_SPDIF( p_format ) \
84 ( ((p_format)->i_format == VLC_CODEC_SPDIFL) \
85 || ((p_format)->i_format == VLC_CODEC_SPDIFB) \
86 || ((p_format)->i_format == VLC_CODEC_A52) \
87 || ((p_format)->i_format == VLC_CODEC_DTS) )
88
89#define AOUT_FMT_HDMI( p_format ) \
90 ( (p_format)->i_format == VLC_CODEC_EAC3 \
91 ||(p_format)->i_format == VLC_CODEC_DTSHD \
92 ||(p_format)->i_format == VLC_CODEC_TRUEHD \
93 ||(p_format)->i_format == VLC_CODEC_MLP \
94 )
95
96/* Values used for the audio-channels object variable */
97#define AOUT_VAR_CHAN_UNSET 0 /* must be zero */
98#define AOUT_VAR_CHAN_STEREO 1
99#define AOUT_VAR_CHAN_RSTEREO 2
100#define AOUT_VAR_CHAN_LEFT 3
101#define AOUT_VAR_CHAN_RIGHT 4
102#define AOUT_VAR_CHAN_DOLBYS 5
103/* deprecated: AOUT_VAR_CHAN_HEADPHONES 6, use AOUT_MIX_MODE_BINAURAL */
104#define AOUT_VAR_CHAN_MONO 7
106#define AOUT_MIX_MODE_UNSET 0
107#define AOUT_MIX_MODE_STEREO 1
108#define AOUT_MIX_MODE_BINAURAL 2
109#define AOUT_MIX_MODE_4_0 3
110#define AOUT_MIX_MODE_5_1 4
111#define AOUT_MIX_MODE_7_1 5
113/*****************************************************************************
114 * Main audio output structures
115 *****************************************************************************/
116
117/* Size of a frame for S/PDIF output. */
118#define AOUT_SPDIF_SIZE 6144
120/* Number of samples in an A/52 frame. */
121#define A52_FRAME_NB 1536
123/**
124 * \defgroup audio_output_module Audio output modules
125 * @{
126 */
127
129 void (*timing_report)(audio_output_t *, vlc_tick_t system_ts, vlc_tick_t audio_ts);
131 void (*volume_report)(audio_output_t *, float);
132 void (*mute_report)(audio_output_t *, bool);
134 void (*device_report)(audio_output_t *, const char *);
135 void (*hotplug_report)(audio_output_t *, const char *, const char *);
136 void (*restart_request)(audio_output_t *, unsigned);
137 int (*gain_request)(audio_output_t *, float);
139
140/** Audio output object
141 *
142 * The audio output object is the abstraction for rendering decoded
143 * (or pass-through) audio samples. In addition to playing samples,
144 * the abstraction exposes controls for pause/resume, flush/drain,
145 * changing the volume or mut flag, and listing and changing output device.
146 *
147 * An audio output can be in one of three different states:
148 * stopped, playing or paused.
149 * The audio output is always created in stopped state and is always destroyed
150 * in that state also. It is moved from stopped to playing state by start(),
151 * and from playing or paused states back to stopped state by stop().
152 **/
153struct audio_output
155 struct vlc_object_t obj;
157 void *sys; /**< Private data for callbacks */
159 int (*start)(audio_output_t *, audio_sample_format_t * restrict fmt);
160 /**< Starts a new stream (mandatory, cannot be NULL).
161 *
162 * This callback changes the audio output from stopped to playing state
163 * (if successful). After the callback returns, time_get(), play(),
164 * pause(), flush() and eventually stop() callbacks may be called.
165 *
166 * \param fmt input stream sample format upon entry,
167 * output stream sample format upon return [IN/OUT]
168 * \return VLC_SUCCESS on success, non-zero on failure
169 *
170 * \note This callback can only be called while the audio output is in
171 * stopped state. There can be only one stream per audio output at a time.
172 *
173 * \note This callbacks needs not be reentrant.
174 */
175
176 void (*stop)(audio_output_t *);
177 /**< Stops the existing stream (mandatory, cannot be NULL).
178 *
179 * This callback terminates the current audio stream,
180 * and returns the audio output to stopped state.
181 *
182 * \note This callback needs not be reentrant.
183 */
184
185 int (*time_get)(audio_output_t *, vlc_tick_t * restrict delay);
186 /**< Estimates playback buffer latency (can be NULL).
187 *
188 * This callback computes an estimation of the delay until the current
189 * tail of the audio output buffer would be rendered. This is essential
190 * for (lip) synchronization and long term drift between the audio output
191 * clock and the media upstream clock (if any).
192 *
193 * If the audio output clock is exactly synchronized with the system
194 * monotonic clock (i.e. vlc_tick_now()), then this callback is not
195 * mandatory. In that case, drain must be implemented (since the default
196 * implementation uses the delay to wait for the end of the stream).
197 *
198 * This callback is called before the first play() in order to get the
199 * initial delay (the hw latency). Most modules won't be able to know this
200 * latency before the first play. In that case, they should return -1 and
201 * handle the first play() date, cf. play() documentation.
202 *
203 * \warning It is recommended to report the audio delay via
204 * aout_TimingReport(). In that case, time_get should not be implemented.
205 *
206 * \param delay pointer to the delay until the next sample to be written
207 * to the playback buffer is rendered [OUT]
208 * \return 0 on success, non-zero on failure or lack of data
209 *
210 * \note This callback cannot be called in stopped state.
211 */
212
213 void (*play)(audio_output_t *, block_t *block, vlc_tick_t date);
214 /**< Queues a block of samples for playback (mandatory, cannot be NULL).
215 *
216 * The first play() date (after a flush()/start()) will be most likely in
217 * the future. Modules that don't know the hw latency before a first play
218 * (when they return -1 from the first time_get()) will need to handle
219 * this. They can play a silence buffer with 'length = date - now()', or
220 * configure their render callback to start at the given date.
221 *
222 * \param block block of audio samples
223 * \param date intended system time to render the first sample
224 *
225 * \note This callback cannot be called in stopped state.
226 */
227
228 void (*pause)( audio_output_t *, bool pause, vlc_tick_t date);
229 /**< Pauses or resumes playback (mandatory, cannot be NULL).
230 *
231 * This callback pauses or resumes audio playback as quickly as possible.
232 * When pausing, it is desirable to stop producing sound immediately, but
233 * retain already queued audio samples in the buffer to play when later
234 * when resuming.
235 *
236 * If pausing is impossible, then aout_PauseDefault() can provide a
237 * fallback implementation of this callback.
238 *
239 * \param pause pause if true, resume from pause if false
240 * \param date timestamp when the pause or resume was requested
241 *
242 * \note This callback cannot be called in stopped state.
243 */
244
245 void (*flush)( audio_output_t *);
246 /**< Flushes the playback buffers (mandatory, cannot be NULL).
247 *
248 * \note This callback cannot be called in stopped state.
249 */
250
251 void (*drain)(audio_output_t *);
252 /**< Drain the playback buffers asynchronously (can be NULL).
253 *
254 * A drain operation can be cancelled by aout->flush() or aout->stop().
255 *
256 * It is legal to continue playback after a drain_async, if flush() is
257 * called before the next play().
258 *
259 * Call aout_DrainedReport() to notify that the stream is drained.
260 *
261 * If NULL, the caller will wait for the delay returned by time_get before
262 * calling stop().
263 */
264
265 int (*volume_set)(audio_output_t *, float volume);
266 /**< Changes playback volume (optional, may be NULL).
267 *
268 * \param volume requested volume (0. = mute, 1. = nominal)
269 *
270 * \note The volume is always a positive number.
271 *
272 * \warning A stream may or may not have been started when called.
273 * \warning This callback may be called concurrently with
274 * time_get(), play(), pause() or flush().
275 * It will however be protected against concurrent calls to
276 * start(), stop(), volume_set(), mute_set() or device_select().
277 */
278
279 int (*mute_set)(audio_output_t *, bool mute);
280 /**< Changes muting (optional, may be NULL).
281 *
282 * \param mute true to mute, false to unmute
283 * \warning The same constraints apply as with volume_set().
284 */
285
286 int (*device_select)(audio_output_t *, const char *id);
287 /**< Selects an audio output device (optional, may be NULL).
288 *
289 * \param id nul-terminated device unique identifier.
290 * \return 0 on success, non-zero on failure.
291 *
292 * \warning The same constraints apply as with volume_set().
293 */
294
295 struct {
296 bool headphones; /**< Default to false, set it to true if the current
297 sink is using headphones */
299 /**< Current sink information set by the module from the start() function */
301 const struct vlc_audio_output_events *events;
303
304/**
305 * Report a new timing point
306 *
307 * system_ts doesn't have to be close to vlc_tick_now(). Any valid { system_ts,
308 * audio_ts } points in the past are sufficient to update the clock.
309 *
310 * \note audio_ts starts at 0 and should not take the block PTS into account.
311 *
312 * It is important to report the first point as soon as possible (and the
313 * following points if the audio delay take some time to be stabilized). Once
314 * the audio is stabilized, it is recommended to report timing points every few
315 * seconds.
316 */
317static inline void aout_TimingReport(audio_output_t *aout, vlc_tick_t system_ts,
318 vlc_tick_t audio_ts)
319{
320 aout->events->timing_report(aout, system_ts, audio_ts);
321}
322
323/**
324 * Report than the stream is drained (after a call to aout->drain_async)
325 */
326static inline void aout_DrainedReport(audio_output_t *aout)
328 aout->events->drained_report(aout);
329}
330
331/**
332 * Report change of configured audio volume to the core and UI.
333 */
334static inline void aout_VolumeReport(audio_output_t *aout, float volume)
336 aout->events->volume_report(aout, volume);
337}
338
339/**
340 * Report change of muted flag to the core and UI.
341 */
342static inline void aout_MuteReport(audio_output_t *aout, bool mute)
344 aout->events->mute_report(aout, mute);
345}
346
347/**
348 * Report audio policy status.
349 * \param cork true to request a cork, false to undo any pending cork.
350 */
351static inline void aout_PolicyReport(audio_output_t *aout, bool cork)
353 aout->events->policy_report(aout, cork);
354}
355
356/**
357 * Report change of output device.
358 */
359static inline void aout_DeviceReport(audio_output_t *aout, const char *id)
361 aout->events->device_report(aout, id);
362}
363
364/**
365 * Report a device hot-plug event.
366 * @param id device ID
367 * @param name human-readable device name (NULL for hot unplug)
368 */
369static inline void aout_HotplugReport(audio_output_t *aout,
370 const char *id, const char *name)
371{
372 aout->events->hotplug_report(aout, id, name);
373}
374
375/**
376 * Request a change of software audio amplification.
377 * \param gain linear amplitude gain (must be positive)
378 * \warning Values in excess 1.0 may cause overflow and distorsion.
379 */
380static inline int aout_GainRequest(audio_output_t *aout, float gain)
382 return aout->events->gain_request(aout, gain);
383}
384
385static inline void aout_RestartRequest(audio_output_t *aout, unsigned mode)
387 aout->events->restart_request(aout, mode);
388}
389
390/**
391 * Default implementation for audio_output_t.pause
392 *
393 * \warning This default callback implementation is suboptimal as it will
394 * discard some audio samples.
395 * Do not use this unless there are really no possible better alternatives.
396 */
397static inline void aout_PauseDefault(audio_output_t *aout, bool paused,
399{
400 if (paused)
401 aout->flush(aout);
402 (void) date;
403}
404
405#define AOUT_RESTART_FILTERS 0x1
406#define AOUT_RESTART_OUTPUT (AOUT_RESTART_FILTERS|0x2)
407#define AOUT_RESTART_STEREOMODE (AOUT_RESTART_OUTPUT|0x4)
409/** @} */
410
411/**
412 * \defgroup audio_format Audio formats
413 * @{
414 */
415/**
416 * It describes the audio channel order VLC expect.
417 */
418static const uint32_t pi_vlc_chan_order_wg4[] =
424};
425
426/**
427 * This function computes the reordering needed to go from pi_chan_order_in to
428 * pi_chan_order_out.
429 * If pi_chan_order_in or pi_chan_order_out is NULL, it will assume that vlc
430 * internal (WG4) order is requested.
431 */
432VLC_API unsigned aout_CheckChannelReorder( const uint32_t *, const uint32_t *,
433 uint32_t mask, uint8_t *table );
434
435/**
436 * Reorders audio samples within a block of linear audio interleaved samples.
437 * \param ptr start address of the block of samples
438 * \param bytes size of the block in bytes (must be a multiple of the product
439 * of the channels count and the sample size)
440 * \param channels channels count (also length of the chans_table table)
441 * \param chans_table permutation table to reorder the channels
442 * (usually computed by aout_CheckChannelReorder())
443 * \param fourcc sample format (must be a linear sample format)
444 * \note The samples must be naturally aligned in memory.
445 */
446VLC_API void aout_ChannelReorder(void *, size_t, uint8_t, const uint8_t *, vlc_fourcc_t);
448/**
449 * This function will compute the extraction parameter into pi_selection to go
450 * from i_channels with their type given by pi_order_src[] into the order
451 * describe by pi_order_dst.
452 * It will also set :
453 * - *pi_channels as the number of channels that will be extracted which is
454 * lower (in case of non understood channels type) or equal to i_channels.
455 * - the layout of the channels (*pi_layout).
456 *
457 * It will return true if channel extraction is really needed, in which case
458 * aout_ChannelExtract must be used
459 *
460 * XXX It must be used when the source may have channel type not understood
461 * by VLC. In this case the channel type pi_order_src[] must be set to 0.
462 * XXX It must also be used if multiple channels have the same type.
463 */
464VLC_API bool aout_CheckChannelExtraction( int *pi_selection, uint32_t *pi_layout, int *pi_channels, const uint32_t pi_order_dst[AOUT_CHAN_MAX], const uint32_t *pi_order_src, int i_channels );
465
466/**
467 * Do the actual channels extraction using the parameters created by
468 * aout_CheckChannelExtraction.
469 *
470 * XXX this function does not work in place (p_dst and p_src must not overlap).
471 * XXX Only 8, 16, 32, 64 bits per sample are supported.
472 */
473VLC_API void aout_ChannelExtract( void *p_dst, int i_dst_channels, const void *p_src, int i_src_channels, int i_sample_count, const int *pi_selection, int i_bits_per_sample );
474
475VLC_API void aout_Interleave(void *dst, const void *const *planes,
476 unsigned samples, unsigned channels,
477 vlc_fourcc_t fourcc);
478VLC_API void aout_Deinterleave(void *dst, const void *src, unsigned samples,
479 unsigned channels, vlc_fourcc_t fourcc);
480
481/* */
482static inline unsigned aout_FormatNbChannels(const audio_sample_format_t *fmt)
485}
486
487VLC_API unsigned int aout_BitsPerSample( vlc_fourcc_t i_format ) VLC_USED;
489
490/**
491 * Prints an audio sample format in a human-readable form.
492 */
493VLC_API void aout_FormatPrint(vlc_object_t *, const char *,
494 const audio_sample_format_t *);
495#define aout_FormatPrint(o, t, f) aout_FormatPrint(VLC_OBJECT(o), t, f)
498
499/** @} */
500
501#define AOUT_VOLUME_DEFAULT 256
502#define AOUT_VOLUME_MAX 512
506VLC_API int aout_VolumeUpdate (audio_output_t *, int, float *);
510VLC_API int aout_DeviceSet (audio_output_t *, const char *);
511VLC_API int aout_DevicesList (audio_output_t *, char ***, char ***);
512
513/** @} */
514
515/**
516 * \defgroup audio_filters Audio filters
517 * \ingroup filters
518 * @{
519 */
520
521/**
522 * Enable or disable an audio filter ("audio-filter")
523 *
524 * \param aout a valid audio output
525 * \param name a valid filter name
526 * \param add true to add the filter, false to remove it
527 * \return 0 on success, non-zero on failure.
528 */
529VLC_API int aout_EnableFilter(audio_output_t *aout, const char *name, bool add);
530
531typedef enum
546static_assert(AOUT_CHANIDX_MAX == AOUT_CHAN_MAX, "channel count mismatch");
547
548#define AOUT_CHAN_REMAP_INIT { \
549 AOUT_CHANIDX_LEFT, \
550 AOUT_CHANIDX_RIGHT, \
551 AOUT_CHANIDX_MIDDLELEFT, \
552 AOUT_CHANIDX_MIDDLERIGHT, \
553 AOUT_CHANIDX_REARLEFT, \
554 AOUT_CHANIDX_REARRIGHT, \
555 AOUT_CHANIDX_REARCENTER, \
556 AOUT_CHANIDX_CENTER, \
557 AOUT_CHANIDX_LFE, \
558}
559
560typedef struct
562 /**
563 * If the remap order differs from the WG4 order, a remap audio filter will
564 * be inserted to remap channels according to this array.
565 */
566 int remap[AOUT_CHANIDX_MAX];
567 /**
568 * If true, a filter will be inserted to add a headphones effect (like a
569 * binauralizer audio filter).
570 */
571 bool headphones;
573
574#define AOUT_FILTERS_CFG_INIT (aout_filters_cfg_t) \
575 { .remap = AOUT_CHAN_REMAP_INIT, \
576 .headphones = false, \
577 };
578
579typedef struct aout_filters aout_filters_t;
583 const audio_sample_format_t *,
584 const aout_filters_cfg_t *cfg) VLC_USED;
585#define aout_FiltersNew(o,inf,outf,remap) \
586 aout_FiltersNew(VLC_OBJECT(o),inf,outf,remap)
588#define aout_FiltersDelete(o,f) \
589 aout_FiltersDelete(VLC_OBJECT(o),f)
595
596/**
597 * Create a vout from an "visualization" audio filter.
598 *
599 * @warning Can only be called once, from the probe function (Open).
600 *
601 * @return a valid vout or NULL in case of error, the returned vout should not
602 * be freed via vout_Close().
603 */
605
606/** @} */
607
608/**
609 * @defgroup audio_output_meter Audio meter API
610 * \ingroup audio_output
611 * @{
612 */
613
614/**
615 * Audio loudness measurement
616 */
619 /** Momentary loudness (last 400 ms), in LUFS */
620 double loudness_momentary;
621 /** Short term loudness (last 3seconds), in LUFS */
622 double loudness_shortterm;
623 /** Integrated loudness (global), in LUFS */
624 double loudness_integrated;
625 /** Loudness range, in LU */
626 double loudness_range;
627 /** True Peak, in dBTP */
628 double truepeak;
630
631/**
632 * Audio meter callback
633 *
634 * Triggered from vlc_audio_meter_Process() and vlc_audio_meter_Flush().
635 */
638 /**
639 * Called when new loudness measurements are available
640 *
641 * @param date absolute date (likely in the future) of this measurement
642 * @param loudness pointer to the loudness measurement
643 * @param opaque pointer set by vlc_audio_meter_AddPlugin().
644 */
645 void (*on_loudness)(vlc_tick_t date, const struct vlc_audio_loudness *loudness, void *data);
647
648/**
649 * Audio meter plugin opaque structure
650 *
651 * This opaque structure is returned by vlc_audio_meter_AddPlugin().
652 */
655/**
656 * Audio meter plugin owner structure
657 *
658 * Used to setup callbacks and private data
659 *
660 * Can be registered with vlc_audio_meter_AddPlugin().
661 */
664 const struct vlc_audio_meter_cbs *cbs;
665 void *sys;
667
668/**
669 * Audio meter structure
670 *
671 * Initialise with vlc_audio_meter_Init()
672 *
673 * @warning variables of this struct should not be used directly
674 */
675struct vlc_audio_meter
681 struct vlc_list plugins;
683
684/**
685 * Initialize the audio meter structure
686 *
687 * @param meter allocated audio meter structure
688 * @param parent object that will be used to create audio filters
689 */
690VLC_API void
692#define vlc_audio_meter_Init(a,b) vlc_audio_meter_Init(a, VLC_OBJECT(b))
694/**
695 * Free allocated resource from the audio meter structure
696 *
697 * @param meter allocated audio meter structure
698 */
699VLC_API void
701
702/**
703 * Set or reset the audio format
704 *
705 * This will reload all plugins added with vlc_audio_meter_AddPlugin()
706 *
707 * @param meter audio meter structure
708 * @param fmt NULL to unload all plugins or a valid pointer to an audio format,
709 * must stay valid during the lifetime of the audio meter (until
710 * vlc_audio_meter_Reset() or vlc_audio_meter_Destroy() are called)
711 *
712 * @return VLC_SUCCESS on success, VLC_EGENERIC if a plugin failed to load
713 */
714VLC_API int
716
717/**
718 * Add an "audio meter" plugin
719 *
720 * The module to be loaded if meter->fmt is valid, otherwise, the module
721 * will be loaded from a next call to vlc_audio_meter_Reset()
722 *
723 * @param meter audio meter structure
724 * @param chain name of the module, can contain specific module options using
725 * the following chain convention:"name{option1=a,option2=b}"
726 * @param owner pointer to a vlc_audio_meter_plugin_owner structure, the
727 * structure must stay valid during the lifetime of the plugin
728 * @return a valid audio meter plugin, or NULL in case of error
729 */
731vlc_audio_meter_AddPlugin(struct vlc_audio_meter *meter, const char *chain,
732 const struct vlc_audio_meter_plugin_owner *owner);
733
734/**
735 * Remove an "audio meter" plugin
736 *
737 * @param meter audio meter structure
738 * @param plugin plugin returned by vlc_audio_meter_AddPlugin()
739 */
740VLC_API void
742
743/**
744 * Process an audio block
745 *
746 * vlc_audio_meter_events callbacks can be triggered from this function.
747 *
748 * @param meter audio meter structure
749 * @param block pointer to a block, this block won't be released of modified
750 * from this function
751 * @param date absolute date (likely in the future) when this block should be rendered
752 */
753VLC_API void
754vlc_audio_meter_Process(struct vlc_audio_meter *meter, block_t *block, vlc_tick_t date);
755
756/**
757 * Flush all "audio meter" plugins
758 *
759 * vlc_audio_meter_events callbacks can be triggered from this function.
760 *
761 * @param meter audio meter structure
762 */
763VLC_API void
765
766/** @} */
767
768#endif /* VLC_AOUT_H */
#define VLC_USED
Definition: fourcc_gen.c:32
#define VLC_API
Definition: fourcc_gen.c:31
uint32_t vlc_fourcc_t
Definition: fourcc_gen.c:33
vout_thread_t * aout_filter_GetVout(filter_t *, const video_format_t *)
Create a vout from an "visualization" audio filter.
Definition: filters.c:414
block_t * aout_FiltersPlay(aout_filters_t *, block_t *, float rate)
Definition: filters.c:779
int aout_EnableFilter(audio_output_t *aout, const char *name, bool add)
Enable or disable an audio filter ("audio-filter")
Definition: common.c:525
vlc_chan_order_idx_t
Definition: vlc_aout.h:533
bool aout_FiltersAdjustResampling(aout_filters_t *, int)
Definition: filters.c:767
#define aout_FiltersDelete(o, f)
Definition: vlc_aout.h:589
block_t * aout_FiltersDrain(aout_filters_t *)
Definition: filters.c:816
#define aout_FiltersNew(o, inf, outf, remap)
Definition: vlc_aout.h:586
void aout_FiltersChangeViewpoint(aout_filters_t *, const vlc_viewpoint_t *vp)
Definition: filters.c:856
void aout_FiltersFlush(aout_filters_t *)
Definition: filters.c:848
@ AOUT_CHANIDX_MAX
Definition: vlc_aout.h:544
@ AOUT_CHANIDX_CENTER
Definition: vlc_aout.h:542
@ AOUT_CHANIDX_MIDDLELEFT
Definition: vlc_aout.h:537
@ AOUT_CHANIDX_DISABLE
Definition: vlc_aout.h:534
@ AOUT_CHANIDX_MIDDLERIGHT
Definition: vlc_aout.h:538
@ AOUT_CHANIDX_RIGHT
Definition: vlc_aout.h:536
@ AOUT_CHANIDX_LFE
Definition: vlc_aout.h:543
@ AOUT_CHANIDX_LEFT
Definition: vlc_aout.h:535
@ AOUT_CHANIDX_REARLEFT
Definition: vlc_aout.h:539
@ AOUT_CHANIDX_REARRIGHT
Definition: vlc_aout.h:540
@ AOUT_CHANIDX_REARCENTER
Definition: vlc_aout.h:541
void aout_Deinterleave(void *dst, const void *src, unsigned samples, unsigned channels, vlc_fourcc_t fourcc)
void aout_Interleave(void *dst, const void *const *planes, unsigned samples, unsigned channels, vlc_fourcc_t fourcc)
unsigned int aout_BitsPerSample(vlc_fourcc_t i_format)
Definition: common.c:41
void aout_ChannelReorder(void *, size_t, uint8_t, const uint8_t *, vlc_fourcc_t)
Reorders audio samples within a block of linear audio interleaved samples.
void aout_FormatPrepare(audio_sample_format_t *p_format)
Definition: common.c:87
static unsigned aout_FormatNbChannels(const audio_sample_format_t *fmt)
Definition: vlc_aout.h:483
void aout_ChannelExtract(void *p_dst, int i_dst_channels, const void *p_src, int i_src_channels, int i_sample_count, const int *pi_selection, int i_bits_per_sample)
Do the actual channels extraction using the parameters created by aout_CheckChannelExtraction.
Definition: common.c:431
const char * aout_FormatPrintChannels(const audio_sample_format_t *)
Definition: common.c:105
static const uint32_t pi_vlc_chan_order_wg4[]
It describes the audio channel order VLC expect.
Definition: vlc_aout.h:419
#define aout_FormatPrint(o, t, f)
Definition: vlc_aout.h:496
unsigned aout_CheckChannelReorder(const uint32_t *, const uint32_t *, uint32_t mask, uint8_t *table)
This function computes the reordering needed to go from pi_chan_order_in to pi_chan_order_out.
bool aout_CheckChannelExtraction(int *pi_selection, uint32_t *pi_layout, int *pi_channels, const uint32_t pi_order_dst[9], const uint32_t *pi_order_src, int i_channels)
This function will compute the extraction parameter into pi_selection to go from i_channels with thei...
Definition: common.c:449
void vlc_audio_meter_Process(struct vlc_audio_meter *meter, block_t *block, vlc_tick_t date)
Process an audio block.
Definition: meter.c:194
int vlc_audio_meter_Reset(struct vlc_audio_meter *meter, const audio_sample_format_t *fmt)
Set or reset the audio format.
Definition: meter.c:156
void vlc_audio_meter_RemovePlugin(struct vlc_audio_meter *meter, vlc_audio_meter_plugin *plugin)
Remove an "audio meter" plugin.
Definition: meter.c:134
#define vlc_audio_meter_Init(a, b)
Definition: vlc_aout.h:693
vlc_audio_meter_plugin * vlc_audio_meter_AddPlugin(struct vlc_audio_meter *meter, const char *chain, const struct vlc_audio_meter_plugin_owner *owner)
Add an "audio meter" plugin.
Definition: meter.c:89
void vlc_audio_meter_Flush(struct vlc_audio_meter *meter)
Flush all "audio meter" plugins.
Definition: meter.c:216
void vlc_audio_meter_Destroy(struct vlc_audio_meter *meter)
Free allocated resource from the audio meter structure.
Definition: meter.c:55
static void aout_RestartRequest(audio_output_t *aout, unsigned mode)
Definition: vlc_aout.h:386
static void aout_DrainedReport(audio_output_t *aout)
Report than the stream is drained (after a call to aout->drain_async)
Definition: vlc_aout.h:327
static void aout_PauseDefault(audio_output_t *aout, bool paused, vlc_tick_t date)
Default implementation for audio_output_t.pause.
Definition: vlc_aout.h:398
static void aout_MuteReport(audio_output_t *aout, bool mute)
Report change of muted flag to the core and UI.
Definition: vlc_aout.h:343
static void aout_TimingReport(audio_output_t *aout, vlc_tick_t system_ts, vlc_tick_t audio_ts)
Report a new timing point.
Definition: vlc_aout.h:318
static void aout_VolumeReport(audio_output_t *aout, float volume)
Report change of configured audio volume to the core and UI.
Definition: vlc_aout.h:335
static void aout_HotplugReport(audio_output_t *aout, const char *id, const char *name)
Report a device hot-plug event.
Definition: vlc_aout.h:370
static int aout_GainRequest(audio_output_t *aout, float gain)
Request a change of software audio amplification.
Definition: vlc_aout.h:381
static void aout_DeviceReport(audio_output_t *aout, const char *id)
Report change of output device.
Definition: vlc_aout.h:360
static void aout_PolicyReport(audio_output_t *aout, bool cork)
Report audio policy status.
Definition: vlc_aout.h:352
int aout_VolumeSet(audio_output_t *, float)
Sets the volume of the audio output stream.
Definition: output.c:838
int aout_MuteGet(audio_output_t *)
Gets the audio output stream mute flag.
Definition: output.c:880
int aout_DevicesList(audio_output_t *, char ***, char ***)
Enumerates possible audio output devices.
Definition: output.c:937
int aout_DeviceSet(audio_output_t *, const char *)
Selects an audio output device.
Definition: output.c:915
float aout_VolumeGet(audio_output_t *)
Gets the volume of the audio output stream (independent of mute).
Definition: output.c:828
int aout_VolumeUpdate(audio_output_t *, int, float *)
Raises the volume.
Definition: output.c:854
int aout_MuteSet(audio_output_t *, bool)
Sets the audio output stream mute flag.
Definition: output.c:889
char * aout_DeviceGet(audio_output_t *)
Gets the currently selected device.
Definition: output.c:905
#define vlc_popcount(x)
Bit weight / population count.
Definition: vlc_common.h:760
const char name[16]
Definition: httpd.c:1281
Definition: vlc_aout.h:562
bool headphones
If true, a filter will be inserted to add a headphones effect (like a binauralizer audio filter).
Definition: vlc_aout.h:572
Definition: filters.c:368
audio format description
Definition: vlc_es.h:82
uint16_t i_physical_channels
Definition: vlc_es.h:88
Audio output object.
Definition: vlc_aout.h:155
void(* flush)(audio_output_t *)
Flushes the playback buffers (mandatory, cannot be NULL).
Definition: vlc_aout.h:246
bool headphones
Default to false, set it to true if the current sink is using headphones.
Definition: vlc_aout.h:297
int(* volume_set)(audio_output_t *, float volume)
Changes playback volume (optional, may be NULL).
Definition: vlc_aout.h:266
void(* pause)(audio_output_t *, bool pause, vlc_tick_t date)
Pauses or resumes playback (mandatory, cannot be NULL).
Definition: vlc_aout.h:229
int(* start)(audio_output_t *, audio_sample_format_t *restrict fmt)
Starts a new stream (mandatory, cannot be NULL).
Definition: vlc_aout.h:160
int(* device_select)(audio_output_t *, const char *id)
Selects an audio output device (optional, may be NULL).
Definition: vlc_aout.h:287
int(* mute_set)(audio_output_t *, bool mute)
Changes muting (optional, may be NULL).
Definition: vlc_aout.h:280
struct vlc_object_t obj
Definition: vlc_aout.h:156
struct audio_output::@188 current_sink_info
Current sink information set by the module from the start() function.
void(* stop)(audio_output_t *)
Stops the existing stream (mandatory, cannot be NULL).
Definition: vlc_aout.h:177
void(* play)(audio_output_t *, block_t *block, vlc_tick_t date)
Queues a block of samples for playback (mandatory, cannot be NULL).
Definition: vlc_aout.h:214
void(* drain)(audio_output_t *)
Drain the playback buffers asynchronously (can be NULL).
Definition: vlc_aout.h:252
const struct vlc_audio_output_events * events
Definition: vlc_aout.h:302
void * sys
Private data for callbacks.
Definition: vlc_aout.h:158
int(* time_get)(audio_output_t *, vlc_tick_t *restrict delay)
Estimates playback buffer latency (can be NULL).
Definition: vlc_aout.h:186
Structure describing a filter.
Definition: vlc_filter.h:216
video format description
Definition: vlc_es.h:352
Audio loudness measurement.
Definition: vlc_aout.h:619
double loudness_shortterm
Short term loudness (last 3seconds), in LUFS.
Definition: vlc_aout.h:623
double loudness_momentary
Momentary loudness (last 400 ms), in LUFS.
Definition: vlc_aout.h:621
double truepeak
True Peak, in dBTP.
Definition: vlc_aout.h:629
double loudness_integrated
Integrated loudness (global), in LUFS.
Definition: vlc_aout.h:625
double loudness_range
Loudness range, in LU.
Definition: vlc_aout.h:627
Audio meter callback.
Definition: vlc_aout.h:638
void(* on_loudness)(vlc_tick_t date, const struct vlc_audio_loudness *loudness, void *data)
Called when new loudness measurements are available.
Definition: vlc_aout.h:646
Audio meter plugin owner structure.
Definition: vlc_aout.h:664
const struct vlc_audio_meter_cbs * cbs
Definition: vlc_aout.h:665
void * sys
Definition: vlc_aout.h:666
Definition: meter.c:34
Audio meter structure.
Definition: vlc_aout.h:677
vlc_object_t * parent
Definition: vlc_aout.h:679
const audio_sample_format_t * fmt
Definition: vlc_aout.h:680
struct vlc_list plugins
Definition: vlc_aout.h:682
vlc_mutex_t lock
Definition: vlc_aout.h:678
Definition: vlc_aout.h:129
void(* policy_report)(audio_output_t *, bool)
Definition: vlc_aout.h:134
int(* gain_request)(audio_output_t *, float)
Definition: vlc_aout.h:138
void(* drained_report)(audio_output_t *)
Definition: vlc_aout.h:131
void(* mute_report)(audio_output_t *, bool)
Definition: vlc_aout.h:133
void(* device_report)(audio_output_t *, const char *)
Definition: vlc_aout.h:135
void(* timing_report)(audio_output_t *, vlc_tick_t system_ts, vlc_tick_t audio_ts)
Definition: vlc_aout.h:130
void(* hotplug_report)(audio_output_t *, const char *, const char *)
Definition: vlc_aout.h:136
void(* restart_request)(audio_output_t *, unsigned)
Definition: vlc_aout.h:137
void(* volume_report)(audio_output_t *, float)
Definition: vlc_aout.h:132
Definition: vlc_frame.h:123
Doubly-linked list node.
Definition: vlc_list.h:44
Mutex.
Definition: vlc_threads.h:195
VLC object common members.
Definition: vlc_objects.h:45
Viewpoints.
Definition: vlc_viewpoint.h:41
Video output thread descriptor.
Definition: vlc_vout.h:55
This file is a collection of common definitions and types.
This file defines the elementary streams format types.
#define AOUT_CHAN_LFE
Definition: vlc_es.h:125
#define AOUT_CHAN_REARCENTER
Definition: vlc_es.h:120
#define AOUT_CHAN_REARLEFT
Definition: vlc_es.h:121
#define AOUT_CHAN_MIDDLELEFT
Definition: vlc_es.h:123
#define AOUT_CHAN_MIDDLERIGHT
Definition: vlc_es.h:124
#define AOUT_CHAN_REARRIGHT
Definition: vlc_es.h:122
#define AOUT_CHAN_MAX
Definition: vlc_es.h:153
#define AOUT_CHAN_RIGHT
Definition: vlc_es.h:119
#define AOUT_CHAN_CENTER
Definition: vlc_es.h:117
#define AOUT_CHAN_LEFT
Definition: vlc_es.h:118
This provides convenience helpers for linked lists.
Thread primitive declarations.
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45