[vlc-devel] [PATCH] sout: sdi: use macros and helpers instead of direct access to CLOCK_FREQ

Steve Lhomme robux4 at ycbcr.xyz
Tue Nov 5 08:19:48 CET 2019


On 2019-11-05 8:15, Steve Lhomme wrote:
> @@ -590,7 +590,7 @@ int DBMSDIOutput::doSchedule()
>       const vlc_tick_t preroll = DECKLINK_PREROLL;
>       vlc_tick_t next = videoBuffer.NextPictureTime();
>       if(next == VLC_TICK_INVALID ||
> -       (!b_running && !ReachedPlaybackTime(next + preroll + SAMPLES_PER_FRAME*CLOCK_FREQ/48000)))
> +       (!b_running && !ReachedPlaybackTime(next + preroll + vlc_tick_from_samples(SAMPLES_PER_FRAME,48000)))
>           return VLC_SUCCESS;
>   
>       if(FAKE_DRIVER)
> @@ -606,7 +606,7 @@ int DBMSDIOutput::doSchedule()
>       if(S_OK != p_output->GetBufferedVideoFrameCount(&bufferedFramesCount))
>           return VLC_EGENERIC;
>   
> -    uint32_t bufferedFramesTarget = (uint64_t)timescale*preroll/frameduration/CLOCK_FREQ;
> +    uint32_t bufferedFramesTarget = samples_from_vlc_tick(preroll,timescale)/frameduration;

This one is not mathematically equivalent, but it seems more appropriate 
in this context.

>       if( bufferedFramesTarget > bufferedFramesCount )
>       {
>           for(size_t i=0; i<bufferedFramesTarget - bufferedFramesCount; i++)
> @@ -631,11 +631,11 @@ int DBMSDIOutput::doSchedule()
>           if(S_OK != p_output->GetBufferedAudioSampleFrameCount(&bufferedAudioCount))
>               return VLC_EGENERIC;
>   
> -        uint32_t bufferedAudioTarget = 48000*preroll/CLOCK_FREQ;
> +        uint32_t bufferedAudioTarget = samples_from_vlc_tick(preroll, 48000);
>           if(bufferedAudioCount < bufferedAudioTarget)
>           {
> -            vlc_tick_t audioSamplesDuration = (bufferedAudioTarget - bufferedAudioCount)
> -                                            * CLOCK_FREQ / 48000;
> +            vlc_tick_t audioSamplesDuration = vlc_tick_from_samples(bufferedAudioTarget - bufferedAudioCount,
> +                                                                    48000);
>               if(b_running)
>                   FeedAudio(next, audioSamplesDuration, false);
>               else


More information about the vlc-devel mailing list