[vlc-commits] aout: remap in order to handle stereo modes

Thomas Guillem git at videolan.org
Thu Jul 13 17:19:25 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jul 13 14:14:50 2017 +0200| [7277779fdc0a4f8d7857f534566e1fc956d5fb77] | committer: Thomas Guillem

aout: remap in order to handle stereo modes

This commit removes the usage of i_original_channels to handle stereo modes.

aout_OutputNew will now fill the remap array if a special stereo-mode needs to
be handled.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7277779fdc0a4f8d7857f534566e1fc956d5fb77
---

 src/audio_output/aout_internal.h |  3 ++-
 src/audio_output/dec.c           | 14 ++++++++++----
 src/audio_output/output.c        | 21 ++++++++++++++-------
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 3cb8058f60..f84a36321e 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -79,6 +79,7 @@ typedef struct
     audio_sample_format_t mixer_format;
 
     aout_request_vout_t request_vout;
+    int remap[AOUT_CHANIDX_MAX];
 
     atomic_uint buffers_lost;
     atomic_uint buffers_played;
@@ -114,7 +115,7 @@ audio_output_t *aout_New (vlc_object_t *);
 #define aout_New(a) aout_New(VLC_OBJECT(a))
 void aout_Destroy (audio_output_t *);
 
-int aout_OutputNew(audio_output_t *, audio_sample_format_t *);
+int aout_OutputNew(audio_output_t *, audio_sample_format_t *, int *wg4_remap);
 int aout_OutputTimeGet(audio_output_t *, mtime_t *);
 void aout_OutputPlay(audio_output_t *, block_t *);
 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index a22f57c333..41c9018c46 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -89,13 +89,15 @@ int aout_DecNew( audio_output_t *p_aout,
     }
     owner->request_vout = *p_request_vout;
 
-    if (aout_OutputNew (p_aout, &owner->mixer_format))
+    int remap[] = AOUT_CHAN_REMAP_INIT;
+    if (aout_OutputNew (p_aout, &owner->mixer_format, remap))
         goto error;
     aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format);
 
     /* Create the audio filtering "input" pipeline */
+    memcpy(owner->remap, remap, sizeof(remap));
     owner->filters = aout_FiltersNew (p_aout, p_format, &owner->mixer_format,
-                                      &owner->request_vout, NULL);
+                                      &owner->request_vout, owner->remap);
     if (owner->filters == NULL)
     {
         aout_OutputDelete (p_aout);
@@ -106,6 +108,7 @@ error:
         return -1;
     }
 
+
     owner->sync.end = VLC_TS_INVALID;
     owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
     owner->sync.discontinuity = true;
@@ -151,8 +154,10 @@ static int aout_CheckReady (audio_output_t *aout)
             if (owner->mixer_format.i_format)
                 aout_OutputDelete (aout);
             owner->mixer_format = owner->input_format;
-            if (aout_OutputNew (aout, &owner->mixer_format))
+            int remap[] = AOUT_CHAN_REMAP_INIT;
+            if (aout_OutputNew (aout, &owner->mixer_format, remap))
                 owner->mixer_format.i_format = 0;
+            memcpy(owner->remap, remap, sizeof(remap));
             aout_volume_SetFormat (owner->volume,
                                    owner->mixer_format.i_format);
             status = AOUT_DEC_CHANGED;
@@ -166,7 +171,8 @@ static int aout_CheckReady (audio_output_t *aout)
         {
             owner->filters = aout_FiltersNew (aout, &owner->input_format,
                                               &owner->mixer_format,
-                                              &owner->request_vout, NULL);
+                                              &owner->request_vout,
+                                              owner->remap);
             if (owner->filters == NULL)
             {
                 aout_OutputDelete (aout);
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index ab688df811..a41008dde4 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -385,14 +385,21 @@ static void aout_Destructor (vlc_object_t *obj)
  * \param fmt audio output stream format [IN/OUT]
  * \warning The caller must hold the audio output lock.
  */
-int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
+int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
+                    int *remap)
 {
     aout_OutputAssertLocked (aout);
 
     int i_forced_stereo_mode = var_GetInteger (aout, "stereo-mode");
     bool b_stereo_original = fmt->i_physical_channels == AOUT_CHANS_STEREO;
     if (i_forced_stereo_mode != AOUT_VAR_CHAN_UNSET)
-        fmt->i_physical_channels = AOUT_CHANS_STEREO;
+    {
+        if (i_forced_stereo_mode == AOUT_VAR_CHAN_LEFT
+         || i_forced_stereo_mode == AOUT_VAR_CHAN_RIGHT)
+            fmt->i_physical_channels = AOUT_CHAN_CENTER;
+        else
+            fmt->i_physical_channels = AOUT_CHANS_STEREO;
+    }
 
     /* Ideally, the audio filters would be created before the audio output,
      * and the ideal audio format would be the output of the filters chain.
@@ -450,16 +457,16 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     switch (i_forced_stereo_mode)
     {
         case AOUT_VAR_CHAN_RSTEREO:
-            fmt->i_original_channels |= AOUT_CHAN_REVERSESTEREO;
+            remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_RIGHT;
+            remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_LEFT;
             break;
         case AOUT_VAR_CHAN_STEREO:
-            fmt->i_original_channels = AOUT_CHANS_STEREO;
             break;
         case AOUT_VAR_CHAN_LEFT:
-            fmt->i_original_channels = AOUT_CHAN_LEFT;
+            remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
             break;
         case AOUT_VAR_CHAN_RIGHT:
-            fmt->i_original_channels = AOUT_CHAN_RIGHT;
+            remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_DISABLE;
             break;
         case AOUT_VAR_CHAN_DOLBYS:
             fmt->i_original_channels = AOUT_CHANS_STEREO|AOUT_CHAN_DOLBYSTEREO;
@@ -467,7 +474,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
         default:
             if (fmt->i_original_channels == (AOUT_CHANS_STEREO | AOUT_CHAN_DUALMONO))
             {   /* Go directly to the left channel. */
-                fmt->i_original_channels = AOUT_CHAN_LEFT;
+                remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
                 val.i_int = AOUT_VAR_CHAN_LEFT;
                 var_Change (aout, "stereo-mode", VLC_VAR_SETVALUE, &val, NULL);
             }



More information about the vlc-commits mailing list