[vlc-commits] [Git][videolan/vlc][master] 5 commits: mock: use 48khz as default audio rate

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun Nov 26 07:12:40 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
db677b43 by Thomas Guillem at 2023-11-26T06:58:23+00:00
mock: use 48khz as default audio rate

So that the requested audio_sample_length * rate / CLOCK_FREQ has more
change to be divisible. It's a not issue if that not the case, the
module will use its own sample_length near to the requested one.

- - - - -
c156bbfd by Thomas Guillem at 2023-11-26T06:58:23+00:00
test: player: add an aout module

In order to not rely on adummy behavior.

- - - - -
49c9a0e5 by Thomas Guillem at 2023-11-26T06:58:23+00:00
adummy: remove unused define

- - - - -
f2245c90 by Thomas Guillem at 2023-11-26T06:58:23+00:00
adummy: implement aout_TimingReport()

adummy is now the more precise aout module ;)

- - - - -
10a4528c by Thomas Guillem at 2023-11-26T06:58:23+00:00
adummy: implement pause

- - - - -


3 changed files:

- modules/audio_output/adummy.c
- modules/demux/mock.c
- test/src/player/player.c


Changes:

=====================================
modules/audio_output/adummy.c
=====================================
@@ -40,60 +40,53 @@ vlc_module_begin ()
     add_shortcut( "dummy" )
 vlc_module_end ()
 
-#define A52_FRAME_NB 1536
-
 struct aout_sys
 {
     vlc_tick_t first_play_date;
-    vlc_tick_t length;
+    vlc_tick_t last_timing_date;
+    vlc_tick_t paused_date;
 };
 
-static int TimeGet(audio_output_t *aout, vlc_tick_t *restrict delay)
+static void Play(audio_output_t *aout, block_t *block, vlc_tick_t date)
 {
     struct aout_sys *sys = aout->sys;
 
     if (unlikely(sys->first_play_date == VLC_TICK_INVALID))
-    {
-        *delay = 0;
-        return 0;
-    }
-
-    vlc_tick_t time_since_first_play = vlc_tick_now() - sys->first_play_date;
-    assert(time_since_first_play >= 0);
+        sys->first_play_date = date;
 
-    if (likely(sys->length > time_since_first_play))
-    {
-        *delay = sys->length - time_since_first_play;
-        return 0;
-    }
-
-    msg_Warn(aout, "underflow");
-    return -1;
-}
+    block_Release( block );
 
-static void Play(audio_output_t *aout, block_t *block, vlc_tick_t date)
-{
-    struct aout_sys *sys = aout->sys;
+    vlc_tick_t now = vlc_tick_now();
 
-    if (unlikely(sys->first_play_date == VLC_TICK_INVALID))
-        sys->first_play_date = vlc_tick_now();
-    sys->length += block->i_length;
+    if (now < sys->first_play_date)
+        return;
 
-    block_Release( block );
-    (void) date;
+    if (sys->last_timing_date == VLC_TICK_INVALID ||
+        now - sys->last_timing_date >= VLC_TICK_FROM_SEC(1))
+    {
+        sys->last_timing_date = now;
+        aout_TimingReport(aout, now, now - sys->first_play_date);
+    }
 }
 
 static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)
 {
-    (void) aout; (void) paused; (void) date;
+    struct aout_sys *sys = aout->sys;
+    if (paused)
+        sys->paused_date = date;
+    else
+    {
+        sys->first_play_date -= sys->paused_date - date;
+        sys->paused_date = VLC_TICK_INVALID;
+    }
 }
 
 static void Flush(audio_output_t *aout)
 {
     struct aout_sys *sys = aout->sys;
 
-    sys->first_play_date = VLC_TICK_INVALID;
-    sys->length = 0;
+    sys->first_play_date = sys->last_timing_date = VLC_TICK_INVALID;
+    sys->paused_date = VLC_TICK_INVALID;
 }
 
 static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
@@ -141,11 +134,10 @@ static int Open(vlc_object_t *obj)
     struct aout_sys *sys = aout->sys = malloc(sizeof(*sys));
     if (!sys)
         return VLC_ENOMEM;
-    sys->first_play_date = VLC_TICK_INVALID;
-    sys->length = 0;
+    sys->first_play_date = sys->last_timing_date = VLC_TICK_INVALID;
+    sys->paused_date = VLC_TICK_INVALID;
 
     aout->start = Start;
-    aout->time_get = TimeGet;
     aout->play = Play;
     aout->pause = Pause;
     aout->flush = Flush;


