[vlc-commits] [Git][videolan/vlc][master] 3 commits: test: player: log the loudness_meter test

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Apr 9 02:42:42 UTC 2022



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


Commits:
b697c740 by Thomas Guillem at 2022-04-09T00:43:59+00:00
test: player: log the loudness_meter test

- - - - -
936295ab by Thomas Guillem at 2022-04-09T00:43:59+00:00
aout: meter: fix data-race with fmt

Lock fmt on read/write since it's written from the DecoderThread and
read anywhere (when creating a meter module from the player).

- - - - -
27ffece6 by Thomas Guillem at 2022-04-09T00:43:59+00:00
aout: stream: fix heap-use-after-free

Reset the meter fmt to NULL when destroying the stream.

WARNING: ThreadSanitizer: heap-use-after-free (pid=45968)
  Read of size 1 at 0x7b4400019fdc by main thread:
    #0 aout_filter_Create ../../src/audio_output/filters.c:56 (libvlccore.so.9+0xa4945)
    #1 vlc_audio_meter_CreatePluginFilter ../../src/audio_output/meter.c:83 (libvlccore.so.9+0xa7074)
    #2 vlc_audio_meter_AddPlugin ../../src/audio_output/meter.c:108 (libvlccore.so.9+0xa71df)
    #3 aout_AddMeterPlugin ../../src/audio_output/output.c:1008 (libvlccore.so.9+0xaa088)
    #4 vlc_player_AddMetadataLoudnessListener ../../src/player/metadata.c:106 (libvlccore.so.9+0x98f93)
    #5 vlc_player_AddMetadataListener ../../src/player/metadata.c:181 (libvlccore.so.9+0x990bc)
    #6 test_audio_loudness_meter ../../test/src/player/player.c:2842 (test_src_player+0x5db2)
    #7 main ../../test/src/player/player.c:2961 (test_src_player+0xa9fa)

  Previous write of size 8 at 0x7b4400019fd8 by main thread:
    #0 free ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:711 (libtsan.so.0+0x368a8)
    #1 vlc_player_track_priv_Delete ../../src/player/track.c:145 (libvlccore.so.9+0x94d60)
    #2 vlc_player_track_Delete ../../src/player/track.c:153 (libvlccore.so.9+0x94d7d)
    #3 ctx_reset ../../test/src/player/player.c:630 (test_src_player+0x484d)
    #4 test_end ../../test/src/player/player.c:1044 (test_src_player+0x5696)
    #5 test_es_selection_override ../../test/src/player/player.c:2913 (test_src_player+0x5b18)
    #6 main ../../test/src/player/player.c:2960 (test_src_player+0xa9f2)

- - - - -


3 changed files:

- src/audio_output/dec.c
- src/audio_output/meter.c
- test/src/player/player.c


Changes:

=====================================
src/audio_output/dec.c
=====================================
@@ -236,10 +236,12 @@ error:
 void vlc_aout_stream_Delete (vlc_aout_stream *stream)
 {
     audio_output_t *aout = aout_stream_aout(stream);
+    aout_owner_t *owner = aout_stream_owner(stream);
 
     if (stream->mixer_format.i_format)
     {
         stream_Reset(stream);
+        vlc_audio_meter_Reset(&owner->meter, NULL);
         if (stream->filters)
             aout_FiltersDelete (aout, stream->filters);
         aout_OutputDelete (aout);


=====================================
src/audio_output/meter.c
=====================================
@@ -103,16 +103,19 @@ vlc_audio_meter_AddPlugin(struct vlc_audio_meter *meter, const char *chain,
     if (plugin->name == NULL)
         goto error;
 
+    vlc_mutex_lock(&meter->lock);
     if (meter->fmt != NULL)
     {
         plugin->filter = vlc_audio_meter_CreatePluginFilter(meter, plugin);
         if (plugin->filter == NULL)
+        {
+            vlc_mutex_unlock(&meter->lock);
             goto error;
+        }
 
         assert(plugin->filter->ops->drain_audio == NULL); /* Not supported */
     }
 
-    vlc_mutex_lock(&meter->lock);
     vlc_list_append(&plugin->node, &meter->plugins);
     vlc_mutex_unlock(&meter->lock);
 
@@ -153,10 +156,10 @@ vlc_audio_meter_Reset(struct vlc_audio_meter *meter, const audio_sample_format_t
 {
     int ret = VLC_SUCCESS;
 
-    meter->fmt = fmt;
-
     vlc_mutex_lock(&meter->lock);
 
+    meter->fmt = fmt;
+
     /* Reload every plugins using the new fmt */
     vlc_audio_meter_plugin *plugin;
     vlc_list_foreach(plugin, &meter->plugins, node)


=====================================
test/src/player/player.c
=====================================
@@ -2792,6 +2792,8 @@ test_audio_loudness_meter_cb(vlc_tick_t date, double momentary_loudness,
 static void
 test_audio_loudness_meter(struct ctx *ctx)
 {
+    test_log("test_audio_loudness_meter\n");
+
     vlc_player_t *player = ctx->player;
 
     static const union vlc_player_metadata_cbs cbs = {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/02fcb4a00867ec607c8700b5fa9d5f21b92efce6...27ffece619bdb77e474e33cedce3bde47478c71a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/02fcb4a00867ec607c8700b5fa9d5f21b92efce6...27ffece619bdb77e474e33cedce3bde47478c71a
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