[vlc-commits] [Git][videolan/vlc][master] 5 commits: lib: rename libvlc_audio_set_channel to libvlc_audio_set_stereomode

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Dec 10 11:07:39 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
9d23e5b1 by Thomas Guillem at 2022-12-10T10:50:09+00:00
lib: rename libvlc_audio_set_channel to libvlc_audio_set_stereomode

And also rename the enum.

- - - - -
73630912 by Thomas Guillem at 2022-12-10T10:50:09+00:00
lib: change libvlc_AudioStereoMode_Error enum value

It didn't correspond to any VLC Core values.

- - - - -
03e671c5 by Thomas Guillem at 2022-12-10T10:50:09+00:00
lib: assert that LibVLC and VLC enums match

- - - - -
42b645e7 by Thomas Guillem at 2022-12-10T10:50:09+00:00
lib: add libvlc_AudioStereoMode_Mono

- - - - -
fefe9b60 by Thomas Guillem at 2022-12-10T10:50:09+00:00
lib: add libvlc_audio_set_mixmode

- - - - -


3 changed files:

- include/vlc/libvlc_media_player.h
- lib/audio.c
- lib/libvlc.sym


Changes:

=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -2217,17 +2217,29 @@ LIBVLC_API void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
  */
 
 /**
- * Audio channels
+ * Audio stereo modes
  */
-typedef enum libvlc_audio_output_channel_t {
-    libvlc_AudioChannel_Error   = -1,
-    libvlc_AudioChannel_Stereo  =  1,
-    libvlc_AudioChannel_RStereo =  2,
-    libvlc_AudioChannel_Left    =  3,
-    libvlc_AudioChannel_Right   =  4,
-    libvlc_AudioChannel_Dolbys  =  5
-} libvlc_audio_output_channel_t;
+typedef enum libvlc_audio_output_stereomode_t {
+    libvlc_AudioStereoMode_Unset   = 0,
+    libvlc_AudioStereoMode_Stereo  = 1,
+    libvlc_AudioStereoMode_RStereo = 2,
+    libvlc_AudioStereoMode_Left    = 3,
+    libvlc_AudioStereoMode_Right   = 4,
+    libvlc_AudioStereoMode_Dolbys  = 5,
+    libvlc_AudioStereoMode_Mono  = 7,
+} libvlc_audio_output_stereomode_t;
 
+/**
+ * Audio mix modes
+ */
+typedef enum libvlc_audio_output_mixmode_t {
+    libvlc_AudioMixMode_Unset       = 0,
+    libvlc_AudioMixMode_Stereo      = 1,
+    libvlc_AudioMixMode_Binaural    = 2,
+    libvlc_AudioMixMode_4_0         = 3,
+    libvlc_AudioMixMode_5_1         = 4,
+    libvlc_AudioMixMode_7_1         = 5,
+} libvlc_audio_output_mixmode_t;
 
 /**
  * Gets the list of available audio output modules.
@@ -2409,21 +2421,59 @@ LIBVLC_API int libvlc_audio_get_volume( libvlc_media_player_t *p_mi );
 LIBVLC_API int libvlc_audio_set_volume( libvlc_media_player_t *p_mi, int i_volume );
 
 /**
- * Get current audio channel.
+ * Get current audio stereo-mode.
+ *
+ * \param p_mi media player
+ * \return the audio stereo-mode, \see libvlc_audio_output_stereomode_t
+ * \version LibVLC 4.0.0 or later
+ */
+LIBVLC_API libvlc_audio_output_stereomode_t libvlc_audio_get_stereomode( libvlc_media_player_t *p_mi );
+
+/**
+ * Set current audio stereo-mode.
+ *
+ * \param p_mi media player
+ * \param channel the audio stereo-mode, \see libvlc_audio_output_stereomode_t
+ * \return 0 on success, -1 on error
+ * \version LibVLC 4.0.0 or later
+ */
+LIBVLC_API int libvlc_audio_set_stereomode( libvlc_media_player_t *p_mi,
+                                            libvlc_audio_output_stereomode_t mode );
+
+/**
+ * Get current audio mix-mode.
  *
  * \param p_mi media player
- * \return the audio channel \see libvlc_audio_output_channel_t
+ * \return the audio mix-mode, \see libvlc_audio_output_mixmode_t
+ * \version LibVLC 4.0.0 or later
  */