=====================================
modules/demux/mock.c
=====================================
@@ -188,7 +188,7 @@ var_Read_float(const char *psz)
     Y(audio, add_track_at, vlc_tick_t, add_integer, Integer, VLC_TICK_INVALID) \
     Y(audio, channels, unsigned, add_integer, Unsigned, 2) \
     Y(audio, format, vlc_fourcc_t, add_string, Fourcc, "f32l") \
-    Y(audio, rate, unsigned, add_integer, Unsigned, 44100) \
+    Y(audio, rate, unsigned, add_integer, Unsigned, 48000) \
     Y(audio, sample_length, vlc_tick_t, add_integer, Integer, VLC_TICK_FROM_MS(40)) \
     Y(audio, sinewave, bool, add_bool, Bool, true) \
     Y(audio, sinewave_frequency, unsigned, add_integer, Integer, 500) \


=====================================
test/src/player/player.c
=====================================
@@ -2182,7 +2182,7 @@ ctx_init(struct ctx *ctx, enum ctx_flags flags)
         "--codec=araw,rawvideo,subsdec,"TELETEXT_DECODER"none",
         "--dec-dev=none",
         (flags & DISABLE_VIDEO_OUTPUT) ? "--vout=none" : "--vout=dummy",
-        (flags & DISABLE_AUDIO_OUTPUT) ? "--aout=none" : "--aout=dummy",
+        (flags & DISABLE_AUDIO_OUTPUT) ? "--aout=none" : "--aout=test_src_player",
         (flags & DISABLE_VIDEO) ? "--no-video" : "--video",
         (flags & DISABLE_AUDIO) ? "--no-audio" : "--audio",
         "--text-renderer=tdummy",
@@ -3008,3 +3008,80 @@ main(void)
     libvlc_release(dummy);
     return 0;
 }
+
+#define MODULE_NAME test_src_player
+#undef VLC_DYNAMIC_PLUGIN
+#include <vlc_plugin.h>
+/* Define a builtin module for mocked parts */
+const char vlc_module_name[] = MODULE_STRING;
+
+struct aout_sys
+{
+    vlc_tick_t first_play_date;
+    vlc_tick_t pos;
+};
+
+static void aout_Play(audio_output_t *aout, block_t *block, vlc_tick_t date)
+{
+    struct aout_sys *sys = aout->sys;
+
+    if (sys->first_play_date == VLC_TICK_INVALID)
+        sys->first_play_date = date;
+
+    aout_TimingReport(aout, sys->first_play_date + sys->pos - VLC_TICK_0, sys->pos);
+    sys->pos += block->i_length;
+    block_Release(block);
+}
+
+static void aout_Flush(audio_output_t *aout)
+{
+    struct aout_sys *sys = aout->sys;
+    sys->pos = 0;
+    sys->first_play_date = VLC_TICK_INVALID;
+}
+
+static int aout_Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
+{
+    (void) aout;
+    return AOUT_FMT_LINEAR(fmt) ? VLC_SUCCESS : VLC_EGENERIC;
+}
+
+static void
+aout_Close(vlc_object_t *obj)
+{
+    audio_output_t *aout = (audio_output_t *)obj;
+    free(aout->sys);
+}
+
+static int aout_Open(vlc_object_t *obj)
+{
+    audio_output_t *aout = (audio_output_t *)obj;
+
+    aout->start = aout_Start;
+    aout->play = aout_Play;
+    aout->pause = NULL;
+    aout->flush = aout_Flush;
+    aout->stop = aout_Flush;
+    aout->volume_set = NULL;
+    aout->mute_set = NULL;
+
+    struct aout_sys *sys = aout->sys = malloc(sizeof(*sys));
+    assert(sys != NULL);
+    aout_Flush(aout);
+
+    return VLC_SUCCESS;
+}
+
+vlc_module_begin()
+    /* This aout module will report audio timings perfectly, but without any
+     * delay, in order to be usable for player tests. Indeed, this aout will
+     * report timings immediately from Play(), but points will be in the
+     * future (like when aout->time_get() is used). */
+    set_capability("audio output", 0)
+    set_callbacks(aout_Open, aout_Close)
+vlc_module_end()
+
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
+    VLC_SYMBOL(vlc_entry),
+    NULL
+};



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8605f410bbcc1358245aea0d91c419e9fccbfc0e...10a4528c1ef62d3703172c94415eff760acd7584

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8605f410bbcc1358245aea0d91c419e9fccbfc0e...10a4528c1ef62d3703172c94415eff760acd7584
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