[vlc-devel] [PATCH 2/4] cdda: use vlc_tick helpers

Thomas Guillem thomas at gllm.fr
Wed Apr 7 13:31:24 UTC 2021


---
 modules/access/cdda.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 541e043a574..0c3d25cb808 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -180,12 +180,12 @@ static int Demux(demux_t *demux)
 
 static inline vlc_tick_t PositionToTime(unsigned position)
 {
-    return (INT64_C(40000) * position) / 3;
+    return vlc_tick_from_samples(CDDA_DATA_SIZE * position / 4, 44100);
 }
 
 static inline unsigned TimeToPosition(vlc_tick_t time)
 {
-    return time * 3 / INT64_C(40000);
+    return samples_from_vlc_tick(time * 4 / CDDA_DATA_SIZE, 44100);
 }
 
 static int DemuxControl(demux_t *demux, int query, va_list args)
@@ -576,7 +576,8 @@ static cddb_disc_t *GetCDDBInfo( vlc_object_t *obj, const vcddev_toc_t *p_toc )
         cddb_disc_add_track( p_disc, t );
         const int64_t i_size = ( p_toc->p_sectors[i+1].i_lba - p_toc->p_sectors[i].i_lba ) *
                                (int64_t)CDDA_DATA_SIZE;
-        i_length += INT64_C(1000000) * i_size / 44100 / 4  ;
+        i_length += vlc_tick_from_samples(i_size / 4, 44100);
+
 
         msg_Dbg( obj, "Track %i offset: %i", i, p_toc->p_sectors[i].i_lba + 150 );
     }
@@ -712,9 +713,7 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
            p_toc->i_last_track > sys->i_cdda_last)
             i_last_sector -= CD_ROM_XA_INTERVAL;
 
-        const vlc_tick_t duration =
-            (vlc_tick_t)(i_last_sector - i_first_sector)
-            * CDDA_DATA_SIZE * CLOCK_FREQ / 44100 / 2 / 2;
+        const vlc_tick_t duration = PositionToTime(i_last_sector - i_first_sector);
 
         input_item_t *item = input_item_NewDisc(access->psz_url,
                                                 (name != NULL) ? name :
-- 
2.30.0



More information about the vlc-devel mailing list