[vlc-commits] [Git][videolan/vlc][master] 5 commits: cdrom: remove unused CDDA_DATA_START
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Thu Sep 9 07:53:26 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
36fdfe2b by Steve Lhomme at 2021-09-09T07:41:37+00:00
cdrom: remove unused CDDA_DATA_START
- - - - -
a0192334 by Steve Lhomme at 2021-09-09T07:41:37+00:00
cdda: use a define for the invalid/default sector LBA values
- - - - -
52c0abe9 by Steve Lhomme at 2021-09-09T07:41:37+00:00
cdrom: define the MinSecFrame to LBA based on duration of CDDA frames
The MSF format corresponds to a basic CD audio duration.
CD_ROM_CDDA_FRAMES is 75 (audio frames/sectors per second)
- - - - -
5ae7ca3e by Steve Lhomme at 2021-09-09T07:41:37+00:00
cdda: document CDDA_BLOCKS_ONCE
- - - - -
039bc91f by Steve Lhomme at 2021-09-09T07:41:37+00:00
cdda: read/set the time/length using vlc_tick API and CD_ROM_CDDA_FRAMES
sys->length and sys->position are in sectors/frames, so they are converted to
time using the number of frames per second (CD_ROM_CDDA_FRAMES).
- - - - -
2 changed files:
- modules/access/cdda.c
- modules/access/vcd/cdrom.h
Changes:
=====================================
modules/access/cdda.c
=====================================
@@ -66,6 +66,8 @@
#include <errno.h>
#endif
+#define INVALID_SECTOR ((unsigned) -1)
+
static vcddev_t *DiscOpen(vlc_object_t *obj, const char *location,
const char *path, unsigned *restrict trackp)
{
@@ -129,7 +131,7 @@ static vcddev_t *DiscOpen(vlc_object_t *obj, const char *location,
}
/* how many blocks Demux() will read in each iteration */
-#define CDDA_BLOCKS_ONCE 20
+#define CDDA_BLOCKS_ONCE 20 // ~267 ms
typedef struct
{
@@ -184,10 +186,6 @@ static int DemuxControl(demux_t *demux, int query, va_list args)
{
demux_sys_t *sys = demux->p_sys;
- /* One sector is 40000/3 µs */
- static_assert (CDDA_DATA_SIZE * CLOCK_FREQ * 3 ==
- 4 * 44100 * INT64_C(40000), "Wrong time/sector ratio");
-
switch (query)
{
case DEMUX_CAN_SEEK:
@@ -213,13 +211,13 @@ static int DemuxControl(demux_t *demux, int query, va_list args)
break;
case DEMUX_GET_LENGTH:
- *va_arg(args, vlc_tick_t *) = (INT64_C(40000) * sys->length) / 3;
+ *va_arg(args, vlc_tick_t *) = vlc_tick_from_samples(sys->length, CD_ROM_CDDA_FRAMES);
break;
case DEMUX_GET_TIME:
- *va_arg(args, vlc_tick_t *) = (INT64_C(40000) * sys->position) / 3;
+ *va_arg(args, vlc_tick_t *) = vlc_tick_from_samples(sys->position, CD_ROM_CDDA_FRAMES);
break;
case DEMUX_SET_TIME:
- sys->position = (va_arg(args, vlc_tick_t) * 3) / INT64_C(40000);
+ sys->position = samples_from_vlc_tick(va_arg(args, vlc_tick_t), CD_ROM_CDDA_FRAMES);
break;
default:
@@ -306,7 +304,7 @@ static int DemuxOpen(vlc_object_t *obj, vcddev_t *dev, unsigned track)
sys->length = var_InheritInteger(obj, "cdda-last-sector") - sys->start;
/* Track number in input item */
- if (sys->start == (unsigned)-1 || sys->length == (unsigned)-1)
+ if (sys->start == INVALID_SECTOR || sys->length == INVALID_SECTOR)
{
vcddev_toc_t *p_toc = ioctl_GetTOC(obj, dev);
if(p_toc == NULL)
@@ -702,8 +700,7 @@ static int ReadDir(stream_t *access, input_item_node_t *node)
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;
+ vlc_tick_from_samples(i_last_sector - i_first_sector, CD_ROM_CDDA_FRAMES);
input_item_t *item = input_item_NewDisc(access->psz_url,
(name != NULL) ? name :
@@ -1007,9 +1004,9 @@ vlc_module_begin ()
add_integer( "cdda-track", 0 , NULL, NULL )
change_volatile ()
- add_integer( "cdda-first-sector", -1, NULL, NULL )
+ add_integer( "cdda-first-sector", INVALID_SECTOR, NULL, NULL )
change_volatile ()
- add_integer( "cdda-last-sector", -1, NULL, NULL )
+ add_integer( "cdda-last-sector", INVALID_SECTOR, NULL, NULL )
change_volatile ()
add_string( "musicbrainz-server", MUSICBRAINZ_DEFAULT_SERVER,
=====================================
modules/access/vcd/cdrom.h
=====================================
@@ -24,6 +24,8 @@
#ifndef VLC_CDROM_H
#define VLC_CDROM_H
+#include <assert.h>
+
enum {
CDDA_TYPE = 0,
VCD_TYPE = 1,
@@ -55,23 +57,24 @@ enum {
/* sector containing the entry points */
#define VCD_ENTRIES_SECTOR 151
-/* where the data start on a CDDA sector */
-#define CDDA_DATA_START 0
/* size of the available data on a CDDA sector */
#define CDDA_DATA_SIZE CD_RAW_SECTOR_SIZE
/* size of a CDDA sector, header and tail included */
#define CDDA_SECTOR_SIZE CD_RAW_SECTOR_SIZE
+/* number of audio frames per second */
+#define CD_ROM_CDDA_FRAMES ((44100 * 4) / CDDA_DATA_SIZE)
/*****************************************************************************
* Misc. Macros
*****************************************************************************/
static inline int MSF_TO_LBA(uint8_t min, uint8_t sec, uint8_t frame)
{
- return (int)(frame + 75 * (sec + 60 * min));
+ static_assert(((44100 * 4) % CDDA_DATA_SIZE) == 0, "bogus CDDA_DATA_SIZE");
+ return (int)(frame + CD_ROM_CDDA_FRAMES * (sec + 60 * min));
}
static inline int MSF_TO_LBA2(uint8_t min, uint8_t sec, uint8_t frame)
{
- return (int)(frame + 75 * (sec -2 + 60 * min));
+ return (int)(frame + CD_ROM_CDDA_FRAMES * (sec -2 + 60 * min));
}
/* Converts BCD to Binary data */
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a39d17557548830bc00df44ba7b71a778ddd5853...039bc91f68616932c8d17ba5658e4a6bdd39a02d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a39d17557548830bc00df44ba7b71a778ddd5853...039bc91f68616932c8d17ba5658e4a6bdd39a02d
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list