[vlc-commits] aout: use the vlc_audio_meter API
Thomas Guillem
git at videolan.org
Wed Aug 26 16:01:17 CEST 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Aug 19 16:37:56 2020 +0200| [8e99087c7f12d91b5fd6b8f31b66a14781cf6c05] | committer: Thomas Guillem
aout: use the vlc_audio_meter API
And expose internally:
- aout_AddMeterPlugin()
- aout_RemoveMeterPlugin().
This will allow the player to add and remove "audio meter" plugins.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8e99087c7f12d91b5fd6b8f31b66a14781cf6c05
---
src/audio_output/aout_internal.h | 10 +++++++++-
src/audio_output/dec.c | 13 +++++++++++++
src/audio_output/output.c | 19 +++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 7f7c84bee0..ad71fcc038 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -27,6 +27,7 @@
# include <vlc_atomic.h>
# include <vlc_filter.h>
+# include <vlc_list.h>
# include <vlc_viewpoint.h>
# include "../clock/clock.h"
@@ -95,6 +96,8 @@ typedef struct
aout_filters_cfg_t filters_cfg;
+ struct vlc_audio_meter meter;
+
atomic_uint buffers_lost;
atomic_uint buffers_played;
atomic_uchar restart;
@@ -134,6 +137,12 @@ void aout_Destroy (audio_output_t *);
int aout_OutputNew(audio_output_t *);
void aout_OutputDelete( audio_output_t * p_aout );
+vlc_audio_meter_plugin *
+aout_AddMeterPlugin(audio_output_t *aout, const char *chain,
+ const struct vlc_audio_meter_plugin_owner *owner);
+
+void
+aout_RemoveMeterPlugin(audio_output_t *aout, vlc_audio_meter_plugin *plugin);
/* From common.c : */
void aout_FormatsPrint(vlc_object_t *, const char *,
@@ -199,5 +208,4 @@ filter_t *aout_filter_Create(vlc_object_t *obj, const filter_owner_t *restrict o
const audio_sample_format_t *outfmt,
config_chain_t *cfg, bool const_fmt);
-
#endif /* !LIBVLC_AOUT_INTERNAL_H */
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 40eb33995f..d3e5de9bfe 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -104,6 +104,8 @@ int aout_DecNew(audio_output_t *p_aout, const audio_sample_format_t *p_format,
goto error;
aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format);
+ vlc_audio_meter_Reset(&owner->meter, &owner->mixer_format);
+
if (!owner->bitexact)
{
/* Create the audio filtering "input" pipeline */
@@ -114,6 +116,8 @@ int aout_DecNew(audio_output_t *p_aout, const audio_sample_format_t *p_format,
if (owner->filters == NULL)
{
aout_OutputDelete (p_aout);
+ vlc_audio_meter_Reset(&owner->meter, NULL);
+
error:
aout_volume_Delete (owner->volume);
owner->volume = NULL;
@@ -203,6 +207,10 @@ static int aout_CheckReady (audio_output_t *aout)
}
aout_FiltersSetClockDelay(owner->filters, owner->sync.delay);
}
+
+ vlc_audio_meter_Reset(&owner->meter,
+ owner->mixer_format.i_format ? &owner->mixer_format : NULL);
+
/* TODO: This would be a good time to call clean up any video output
* left over by an audio visualization:
input_resource_TerminatVout(MAGIC HERE); */
@@ -492,6 +500,9 @@ int aout_DecPlay(audio_output_t *aout, block_t *block)
play_date = system_now;
}
+
+ vlc_audio_meter_Process(&owner->meter, block, play_date);
+
/* Output */
owner->sync.discontinuity = false;
aout->play(aout, block, play_date);
@@ -550,6 +561,8 @@ void aout_DecFlush(audio_output_t *aout)
if (owner->mixer_format.i_format)
{
+ vlc_audio_meter_Flush(&owner->meter);
+
if (owner->filters)
aout_FiltersFlush (owner->filters);
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 485aa6fe3c..7c8ed030b0 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -224,6 +224,7 @@ audio_output_t *aout_New (vlc_object_t *parent)
vlc_viewpoint_init (&owner->vp.value);
atomic_init (&owner->vp.update, false);
vlc_atomic_rc_init(&owner->rc);
+ vlc_audio_meter_Init(&owner->meter, aout);
/* Audio output module callbacks */
var_Create (aout, "volume", VLC_VAR_FLOAT);
@@ -363,6 +364,7 @@ void aout_Destroy (audio_output_t *aout)
aout->volume_set = NULL;
aout->mute_set = NULL;
aout->device_select = NULL;
+ vlc_audio_meter_Destroy(&owner->meter);
vlc_mutex_unlock(&owner->lock);
var_DelCallback (aout, "viewpoint", ViewpointCallback, NULL);
@@ -802,3 +804,20 @@ static void aout_ChangeViewpoint(audio_output_t *aout,
atomic_store_explicit(&owner->vp.update, true, memory_order_relaxed);
vlc_mutex_unlock(&owner->vp.lock);
}
+
+vlc_audio_meter_plugin *
+aout_AddMeterPlugin(audio_output_t *aout, const char *chain,
+ const struct vlc_audio_meter_plugin_owner *meter_plugin_owner)
+{
+ aout_owner_t *owner = aout_owner(aout);
+
+ return vlc_audio_meter_AddPlugin(&owner->meter, chain, meter_plugin_owner);
+}
+
+void
+aout_RemoveMeterPlugin(audio_output_t *aout, vlc_audio_meter_plugin *plugin)
+{
+ aout_owner_t *owner = aout_owner(aout);
+
+ vlc_audio_meter_RemovePlugin(&owner->meter, plugin);
+}
More information about the vlc-commits
mailing list