-LIBVLC_API int libvlc_audio_get_channel( libvlc_media_player_t *p_mi );
+LIBVLC_API libvlc_audio_output_mixmode_t libvlc_audio_get_mixmode( libvlc_media_player_t *p_mi );
 
 /**
- * Set current audio channel.
+ * Set current audio mix-mode.
+ *
+ * By default (libvlc_AudioMixMode_Unset), the audio output will keep its
+ * original channel configuration (play stereo as stereo, or 5.1 as 5.1). Yet,
+ * the OS and Audio API might refuse a channel configuration and asks VLC to
+ * adapt (Stereo played as 5.1 or vice-versa).
+ *
+ * This function allows to force a channel configuration, it will only work if
+ * the OS and Audio API accept this configuration (otherwise, it won't have any
+ * effects). Here are some examples:
+ *  - Play multi-channels (5.1, 7.1...) as stereo (libvlc_AudioMixMode_Stereo)
+ *  - Play Stereo or 5.1 as 7.1 (libvlc_AudioMixMode_7_1)
+ *  - Play multi-channels as stereo with a binaural effect
+ *  (libvlc_AudioMixMode_Binaural). It might be selected automatically if the
+ *  OS and Audio API can detect if a headphone is plugged.
  *
  * \param p_mi media player
- * \param channel the audio channel, \see libvlc_audio_output_channel_t
+ * \param channel the audio mix-mode, \see libvlc_audio_output_mixmode_t
  * \return 0 on success, -1 on error
+ * \version LibVLC 4.0.0 or later
  */
-LIBVLC_API int libvlc_audio_set_channel( libvlc_media_player_t *p_mi, int channel );
+LIBVLC_API int libvlc_audio_set_mixmode( libvlc_media_player_t *p_mi,
+                                         libvlc_audio_output_mixmode_t mode );
+
 
 /**
  * Get current audio delay.


=====================================
lib/audio.c
=====================================
@@ -348,13 +348,13 @@ end:
 }
 
 /*****************************************************************************
- * libvlc_audio_get_channel : Get the current audio channel
+ * libvlc_audio_get_stereomode : Get the current audio stereo-mode
  *****************************************************************************/
-int libvlc_audio_get_channel( libvlc_media_player_t *mp )
+libvlc_audio_output_stereomode_t libvlc_audio_get_stereomode( libvlc_media_player_t *mp )
 {
     audio_output_t *p_aout = GetAOut( mp );
     if( !p_aout )
-        return 0;
+        return libvlc_AudioStereoMode_Unset;
 
     int val = var_GetInteger( p_aout, "stereo-mode" );
     aout_Release(p_aout);
@@ -362,19 +362,70 @@ int libvlc_audio_get_channel( libvlc_media_player_t *mp )
 }
 
 /*****************************************************************************
- * libvlc_audio_set_channel : Set the current audio channel
+ * libvlc_audio_set_stereomode : Set the current audio stereo-mode
  *****************************************************************************/
