[vlc-commits] auhal: warn about audio configuration one time per device
Thomas Guillem
git at videolan.org
Fri Mar 9 16:43:32 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar 9 10:10:15 2018 +0100| [a43f4196348a74bf67267e948576ed268535ed92] | committer: Thomas Guillem
auhal: warn about audio configuration one time per device
This warning is quite useful if you don't know how to configure your speakers
to get surround, but it should not be displayed it every time. Indeed, some
users may want to stick to stereo and you can't really differentiate a device
(with more than 2 channels) configured for stereo with a device not configured
at all.
Fixes #19949
(cherry picked from commit 58982a04bb50cd885f62aa42434d016e06ed2252)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=a43f4196348a74bf67267e948576ed268535ed92
---
modules/audio_output/auhal.c | 77 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 67 insertions(+), 10 deletions(-)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index ec6c9a6b02..226eb98adf 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -59,6 +59,7 @@ vlc_module_begin ()
VOLUME_TEXT, VOLUME_LONGTEXT, true)
change_integer_range(0, AOUT_VOLUME_MAX)
add_string("auhal-audio-device", "", DEVICE_TEXT, DEVICE_LONGTEXT, true)
+ add_string("auhal-warned-devices", "", NULL, NULL, true)
add_obsolete_integer("macosx-audio-device") /* since 2.1.0 */
vlc_module_end ()
@@ -991,6 +992,71 @@ RenderCallbackSPDIF(AudioDeviceID inDevice, const AudioTimeStamp * inNow,
#pragma mark -
#pragma mark initialization
+static void
+WarnConfiguration(audio_output_t *p_aout)
+{
+ struct aout_sys_t *p_sys = p_aout->sys;
+ char *warned_devices = var_CreateGetNonEmptyString(p_aout, "auhal-warned-devices");
+ bool dev_is_warned = false;
+ unsigned dev_count = 0;
+
+ /* Check if the actual device was already warned */
+ if (warned_devices)
+ {
+ char *dup = strdup(warned_devices);
+ if (dup)
+ {
+ char *savetpr;
+ for (const char *dev = strtok_r(dup, ";", &savetpr);
+ dev != NULL && !dev_is_warned;
+ dev = strtok_r(NULL, ";", &savetpr))
+ {
+ dev_count++;
+ int devid = atoi(dev);
+ if (devid >= 0 && (unsigned) devid == p_sys->i_selected_dev)
+ {
+ dev_is_warned = true;
+ break;
+ }
+ }
+ free(dup);
+ }
+ }
+
+ /* Warn only one time per device */
+ if (!dev_is_warned)
+ {
+ msg_Warn(p_aout, "You should configure your speaker layout with "
+ "Audio Midi Setup in /Applications/Utilities. VLC will "
+ "output Stereo only.");
+ vlc_dialog_display_error(p_aout,
+ _("Audio device is not configured"), "%s",
+ _("You should configure your speaker layout with "
+ "\"Audio Midi Setup\" in /Applications/"
+ "Utilities. VLC will output Stereo only."));
+
+ /* Don't save too many devices */
+ if (dev_count >= 10)
+ {
+ char *end = strrchr(warned_devices, ';');
+ if (end)
+ *end = 0;
+ }
+
+ /* Add the actual device to the list of warned devices */
+ char *new_warned_devices;
+ if (asprintf(&new_warned_devices, "%u%s%s", p_sys->i_selected_dev,
+ warned_devices ? ";" : "",
+ warned_devices ? warned_devices : "") != -1)
+ {
+ config_PutPsz(p_aout, "auhal-warned-devices", new_warned_devices);
+ var_SetString(p_aout, "auhal-warned-devices", new_warned_devices);
+ free(new_warned_devices);
+ }
+ }
+ free(warned_devices);
+}
+
/*
* StartAnalog: open and setup a HAL AudioUnit to do PCM audio output
*/
@@ -1070,16 +1136,7 @@ StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt,
free(layout);
if (warn_configuration)
- {
- msg_Err(p_aout, "You should configure your speaker layout with "
- "Audio Midi Setup in /Applications/Utilities. VLC will "
- "output Stereo only.");
- vlc_dialog_display_error(p_aout,
- _("Audio device is not configured"), "%s",
- _("You should configure your speaker layout with "
- "\"Audio Midi Setup\" in /Applications/"
- "Utilities. VLC will output Stereo only."));
- }
+ WarnConfiguration(p_aout);
return VLC_SUCCESS;
error:
More information about the vlc-commits
mailing list