[vlc-commits] aout: move aout events to truly separate structure
Rémi Denis-Courmont
git at videolan.org
Thu May 3 17:44:52 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 3 15:48:12 2018 +0300| [590d7c6ee86b39dfececc295d8ab9df1e04af8fc] | committer: Rémi Denis-Courmont
aout: move aout events to truly separate structure
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=590d7c6ee86b39dfececc295d8ab9df1e04af8fc
---
include/vlc_aout.h | 34 ++++++++++++++++++----------------
src/audio_output/output.c | 18 +++++++++++-------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index e260209346..97e6468da2 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -111,6 +111,16 @@
/* FIXME to remove once aout.h is cleaned a bit more */
#include <vlc_block.h>
+struct vlc_audio_output_events {
+ void (*volume_report)(audio_output_t *, float);
+ void (*mute_report)(audio_output_t *, bool);
+ void (*policy_report)(audio_output_t *, bool);
+ void (*device_report)(audio_output_t *, const char *);
+ void (*hotplug_report)(audio_output_t *, const char *, const char *);
+ void (*restart_request)(audio_output_t *, unsigned);
+ int (*gain_request)(audio_output_t *, float);
+};
+
/** Audio output object */
struct audio_output
{
@@ -176,15 +186,7 @@ struct audio_output
} current_sink_info;
/**< Current sink informations set by the module from the start() function */
- struct {
- void (*volume_report)(audio_output_t *, float);
- void (*mute_report)(audio_output_t *, bool);
- void (*policy_report)(audio_output_t *, bool);
- void (*device_report)(audio_output_t *, const char *);
- void (*hotplug_report)(audio_output_t *, const char *, const char *);
- int (*gain_request)(audio_output_t *, float);
- void (*restart_request)(audio_output_t *, unsigned);
- } event;
+ const struct vlc_audio_output_events *events;
};
typedef enum
@@ -308,7 +310,7 @@ VLC_API int aout_DevicesList (audio_output_t *, char ***, char ***);
*/
static inline void aout_VolumeReport(audio_output_t *aout, float volume)
{
- aout->event.volume_report(aout, volume);
+ aout->events->volume_report(aout, volume);
}
/**
@@ -316,7 +318,7 @@ static inline void aout_VolumeReport(audio_output_t *aout, float volume)
*/
static inline void aout_MuteReport(audio_output_t *aout, bool mute)
{
- aout->event.mute_report(aout, mute);
+ aout->events->mute_report(aout, mute);
}
/**
@@ -325,7 +327,7 @@ static inline void aout_MuteReport(audio_output_t *aout, bool mute)
*/
static inline void aout_PolicyReport(audio_output_t *aout, bool cork)
{
- aout->event.policy_report(aout, cork);
+ aout->events->policy_report(aout, cork);
}
/**
@@ -333,7 +335,7 @@ static inline void aout_PolicyReport(audio_output_t *aout, bool cork)
*/
static inline void aout_DeviceReport(audio_output_t *aout, const char *id)
{
- aout->event.device_report(aout, id);
+ aout->events->device_report(aout, id);
}
/**
@@ -344,7 +346,7 @@ static inline void aout_DeviceReport(audio_output_t *aout, const char *id)
static inline void aout_HotplugReport(audio_output_t *aout,
const char *id, const char *name)
{
- aout->event.hotplug_report(aout, id, name);
+ aout->events->hotplug_report(aout, id, name);
}
/**
@@ -354,12 +356,12 @@ static inline void aout_HotplugReport(audio_output_t *aout,
*/
static inline int aout_GainRequest(audio_output_t *aout, float gain)
{
- return aout->event.gain_request(aout, gain);
+ return aout->events->gain_request(aout, gain);
}
static inline void aout_RestartRequest(audio_output_t *aout, unsigned mode)
{
- aout->event.restart_request(aout, mode);
+ aout->events->restart_request(aout, mode);
}
/* Audio output filters */
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 56a179fa8b..bc77e09c68 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -161,6 +161,16 @@ static int aout_GainNotify (audio_output_t *aout, float gain)
return 0;
}
+static const struct vlc_audio_output_events aout_events = {
+ aout_VolumeNotify,
+ aout_MuteNotify,
+ aout_PolicyNotify,
+ aout_DeviceNotify,
+ aout_HotplugNotify,
+ aout_RestartNotify,
+ aout_GainNotify,
+};
+
static int FilterCallback (vlc_object_t *obj, const char *var,
vlc_value_t prev, vlc_value_t cur, void *data)
{
@@ -231,13 +241,7 @@ audio_output_t *aout_New (vlc_object_t *parent)
/* TODO: 3.0 HACK: only way to signal DTS_HD to aout modules. */
var_Create (aout, "dtshd", VLC_VAR_BOOL);
- aout->event.volume_report = aout_VolumeNotify;
- aout->event.mute_report = aout_MuteNotify;
- aout->event.policy_report = aout_PolicyNotify;
- aout->event.device_report = aout_DeviceNotify;
- aout->event.hotplug_report = aout_HotplugNotify;
- aout->event.gain_request = aout_GainNotify;
- aout->event.restart_request = aout_RestartNotify;
+ aout->events = &aout_events;
/* Audio output module initialization */
aout->start = NULL;
More information about the vlc-commits
mailing list