[vlc-commits] [Git][videolan/vlc][master] 9 commits: aout: use vlc_aout_stream_RequestRestart directly

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun May 5 05:09:57 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
ac707366 by Thomas Guillem at 2024-05-05T04:23:00+00:00
aout: use vlc_aout_stream_RequestRestart directly

This will be needed by the next commit.

- - - - -
c7091b3f by Thomas Guillem at 2024-05-05T04:23:00+00:00
aout: rework aout_RestartRequest()

The same mode is always used from modules: AOUT_RESTART_OUTPUT.
There is no use to restart filters and change stereo-mode from modules.

It is not always necessary to restart the audio decoder (restart_dec=true).
This will be modified in each modules separately.

- - - - -
449c313c by Thomas Guillem at 2024-05-05T04:23:00+00:00
aout: don't expose AOUT_RESTART_ defines

- - - - -
41548a74 by Thomas Guillem at 2024-05-05T04:23:00+00:00
aout: rework internal restart modes

AOUT_RESTART_STEREOMODE was only triggering an aout stream restart, so
rename it to AOUT_RESTART_OUTPUT.

AOUT_RESTART_OUTPUT that was triggering an aout stream restart and an
audio dec restart, is now renamed AOUT_RESTART_OUTPUT_DEC.

- - - - -
8017bebe by Thomas Guillem at 2024-05-05T04:23:00+00:00
alsa: don't restart the audio decoder

Only the aout stream need to be restarted on error.

- - - - -
20bf6206 by Thomas Guillem at 2024-05-05T04:23:00+00:00
aaudio: don't restart the audio decoder

Only the aout stream need to be restarted on error.

- - - - -
7d5fa1f7 by Thomas Guillem at 2024-05-05T04:23:00+00:00
audiounit_ios: don't restart the audio decoder

Only the aout stream need to be restarted on error.

- - - - -
d418bfb3 by Thomas Guillem at 2024-05-05T04:23:00+00:00
auhal: don't restart the audio decoder

Only the aout stream need to be restarted on error.

- - - - -
3f295955 by Thomas Guillem at 2024-05-05T04:23:00+00:00
jack: don't restart the audio decoder

Only the aout stream need to be restarted on error.

- - - - -


16 changed files:

- include/vlc_aout.h
- modules/audio_output/alsa.c
- modules/audio_output/android/aaudio.c
- modules/audio_output/android/device.c
- modules/audio_output/android/device.h
- modules/audio_output/audiounit_ios.m
- modules/audio_output/auhal.c
- modules/audio_output/jack.c
- modules/audio_output/mmdevice.c
- modules/audio_output/oss.c
- modules/audio_output/pulse.c
- modules/audio_output/waveout.c
- modules/audio_output/winstore.c
- src/audio_output/aout_internal.h
- src/audio_output/dec.c
- src/audio_output/output.c


Changes:

=====================================
include/vlc_aout.h
=====================================
@@ -133,7 +133,7 @@ struct vlc_audio_output_events {
     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);
+    void (*restart_request)(audio_output_t *, bool);
     int (*gain_request)(audio_output_t *, float);
 };
 
@@ -393,15 +393,11 @@ static inline int aout_GainRequest(audio_output_t *aout, float gain)
     return aout->events->gain_request(aout, gain);
 }
 
-static inline void aout_RestartRequest(audio_output_t *aout, unsigned mode)
+static inline void aout_RestartRequest(audio_output_t *aout, bool restart_dec)
 {
-    aout->events->restart_request(aout, mode);
+    aout->events->restart_request(aout, restart_dec);
 }
 
