VLC 4.0.0-dev
Loading...
Searching...
No Matches
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 *);
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, 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 void (*play)(audio_output_t *, block_t *block, vlc_tick_t date);
186 /**< Queues a block of samples for playback (mandatory, cannot be NULL).
187 *
188 * The first play() date (after a flush()/start()) will be most likely in
189 * the future. They can play a silence buffer with 'length = date - now()',
190 * or configure their render callback to start at the given date.
191 *
192 * \param block block of audio samples
193 * \param date intended system time to render the first sample
194 *
195 * \note This callback cannot be called in stopped state.
196 */
197
198 void (*pause)( audio_output_t *, bool pause, vlc_tick_t date);
199 /**< Pauses or resumes playback (can be NULL).
200 *
201 * This callback pauses or resumes audio playback as quickly as possible.
202 * When pausing, it is desirable to stop producing sound immediately, but
203 * retain already queued audio samples in the buffer to play when later
204 * when resuming.
205 *
206 * If pausing is impossible, the core will flush the module.
207 *
208 * \param pause pause if true, resume from pause if false
209 * \param date timestamp when the pause or resume was requested
210 *
211 * \note This callback cannot be called in stopped state.
212 */
213
214 void (*flush)( audio_output_t *);
215 /**< Flushes the playback buffers (mandatory, cannot be NULL).
216 *
217 * \note This callback cannot be called in stopped state.
218 */
219
220 void (*drain)(audio_output_t *);
221 /**< Drain the playback buffers asynchronously (can be NULL).
222 *
223 * A drain operation can be cancelled by aout->flush() or aout->stop().
224 *
225 * It is legal to continue playback after a drain_async, if flush() is
226 * called before the next play().
227 *
228 * Call aout_DrainedReport() to notify that the stream is drained.
229 *
230 * If NULL, the caller will wait for the delay reported by timing_report
231 * before calling stop().
232 */
233
234 int (*volume_set)(audio_output_t *, float volume);
235 /**< Changes playback volume (optional, may be NULL).
236 *
237 * \param volume requested volume (0. = mute, 1. = nominal)
238 *
239 * \note The volume is always a positive number.
240 *
241 * \warning A stream may or may not have been started when called.
242 * \warning This callback may be called concurrently with
243 * play(), pause() or flush().
244 * It will however be protected against concurrent calls to
245 * start(), stop(), volume_set(), mute_set() or device_select().
246 */
247
248 int (*mute_set)(audio_output_t *, bool mute);
249 /**< Changes muting (optional, may be NULL).
250 *
251 * \param mute true to mute, false to unmute
252 * \warning The same constraints apply as with volume_set().
253 */
254
255 int (*device_select)(audio_output_t *, const char *id);
256 /**< Selects an audio output device (optional, may be NULL).
257 *
258 * \param id nul-terminated device unique identifier.
259 * \return 0 on success, non-zero on failure.
260 *
261 * \warning The same constraints apply as with volume_set().
262 */
263
264 struct {
265 bool headphones; /**< Default to false, set it to true if the current
266 sink is using headphones */
268 /**< Current sink information set by the module from the start() function */
270 const struct vlc_audio_output_events *events;
272
273/**
274 * Report a new timing point
275 *
276 * It is important to report the first point as soon as possible (and the
277 * following points if the audio delay take some time to be stabilized). Once
278 * the audio is stabilized, it is recommended to report timing points every
279 * seconds.
280 *
281 * This function can be called from the play() callback or from any threads
282 * after the first play(). This should not be called after a flush(), a stop(),
283 * a drain() or while paused. After a flush(), play() need to be called again
284 * before reporting a new timing. In that case, audio_ts should start again at
285 * 0 (for the first sample played).
286 *
287 * \param aout the audio output instance
288 * \param system_ts system timestamp when audio_ts is played, based on
289 * vlc_tick_now(), can be now, in the past or in the future.
290 * \param audio_pts audio timestamp played at system_ts, starts at block->i_pts
291 * for the first sample played.
292 */
293static inline void aout_TimingReport(audio_output_t *aout, vlc_tick_t system_ts,
294 vlc_tick_t audio_pts)
295{
296 aout->events->timing_report(aout, system_ts, audio_pts);
297}
298
299/**
300 * Report than the stream is drained (after a call to aout->drain_async)
301 */
302static inline void aout_DrainedReport(audio_output_t *aout)
304 aout->events->drained_report(aout);
305}
306
307/**
308 * Report change of configured audio volume to the core and UI.
309 */
310static inline void aout_VolumeReport(audio_output_t *aout, float volume)
312 aout->events->volume_report(aout, volume);
313}
314
315/**
316 * Report change of muted flag to the core and UI.
317 */
318static inline void aout_MuteReport(audio_output_t *aout, bool mute)
320 aout->events->mute_report(aout, mute);
321}
322
323/**
324 * Report audio policy status.
325 * \param aout the audio output instance reporting the cork policy
326 * \param cork true to request a cork, false to undo any pending cork.
327 */
328static inline void aout_PolicyReport(audio_output_t *aout, bool cork)
330 aout->events->policy_report(aout, cork);
331}
332
333/**
334 * Report change of output device.
335 */
336static inline void aout_DeviceReport(audio_output_t *aout, const char *id)
338 aout->events->device_report(aout, id);
339}
340
341/**
342 * Report a device hot-plug event.
343 * @param aout the audio output instance reporting the new device
344 * @param id device ID
345 * @param name human-readable device name (NULL for hot unplug)
346 */
347static inline void aout_HotplugReport(audio_output_t *aout,
348 const char *id, const char *name)
349{
350 aout->events->hotplug_report(aout, id, name);
351}
352
353/**
354 * Request a change of software audio amplification.
355 * \param aout the audio output instance requesting software gain
356 * \param gain linear amplitude gain (must be positive)
357 * \warning Values in excess 1.0 may cause overflow and distortion.
358 */
359static inline int aout_GainRequest(audio_output_t *aout, float gain)
361 return aout->events->gain_request(aout, gain);
362}
363
364static inline void aout_RestartRequest(audio_output_t *aout, bool restart_dec)
366 aout->events->restart_request(aout, restart_dec);
367}
368
369/** @} */
370
371/**
372 * \defgroup audio_format Audio formats
373 * @{
374 */
375/**
376 * It describes the audio channel order VLC expect.
377 */
378static const uint32_t pi_vlc_chan_order_wg4[] =
386/**
387 * This function computes the reordering needed to go from pi_chan_order_in to
388 * pi_chan_order_out.
389 * If pi_chan_order_in or pi_chan_order_out is NULL, it will assume that vlc
390 * internal (WG4 = pi_vlc_chan_order_wg4) order is requested.
391 * The tables must be 0 terminated.
392 */
393VLC_API unsigned aout_CheckChannelReorder( const uint32_t *pi_chan_order_in,
394 const uint32_t *pi_chan_order_out,
395 uint32_t mask, uint8_t *table );
396
397/**
398 * Reorders audio samples within a block of linear audio interleaved samples.
399 * \param ptr start address of the block of samples
400 * \param bytes size of the block in bytes (must be a multiple of the product
401 * of the channels count and the sample size)
402 * \param channels channels count (also length of the chans_table table)
403 * \param chans_table permutation table to reorder the channels
404 * (usually computed by aout_CheckChannelReorder())
405 * \param fourcc sample format (must be a linear sample format)
406 * \note The samples must be naturally aligned in memory.
407 */
408VLC_API void aout_ChannelReorder(void *ptr, size_t bytes, uint8_t channels,
409 const uint8_t *chans_table,
410 vlc_fourcc_t fourcc);
411
412/**
413 * This function will compute the extraction parameter into pi_selection to go
414 * from i_channels with their type given by pi_order_src[] into the order
415 * describe by pi_order_dst.
416 * It will also set :
417 * - *pi_channels as the number of channels that will be extracted which is
418 * lower (in case of non understood channels type) or equal to i_channels.
419 * - the layout of the channels (*pi_layout).
420 *
421 * It will return true if channel extraction is really needed, in which case
422 * aout_ChannelExtract must be used
423 *
424 * XXX It must be used when the source may have channel type not understood
425 * by VLC. In this case the channel type pi_order_src[] must be set to 0.
426 * XXX It must also be used if multiple channels have the same type.
427 */
428VLC_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 );
429
430/**
431 * Do the actual channels extraction using the parameters created by
432 * aout_CheckChannelExtraction.
433 *
434 * XXX this function does not work in place (p_dst and p_src must not overlap).
435 * XXX Only 8, 16, 32, 64 bits per sample are supported.
436 */
437VLC_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 );
438
439VLC_API void aout_Interleave(void *dst, const void *const *planes,
440 unsigned samples, unsigned channels,
441 vlc_fourcc_t fourcc);
442VLC_API void aout_Deinterleave(void *dst, const void *src, unsigned samples,
443 unsigned channels, vlc_fourcc_t fourcc);
444
445/* */
446static inline unsigned aout_FormatNbChannels(const audio_sample_format_t *fmt)
449}
450
451VLC_API unsigned int aout_BitsPerSample( vlc_fourcc_t i_format ) VLC_USED;
453
454/**
455 * Prints an audio sample format in a human-readable form.
456 */
457VLC_API void aout_FormatPrint(vlc_object_t *, const char *,
458 const audio_sample_format_t *);
459#define aout_FormatPrint(o, t, f) aout_FormatPrint(VLC_OBJECT(o), t, f)
462
463/** @} */
464
465#define AOUT_VOLUME_DEFAULT 256
466#define AOUT_VOLUME_MAX 512
468/**
469 * Gets the volume of the audio output stream (independent of mute).
470 * \return Current audio volume (0. = silent, 1. = nominal),
471 * or a strictly negative value if undefined.
472 */
474
475/**
476 * Sets the volume of the audio output stream.
477 * \note The mute status is not changed.
478 * \return 0 on success, -1 on failure.
479 */
481
482/**
483 * Adjusts the volume.
484 * \param aout the audio output to update the volume for
485 * \param value how much to increase (> 0) or decrease (< 0) the volume
486 * \param volp if non-NULL, will contain contain the resulting volume
487 */
488VLC_API int aout_VolumeUpdate (audio_output_t *aout, int value,
489 float *volp);
490
491/**
492 * Gets the audio output stream mute flag.
493 * \return 0 if not muted, 1 if muted, -1 if undefined.
494 */
496
497/**
498 * Sets the audio output stream mute flag.
499 * \return 0 on success, -1 on failure.
500 */
502
503/**
504 * Gets the currently selected device.
505 * \return the selected device ID (caller must free() it)
506 * NULL if no device is selected or in case of error.
507 */
509
510/**
511 * Selects an audio output device.
512 * \param aout the audio output to set the device for
513 * \param id device ID to select, or NULL for the default device
514 * \return zero on success, non-zero on error.
515 */
516VLC_API int aout_DeviceSet (audio_output_t *aout, const char *id);
517
518/**
519 * Enumerates possible audio output devices.
520 *
521 * The function will heap-allocate two tables of heap-allocated strings;
522 * the caller is responsible for freeing all strings and both tables.
523 *
524 * \param aout the audio output to get the device list from
525 * \param ids pointer to a table of device identifiers [OUT]
526 * \param names pointer to a table of device human-readable descriptions [OUT]
527 * \return the number of devices, or negative on error.
528 * \note In case of error, *ids and *names are undefined.
529 */
530VLC_API int aout_DevicesList (audio_output_t *aout, char ***ids,
531 char ***names);
532
533/** @} */
534
535/**
536 * \defgroup audio_filters Audio filters
537 * \ingroup filters
538 * @{
539 */
540
541/**
542 * Enable or disable an audio filter ("audio-filter")
543 *
544 * \param aout a valid audio output
545 * \param name a valid filter name
546 * \param add true to add the filter, false to remove it
547 * \return 0 on success, non-zero on failure.
548 */
549VLC_API int aout_EnableFilter(audio_output_t *aout, const char *name, bool add);
550
551typedef enum
566static_assert(AOUT_CHANIDX_MAX == AOUT_CHAN_MAX, "channel count mismatch");
567
568#define AOUT_CHAN_REMAP_INIT { \
569 AOUT_CHANIDX_LEFT, \
570 AOUT_CHANIDX_RIGHT, \
571 AOUT_CHANIDX_MIDDLELEFT, \
572 AOUT_CHANIDX_MIDDLERIGHT, \
573 AOUT_CHANIDX_REARLEFT, \
574 AOUT_CHANIDX_REARRIGHT, \
575 AOUT_CHANIDX_REARCENTER, \
576 AOUT_CHANIDX_CENTER, \
577 AOUT_CHANIDX_LFE, \
578}
579
580typedef struct
582 /**
583 * If the remap order differs from the WG4 order, a remap audio filter will
584 * be inserted to remap channels according to this array.
585 */
587 /**
588 * If true, a filter will be inserted to add a headphones effect (like a
589 * binauralizer audio filter).
590 */
591 bool headphones;
593
594#define AOUT_FILTERS_CFG_INIT (aout_filters_cfg_t) \
595 { .remap = AOUT_CHAN_REMAP_INIT, \
596 .headphones = false, \
597 };
598
599typedef struct aout_filters aout_filters_t;
603 const audio_sample_format_t *,
604 const aout_filters_cfg_t *cfg) VLC_USED;
605#define aout_FiltersNew(o,inf,outf,remap) \
606 aout_FiltersNew(VLC_OBJECT(o),inf,outf,remap)
608#define aout_FiltersDelete(o,f) \
609 aout_FiltersDelete(VLC_OBJECT(o),f)
615
616/**
617 * Create a vout from an "visualization" audio filter.
618 *
619 * @warning Can only be called once, from the probe function (Open).
620 *
621 * @return a valid vout or NULL in case of error, the returned vout should not
622 * be freed via vout_Close().
623 */
625
626/** @} */
627
628/**
629 * @defgroup audio_output_meter Audio meter API
630 * \ingroup audio_output
631 * @{
632 */
633
634/**
635 * Audio loudness measurement
636 */
639 /** Momentary loudness (last 400 ms), in LUFS */
640 double loudness_momentary;
641 /** Short term loudness (last 3seconds), in LUFS */
642 double loudness_shortterm;
643 /** Integrated loudness (global), in LUFS */
644 double loudness_integrated;
645 /** Loudness range, in LU */
646 double loudness_range;
647 /** True Peak, in dBTP */
648 double truepeak;
650
651/**
652 * Audio meter callback
653 *
654 * Triggered from vlc_audio_meter_Process() and vlc_audio_meter_Flush().
655 */
658 /**
659 * Called when new loudness measurements are available
660 *
661 * @param date absolute date (likely in the future) of this measurement
662 * @param loudness pointer to the loudness measurement
663 * @param opaque pointer set by vlc_audio_meter_AddPlugin().
664 */
665 void (*on_loudness)(vlc_tick_t date, const struct vlc_audio_loudness *loudness, void *data);
667
668/**
669 * Audio meter plugin opaque structure
670 *
671 * This opaque structure is returned by vlc_audio_meter_AddPlugin().
672 */
675/**
676 * Audio meter plugin owner structure
677 *
678 * Used to setup callbacks and private data
679 *
680 * Can be registered with vlc_audio_meter_AddPlugin().
681 */
684 const struct vlc_audio_meter_cbs *cbs;
685 void *sys;
687
688/**
689 * Audio meter structure
690 *
691 * Initialise with vlc_audio_meter_Init()
692 *
693 * @warning variables of this struct should not be used directly
694 */
695struct vlc_audio_meter
704/**
705 * Initialize the audio meter structure
706 *
707 * @param meter allocated audio meter structure
708 * @param parent object that will be used to create audio filters
709 */
710VLC_API void
712#define vlc_audio_meter_Init(a,b) vlc_audio_meter_Init(a, VLC_OBJECT(b))
714/**
715 * Free allocated resource from the audio meter structure
716 *
717 * @param meter allocated audio meter structure
718 */
719VLC_API void
721
722/**
723 * Set or reset the audio format
724 *
725 * This will reload all plugins added with vlc_audio_meter_AddPlugin()
726 *
727 * @param meter audio meter structure
728 * @param fmt NULL to unload all plugins or a valid pointer to an audio format,
729 * must stay valid during the lifetime of the audio meter (until
730 * vlc_audio_meter_Reset() or vlc_audio_meter_Destroy() are called)
731 *
732 * @return VLC_SUCCESS on success, VLC_EGENERIC if a plugin failed to load
733 */
734VLC_API int
736
737/**
738 * Add an "audio meter" plugin
739 *
740 * The module to be loaded if meter->fmt is valid, otherwise, the module
741 * will be loaded from a next call to vlc_audio_meter_Reset()
742 *
743 * @param meter audio meter structure
744 * @param chain name of the module, can contain specific module options using
745 * the following chain convention:"name{option1=a,option2=b}"
746 * @param owner pointer to a vlc_audio_meter_plugin_owner structure, the
747 * structure must stay valid during the lifetime of the plugin
748 * @return a valid audio meter plugin, or NULL in case of error
749 */
751vlc_audio_meter_AddPlugin(struct vlc_audio_meter *meter, const char *chain,
752 const struct vlc_audio_meter_plugin_owner *owner);
753
754/**
755 * Remove an "audio meter" plugin
756 *
757 * @param meter audio meter structure
758 * @param plugin plugin returned by vlc_audio_meter_AddPlugin()
759 */
760VLC_API void
762
763/**
764 * Process an audio block
765 *
766 * vlc_audio_meter_events callbacks can be triggered from this function.
767 *
768 * @param meter audio meter structure
769 * @param block pointer to a block, this block won't be released of modified
770 * from this function
771 * @param date absolute date (likely in the future) when this block should be rendered
772 */
773VLC_API void
774vlc_audio_meter_Process(struct vlc_audio_meter *meter, block_t *block, vlc_tick_t date);
775
776/**
777 * Flush all "audio meter" plugins
778 *
779 * vlc_audio_meter_events callbacks can be triggered from this function.
780 *
781 * @param meter audio meter structure
782 */
783VLC_API void
785
786/** @} */
787
788#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
The vlc_fourcc_t type.
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:415
block_t * aout_FiltersPlay(aout_filters_t *, block_t *, float rate)
Definition filters.c:790
struct aout_filters aout_filters_t
Definition vlc_aout.h:600
int aout_EnableFilter(audio_output_t *aout, const char *name, bool add)
Enable or disable an audio filter ("audio-filter").
Definition common.c:530
vlc_chan_order_idx_t
Definition vlc_aout.h:553
bool aout_FiltersAdjustResampling(aout_filters_t *, int)
Definition filters.c:778
#define aout_FiltersDelete(o, f)
Definition vlc_aout.h:609
block_t * aout_FiltersDrain(aout_filters_t *)
Definition filters.c:827
#define aout_FiltersNew(o, inf, outf, remap)
Definition vlc_aout.h:606
void aout_FiltersChangeViewpoint(aout_filters_t *, const vlc_viewpoint_t *vp)
Definition filters.c:867
void aout_FiltersFlush(aout_filters_t *)
Definition filters.c:859
@ AOUT_CHANIDX_MAX
Definition vlc_aout.h:564
@ AOUT_CHANIDX_CENTER
Definition vlc_aout.h:562
@ AOUT_CHANIDX_MIDDLELEFT
Definition vlc_aout.h:557
@ AOUT_CHANIDX_DISABLE
Definition vlc_aout.h:554
@ AOUT_CHANIDX_MIDDLERIGHT
Definition vlc_aout.h:558
@ AOUT_CHANIDX_RIGHT
Definition vlc_aout.h:556
@ AOUT_CHANIDX_LFE
Definition vlc_aout.h:563
@ AOUT_CHANIDX_LEFT
Definition vlc_aout.h:555
@ AOUT_CHANIDX_REARLEFT
Definition vlc_aout.h:559
@ AOUT_CHANIDX_REARRIGHT
Definition vlc_aout.h:560
@ AOUT_CHANIDX_REARCENTER
Definition vlc_aout.h:561
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_FormatPrepare(audio_sample_format_t *p_format)
Definition common.c:87
void aout_ChannelReorder(void *ptr, size_t bytes, uint8_t channels, const uint8_t *chans_table, vlc_fourcc_t fourcc)
Reorders audio samples within a block of linear audio interleaved samples.
static unsigned aout_FormatNbChannels(const audio_sample_format_t *fmt)
Definition vlc_aout.h:447
unsigned aout_CheckChannelReorder(const uint32_t *pi_chan_order_in, const uint32_t *pi_chan_order_out, uint32_t mask, uint8_t *table)
This function computes the reordering needed to go from pi_chan_order_in to pi_chan_order_out.
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:436
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:379
#define aout_FormatPrint(o, t, f)
Definition vlc_aout.h:460
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:454
void vlc_audio_meter_Process(struct vlc_audio_meter *meter, block_t *block, vlc_tick_t date)
Process an audio block.
Definition meter.c:189
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:153
void vlc_audio_meter_RemovePlugin(struct vlc_audio_meter *meter, vlc_audio_meter_plugin *plugin)
Remove an "audio meter" plugin.
Definition meter.c:133
#define vlc_audio_meter_Init(a, b)
Definition vlc_aout.h:713
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:88
void vlc_audio_meter_Flush(struct vlc_audio_meter *meter)
Flush all "audio meter" plugins.
Definition meter.c:211
void vlc_audio_meter_Destroy(struct vlc_audio_meter *meter)
Free allocated resource from the audio meter structure.
Definition meter.c:54
static void aout_RestartRequest(audio_output_t *aout, bool restart_dec)
Definition vlc_aout.h:365
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:303
static void aout_TimingReport(audio_output_t *aout, vlc_tick_t system_ts, vlc_tick_t audio_pts)
Report a new timing point.
Definition vlc_aout.h:294
static void aout_MuteReport(audio_output_t *aout, bool mute)
Report change of muted flag to the core and UI.
Definition vlc_aout.h:319
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:311
static void aout_HotplugReport(audio_output_t *aout, const char *id, const char *name)
Report a device hot-plug event.
Definition vlc_aout.h:348
static int aout_GainRequest(audio_output_t *aout, float gain)
Request a change of software audio amplification.
Definition vlc_aout.h:360
static void aout_DeviceReport(audio_output_t *aout, const char *id)
Report change of output device.
Definition vlc_aout.h:337
static void aout_PolicyReport(audio_output_t *aout, bool cork)
Report audio policy status.
Definition vlc_aout.h:329
int aout_VolumeUpdate(audio_output_t *aout, int value, float *volp)
Adjusts the volume.
Definition output.c:851
int aout_DeviceSet(audio_output_t *aout, const char *id)
Selects an audio output device.
Definition output.c:891
int aout_VolumeSet(audio_output_t *, float)
Sets the volume of the audio output stream.
Definition output.c:840
int aout_MuteGet(audio_output_t *)
Gets the audio output stream mute flag.
Definition output.c:870
float aout_VolumeGet(audio_output_t *)
Gets the volume of the audio output stream (independent of mute).
Definition output.c:835
int aout_DevicesList(audio_output_t *aout, char ***ids, char ***names)
Enumerates possible audio output devices.
Definition output.c:902
int aout_MuteSet(audio_output_t *, bool)
Sets the audio output stream mute flag.
Definition output.c:875
char * aout_DeviceGet(audio_output_t *)
Gets the currently selected device.
Definition output.c:886
#define vlc_popcount(x)
Bit weight / population count.
Definition vlc_common.h:676
const char name[16]
Definition httpd.c:1299
Definition vlc_aout.h:582
int remap[AOUT_CHANIDX_MAX]
If the remap order differs from the WG4 order, a remap audio filter will be inserted to remap channel...
Definition vlc_aout.h:587
bool headphones
If true, a filter will be inserted to add a headphones effect (like a binauralizer audio filter).
Definition vlc_aout.h:592
Definition filters.c:366
vlc_channel_mask i_physical_channels
Definition vlc_es.h:75
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:215
bool headphones
Default to false, set it to true if the current sink is using headphones.
Definition vlc_aout.h:266
int(* volume_set)(audio_output_t *, float volume)
Changes playback volume (optional, may be NULL).
Definition vlc_aout.h:235
struct audio_output::@022047323211260327062360324170013071132241043035 current_sink_info
Current sink information set by the module from the start() function.
void(* pause)(audio_output_t *, bool pause, vlc_tick_t date)
Pauses or resumes playback (can be NULL).
Definition vlc_aout.h:199
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:256
int(* mute_set)(audio_output_t *, bool mute)
Changes muting (optional, may be NULL).
Definition vlc_aout.h:249
struct vlc_object_t obj
Definition vlc_aout.h:156
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:186
void(* drain)(audio_output_t *)
Drain the playback buffers asynchronously (can be NULL).
Definition vlc_aout.h:221
const struct vlc_audio_output_events * events
Definition vlc_aout.h:271
void * sys
Private data for callbacks.
Definition vlc_aout.h:158
Structure describing a filter.
Definition vlc_filter.h:221
video format description
Definition vlc_es.h:342
Audio loudness measurement.
Definition vlc_aout.h:639
double loudness_shortterm
Short term loudness (last 3seconds), in LUFS.
Definition vlc_aout.h:643
double loudness_momentary
Momentary loudness (last 400 ms), in LUFS.
Definition vlc_aout.h:641
double truepeak
True Peak, in dBTP.
Definition vlc_aout.h:649
double loudness_integrated
Integrated loudness (global), in LUFS.
Definition vlc_aout.h:645
double loudness_range
Loudness range, in LU.
Definition vlc_aout.h:647
Audio meter callback.
Definition vlc_aout.h:658
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:666
Audio meter plugin owner structure.
Definition vlc_aout.h:684
const struct vlc_audio_meter_cbs * cbs
Definition vlc_aout.h:685
void * sys
Definition vlc_aout.h:686
Definition meter.c:33
Audio meter structure.
Definition vlc_aout.h:697
vlc_object_t * parent
Definition vlc_aout.h:699
const audio_sample_format_t * fmt
Definition vlc_aout.h:700
struct vlc_list plugins
Definition vlc_aout.h:702
vlc_mutex_t lock
Definition vlc_aout.h:698
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(* restart_request)(audio_output_t *, bool)
Definition vlc_aout.h:137
void(* hotplug_report)(audio_output_t *, const char *, const char *)
Definition vlc_aout.h:136
void(* volume_report)(audio_output_t *, float)
Definition vlc_aout.h:132
Doubly-linked list node.
Definition vlc_list.h:44
Mutex.
Definition vlc_threads.h:143
VLC object common members.
Definition vlc_objects.h:53
Viewpoints.
Definition vlc_viewpoint.h:41
Video output thread descriptor.
Definition vlc_vout.h:54
This file is a collection of common definitions and types.
audio_format_t audio_sample_format_t
Definition vlc_common.h:402
struct vlc_frame_t block_t
Definition vlc_common.h:447
struct audio_output audio_output_t
Definition vlc_common.h:401
This file defines the elementary streams format types.
#define AOUT_CHAN_LFE
Definition vlc_es.h:112
#define AOUT_CHAN_REARCENTER
Definition vlc_es.h:107
#define AOUT_CHAN_REARLEFT
Definition vlc_es.h:108
#define AOUT_CHAN_MIDDLELEFT
Definition vlc_es.h:110
#define AOUT_CHAN_MIDDLERIGHT
Definition vlc_es.h:111
#define AOUT_CHAN_REARRIGHT
Definition vlc_es.h:109
#define AOUT_CHAN_MAX
Definition vlc_es.h:140
#define AOUT_CHAN_RIGHT
Definition vlc_es.h:106
#define AOUT_CHAN_CENTER
Definition vlc_es.h:104
#define AOUT_CHAN_LEFT
Definition vlc_es.h:105
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:48