-int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel )
+int libvlc_audio_set_stereomode( libvlc_media_player_t *mp, libvlc_audio_output_stereomode_t mode )
 {
+    static_assert(libvlc_AudioStereoMode_Unset == AOUT_VAR_CHAN_UNSET &&
+                  libvlc_AudioStereoMode_Stereo == AOUT_VAR_CHAN_STEREO &&
+                  libvlc_AudioStereoMode_RStereo == AOUT_VAR_CHAN_RSTEREO &&
+                  libvlc_AudioStereoMode_Left == AOUT_VAR_CHAN_LEFT &&
+                  libvlc_AudioStereoMode_Right == AOUT_VAR_CHAN_RIGHT &&
+                  libvlc_AudioStereoMode_Dolbys == AOUT_VAR_CHAN_DOLBYS &&
+                  libvlc_AudioStereoMode_Mono == AOUT_VAR_CHAN_MONO,
+                  "Mismatch with stereo-mode LibVLC/VLC enums");
+
+    audio_output_t *p_aout = GetAOut( mp );
+    int ret = 0;
+
+    if( !p_aout )
+        return -1;
+
+    if( var_SetInteger( p_aout, "stereo-mode", mode ) < 0 )
+    {
+        libvlc_printerr( "Audio stereo-mode out of range" );
+        ret = -1;
+    }
+    aout_Release(p_aout);
+    return ret;
+}
+
+/*****************************************************************************
+ * libvlc_audio_get_mixmode : Get the current audio mix-mode
+ *****************************************************************************/
+libvlc_audio_output_mixmode_t libvlc_audio_get_mixmode( libvlc_media_player_t *mp )
+{
+    audio_output_t *p_aout = GetAOut( mp );
+    if( !p_aout )
+        return libvlc_AudioMixMode_Unset;
+
+    int val = var_GetInteger( p_aout, "mix-mode" );
+    aout_Release(p_aout);
+    return val;
+}
+
+/*****************************************************************************
+ * libvlc_audio_set_mixmode : Set the current audio mix-mode
+ *****************************************************************************/
+int libvlc_audio_set_mixmode( libvlc_media_player_t *mp, libvlc_audio_output_mixmode_t mode )
+{
+    static_assert(libvlc_AudioMixMode_Unset == AOUT_VAR_CHAN_UNSET &&
+                  libvlc_AudioMixMode_Stereo == AOUT_MIX_MODE_STEREO &&
+                  libvlc_AudioMixMode_Binaural == AOUT_MIX_MODE_BINAURAL &&
+                  libvlc_AudioMixMode_4_0 == AOUT_MIX_MODE_4_0 &&
+                  libvlc_AudioMixMode_5_1 == AOUT_MIX_MODE_5_1 &&
+                  libvlc_AudioMixMode_7_1 == AOUT_MIX_MODE_7_1,
+                  "Mismatch with mix-mode LibVLC/VLC enums");
+
     audio_output_t *p_aout = GetAOut( mp );
     int ret = 0;
 
     if( !p_aout )
         return -1;
 
-    if( var_SetInteger( p_aout, "stereo-mode", channel ) < 0 )
+    if( var_SetInteger( p_aout, "mix-mode", mode ) < 0 )
     {
-        libvlc_printerr( "Audio channel out of range" );
+        libvlc_printerr( "Audio mix-mode out of range" );
         ret = -1;
     }
     aout_Release(p_aout);


=====================================
lib/libvlc.sym
=====================================
@@ -19,14 +19,16 @@ libvlc_audio_output_device_set
 libvlc_audio_output_list_get
 libvlc_audio_output_list_release
 libvlc_audio_output_set
-libvlc_audio_get_channel
+libvlc_audio_get_mixmode
+libvlc_audio_get_stereomode
 libvlc_audio_get_delay
 libvlc_audio_get_mute
 libvlc_audio_get_track
 libvlc_audio_get_track_count
 libvlc_audio_get_track_description
 libvlc_audio_get_volume
-libvlc_audio_set_channel
+libvlc_audio_set_mixmode
+libvlc_audio_set_stereomode
 libvlc_audio_set_delay
 libvlc_audio_set_mute
 libvlc_audio_set_track



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/996b08df5bcf4d753a38971e5e23a4279f3e2387...fefe9b605325bd04251e9ca877d9a8bd5b56295f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/996b08df5bcf4d753a38971e5e23a4279f3e2387...fefe9b605325bd04251e9ca877d9a8bd5b56295f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list