-#define AOUT_RESTART_FILTERS        0x1
-#define AOUT_RESTART_OUTPUT         (AOUT_RESTART_FILTERS|0x2)
-#define AOUT_RESTART_STEREOMODE     (AOUT_RESTART_OUTPUT|0x4)
-
 /** @} */
 
 /**


=====================================
modules/audio_output/alsa.c
=====================================
@@ -363,7 +363,7 @@ static void * InjectionThread(void * data)
     if (sys->started && !sys->unrecoverable_error)
     {
         msg_Err(aout, "Unhandled error in injection thread, requesting aout restart");
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(aout, false);
     }
     vlc_mutex_unlock(&sys->lock);
     return NULL;
@@ -1080,7 +1080,7 @@ static int DeviceSelect (audio_output_t *aout, const char *id)
     free (sys->device);
     sys->device = device;
     aout_DeviceReport (aout, device);
-    aout_RestartRequest (aout, AOUT_RESTART_OUTPUT);
+    aout_RestartRequest (aout, true);
     return 0;
 }
 


=====================================
modules/audio_output/android/aaudio.c
=====================================
@@ -486,7 +486,7 @@ ErrorCallback(AAudioStream *as, void *user, aaudio_result_t error)
     (void) as;
 
     LogAAudioError(stream, "AAudio stream error or disconnected:", error);
-    aout_stream_RestartRequest(stream, AOUT_RESTART_OUTPUT);
+    aout_stream_RestartRequest(stream, false);
 }
 
 static void
@@ -732,7 +732,7 @@ Flush(aout_stream_t *stream)
     {
         msg_Err(stream, "rate changed after flush, from %u to %d",
                 sys->fmt.i_rate, new_rate);
-        aout_stream_RestartRequest(stream, AOUT_RESTART_OUTPUT);
+        aout_stream_RestartRequest(stream, false);
     }
 }
 


=====================================
modules/audio_output/android/device.c
=====================================
@@ -236,7 +236,7 @@ static int DeviceSelect(audio_output_t *aout, const char *id)
     {
         sys->adev = adev;
         sys->encoding_flags = encoding_flags;
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(aout, true);
         msg_Dbg(aout, "selected device: %s", id);
 
         if (adev == ANDROID_AUDIO_DEVICE_ENCODED)


=====================================
modules/audio_output/android/device.h
=====================================
@@ -56,9 +56,9 @@ aout_stream_GainRequest(aout_stream_t *s, float gain)
 }
 
 static inline void
-aout_stream_RestartRequest(aout_stream_t *s, unsigned mode)
+aout_stream_RestartRequest(aout_stream_t *s, bool restart_dec)
 {
-    aout_RestartRequest(s->aout, mode);
+    aout_RestartRequest(s->aout, restart_dec);
 }
 
 static inline


=====================================
modules/audio_output/audiounit_ios.m
=====================================
@@ -217,7 +217,7 @@ GetLatency(audio_output_t *p_aout)
 
     if (routeChangeReason == AVAudioSessionRouteChangeReasonNewDeviceAvailable
      || routeChangeReason == AVAudioSessionRouteChangeReasonOldDeviceUnavailable)
-        aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(p_aout, false);
     else
         ca_ResetDeviceLatency(p_aout);
 }
@@ -252,7 +252,7 @@ GetLatency(audio_output_t *p_aout)
         msg_Dbg(p_aout, "Spatial Audio availability changed: %i", spatialAudioEnabled);
 
         if (spatialAudioEnabled) {
-            aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+            aout_RestartRequest(p_aout, false);
         }
     }
 }
@@ -686,7 +686,7 @@ static int DeviceSelect(audio_output_t *p_aout, const char *psz_id)
     if (au_dev != p_sys->au_dev)
     {
         p_sys->au_dev = au_dev;
-        aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(p_aout, true);
         msg_Dbg(p_aout, "selected audiounit device: %s", psz_id);
     }
     aout_DeviceReport(p_aout, psz_id);


=====================================
modules/audio_output/auhal.c
=====================================
@@ -610,7 +610,7 @@ DeviceAliveListener(AudioObjectID inObjectID,  UInt32 inNumberAddresses,
         return -1;
 
     msg_Warn(p_aout, "audio device died, resetting aout");
-    aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+    aout_RestartRequest(p_aout, false);
 
     return noErr;
 }
@@ -659,7 +659,7 @@ DefaultDeviceChangedListener(AudioObjectID inObjectID, UInt32 inNumberAddresses,
     if (defaultDeviceID != p_sys->i_selected_dev)
     {
         msg_Dbg(p_aout, "default device actually changed, resetting aout");
-        aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(p_aout, true);
     }
     vlc_mutex_unlock(&p_sys->selected_device_lock);
 
@@ -717,7 +717,7 @@ StreamsChangedListener(AudioObjectID inObjectID, UInt32 inNumberAddresses,
         if (p_streams[i] == inObjectID)
         {
             msg_Dbg(p_aout, "Restart aout as this affects current device");
-            aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+            aout_RestartRequest(p_aout, true);
             break;
         }
     }
@@ -753,7 +753,7 @@ DevicesListener(AudioObjectID inObjectID, UInt32 inNumberAddresses,
                        &p_sys->i_selected_dev);
     CFRange range = CFRangeMake(0, CFArrayGetCount(p_sys->device_list));
     if (!CFArrayContainsValue(p_sys->device_list, range, selectedDevice))
-        aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(p_aout, true);
     CFRelease(selectedDevice);
     vlc_mutex_unlock(&p_sys->device_list_lock);
     vlc_mutex_unlock(&p_sys->selected_device_lock);
@@ -891,7 +891,7 @@ SwitchAudioDevice(audio_output_t *p_aout, const char *name)
     p_sys->i_new_selected_dev = (name) ? atoi(name) : 0;
 
     aout_DeviceReport(p_aout, name);
-    aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+    aout_RestartRequest(p_aout, true);
 
     return 0;
 }


=====================================
modules/audio_output/jack.c
=====================================
@@ -449,7 +449,7 @@ static int Buffer_ch( jack_nframes_t nframes, void *p_arg )
         jack_deactivate( p_sys->p_jack_client );
         p_sys->read_buffer = orig_buffer;
         status = ENOMEM;
-        aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(p_aout, false);
     }
     return status;
 }


=====================================
modules/audio_output/mmdevice.c
=====================================
@@ -583,7 +583,7 @@ vlc_MMNotificationClient_OnDefaultDeviceChange(IMMNotificationClient *this,
     {
         msg_Dbg(aout, "default device changed: %ls", wid);
         sys->request_device_restart = true;
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(aout, true);
     }
     vlc_mutex_unlock(&sys->lock);
 
@@ -738,7 +738,7 @@ static int DeviceRequestLocked(audio_output_t *aout)
 
     if (sys->stream != NULL && sys->dev != NULL)
         /* Request restart of stream with the new device */
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(aout, true);
     return (sys->dev != NULL) ? 0 : -1;
 }
 


=====================================
modules/audio_output/oss.c
=====================================
@@ -380,7 +380,7 @@ static int DeviceSelect (audio_output_t *aout, const char *id)
     free (sys->device);
     sys->device = path;
     aout_DeviceReport (aout, path);
-    aout_RestartRequest (aout, AOUT_RESTART_OUTPUT);
+    aout_RestartRequest (aout, true);
     return 0;
 }
 


=====================================
modules/audio_output/pulse.c
=====================================
@@ -343,7 +343,7 @@ static void stream_event_cb(pa_stream *s, const char *name, pa_proplist *pl,
     /* FIXME: expose aout_Restart() directly */
     if (!strcmp(name, PA_STREAM_EVENT_FORMAT_LOST)) {
         msg_Dbg (aout, "format lost");
-        aout_RestartRequest (aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest (aout, true);
     } else
         msg_Warn (aout, "unhandled stream event \"%s\"", name);
     (void) s;


=====================================
modules/audio_output/waveout.c
=====================================
@@ -769,7 +769,7 @@ static int DeviceSelect (audio_output_t *aout, const char *id)
 {
     var_SetString(aout, "waveout-audio-device", (id != NULL) ? id : "");
     aout_DeviceReport (aout, id);
-    aout_RestartRequest (aout, AOUT_RESTART_OUTPUT);
+    aout_RestartRequest (aout, true);
     return 0;
 }
 


=====================================
modules/audio_output/winstore.c
=====================================
@@ -217,7 +217,7 @@ static int DeviceRequestLocked(audio_output_t *aout)
 
     if (sys->stream != NULL && sys->client != NULL)
         /* Request restart of stream with the new device */
-        aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+        aout_RestartRequest(aout, true);
     return (sys->client != NULL) ? 0 : -1;
 }
 


=====================================
src/audio_output/aout_internal.h
=====================================
@@ -34,6 +34,10 @@
 /* Max input rate factor (1/4 -> 4) */
 # define AOUT_MAX_INPUT_RATE (4)
 
+#define AOUT_RESTART_FILTERS        0x1
+#define AOUT_RESTART_OUTPUT         (AOUT_RESTART_FILTERS|0x2)
+#define AOUT_RESTART_OUTPUT_DEC     (AOUT_RESTART_OUTPUT|0x4)
+
 enum {
     AOUT_RESAMPLING_NONE=0,
     AOUT_RESAMPLING_UP,


=====================================
src/audio_output/dec.c
=====================================
@@ -351,7 +351,7 @@ static int stream_CheckReady (vlc_aout_stream *stream)
 
     int restart = atomic_exchange_explicit(&stream->restart, 0,
                                            memory_order_acquire);
-    if (unlikely(restart))
+    if (unlikely(restart != 0))
     {
         if (stream->filters)
         {
@@ -382,7 +382,7 @@ static int stream_CheckReady (vlc_aout_stream *stream)
              * suitable codec (like an HDMI audio format). However, keep the
              * same codec if the aout was restarted because of a stereo-mode
              * change from the user. */
-            if (restart == AOUT_RESTART_OUTPUT)
+            if ((restart & AOUT_RESTART_OUTPUT_DEC) == AOUT_RESTART_OUTPUT_DEC)
                 status = AOUT_DEC_CHANGED;
         }
         else if (tracer != NULL)


=====================================
src/audio_output/output.c
=====================================
@@ -165,16 +165,21 @@ out:
     vlc_mutex_unlock (&owner->dev.lock);
 }
 
-static void aout_RestartNotify (audio_output_t *aout, unsigned mode)
+static void aout_RestartNotify (audio_output_t *aout, bool restart_dec)
 {
     aout_owner_t *owner = aout_owner (aout);
     if (owner->main_stream)
+    {
+        unsigned mode = restart_dec ? AOUT_RESTART_OUTPUT_DEC : AOUT_RESTART_OUTPUT;
         vlc_aout_stream_RequestRestart(owner->main_stream, mode);
+    }
 }
 
 void aout_InputRequestRestart(audio_output_t *aout)
 {
-    aout_RestartNotify(aout, AOUT_RESTART_FILTERS);
+    aout_owner_t *owner = aout_owner (aout);
+    if (owner->main_stream)
+        vlc_aout_stream_RequestRestart(owner->main_stream, AOUT_RESTART_FILTERS);
 }
 
 static int aout_GainNotify (audio_output_t *aout, float gain)
@@ -220,7 +225,8 @@ static int StereoModeCallback (vlc_object_t *obj, const char *varname,
     owner->requested_stereo_mode = newval.i_int;
     vlc_mutex_unlock (&owner->lock);
 
-    aout_RestartRequest (aout, AOUT_RESTART_STEREOMODE);
+    if (owner->main_stream)
+        vlc_aout_stream_RequestRestart(owner->main_stream, AOUT_RESTART_OUTPUT);
     return 0;
 }
 
@@ -235,7 +241,8 @@ static int MixModeCallback (vlc_object_t *obj, const char *varname,
     owner->requested_mix_mode = newval.i_int;
     vlc_mutex_unlock (&owner->lock);
 
-    aout_RestartRequest (aout, AOUT_RESTART_STEREOMODE);
+    if (owner->main_stream)
+        vlc_aout_stream_RequestRestart(owner->main_stream, AOUT_RESTART_OUTPUT);
     return 0;
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ce78ae848963786b528ea4db79de83f6597c3fc7...3f2959558d345b0659b45630e5b9fa812eaa5bd2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ce78ae848963786b528ea4db79de83f6597c3fc7...3f2959558d345b0659b45630e5b9fa812eaa5bd2
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