More audio control corrections.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: audio.h,v 1.5 2005/03/05 09:26:52 rocky Exp $
|
||||
$Id: audio.h,v 1.6 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -121,6 +121,14 @@ extern "C" {
|
||||
driver_return_code_t cdio_audio_set_volume (CdIo_t *p_cdio,
|
||||
cdio_audio_volume_t *p_volume);
|
||||
|
||||
/*!
|
||||
Stop playing an audio CD.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
driver_return_code_t cdio_audio_stop (CdIo_t *p_cdio);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: device.h,v 1.18 2005/03/05 10:48:41 rocky Exp $
|
||||
$Id: device.h,v 1.19 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -216,6 +216,14 @@ extern "C" {
|
||||
DRIVER_OP_BAD_POINTER = -6, /**< Bad pointer to memory area */
|
||||
} driver_return_code_t;
|
||||
|
||||
/*!
|
||||
Close media tray in CD drive if there is a routine to do so.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
|
||||
*/
|
||||
driver_return_code_t cdio_close_tray (CdIo_t *p_cdio);
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: sector.h,v 1.35 2005/02/06 04:20:25 rocky Exp $
|
||||
$Id: sector.h,v 1.36 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -212,45 +212,45 @@
|
||||
/*!
|
||||
Convert an LBA into a string representation of the MSF.
|
||||
\warning cdio_lba_to_msf_str returns new allocated string */
|
||||
char *cdio_lba_to_msf_str (lba_t lba);
|
||||
char *cdio_lba_to_msf_str (lba_t i_lba);
|
||||
|
||||
/*!
|
||||
Convert an MSF into a string representation of the MSF.
|
||||
\warning cdio_msf_to_msf_str returns new allocated string */
|
||||
char *cdio_msf_to_str (const msf_t *msf);
|
||||
char *cdio_msf_to_str (const msf_t *p_msf);
|
||||
|
||||
/*!
|
||||
Convert an LBA into the corresponding LSN.
|
||||
*/
|
||||
lba_t cdio_lba_to_lsn (lba_t lba);
|
||||
lba_t cdio_lba_to_lsn (lba_t i_lba);
|
||||
|
||||
/*!
|
||||
Convert an LBA into the corresponding MSF.
|
||||
*/
|
||||
void cdio_lba_to_msf(lba_t lba, msf_t *msf);
|
||||
void cdio_lba_to_msf(lba_t i_lba, msf_t *p_msf);
|
||||
|
||||
/*!
|
||||
Convert an LSN into the corresponding LBA.
|
||||
CDIO_INVALID_LBA is returned if there is an error.
|
||||
*/
|
||||
lba_t cdio_lsn_to_lba (lsn_t lsn);
|
||||
lba_t cdio_lsn_to_lba (lsn_t i_lsn);
|
||||
|
||||
/*!
|
||||
Convert an LSN into the corresponding MSF.
|
||||
*/
|
||||
void cdio_lsn_to_msf (lsn_t lsn, msf_t *msf);
|
||||
void cdio_lsn_to_msf (lsn_t i_lsn, msf_t *p_msf);
|
||||
|
||||
/*!
|
||||
Convert a MSF into the corresponding LBA.
|
||||
CDIO_INVALID_LBA is returned if there is an error.
|
||||
*/
|
||||
lba_t cdio_msf_to_lba (const msf_t *msf);
|
||||
lba_t cdio_msf_to_lba (const msf_t *p_msf);
|
||||
|
||||
/*!
|
||||
Convert a MSF into the corresponding LSN.
|
||||
CDIO_INVALID_LSN is returned if there is an error.
|
||||
*/
|
||||
lsn_t cdio_msf_to_lsn (const msf_t *msf);
|
||||
lsn_t cdio_msf_to_lsn (const msf_t *p_msf);
|
||||
|
||||
/*!
|
||||
Convert a MSF - broken out as 3 integer components into the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: freebsd.c,v 1.20 2005/03/05 23:21:40 rocky Exp $
|
||||
$Id: freebsd.c,v 1.21 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: freebsd.c,v 1.20 2005/03/05 23:21:40 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: freebsd.c,v 1.21 2005/03/06 11:21:52 rocky Exp $";
|
||||
|
||||
#include "freebsd.h"
|
||||
|
||||
@@ -301,13 +301,13 @@ audio_play_msf_freebsd (void *p_user_data, msf_t *p_start_msf,
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
struct ioc_play_msf freebsd_play_msf;
|
||||
|
||||
freebsd_play_msf.start_m = p_start_msf->m;
|
||||
freebsd_play_msf.start_s = p_start_msf->s;
|
||||
freebsd_play_msf.start_f = p_start_msf->f;
|
||||
freebsd_play_msf.start_m = cdio_from_bcd8(p_start_msf->m);
|
||||
freebsd_play_msf.start_s = cdio_from_bcd8(p_start_msf->s);
|
||||
freebsd_play_msf.start_f = cdio_from_bcd8(p_start_msf->f);
|
||||
|
||||
freebsd_play_msf.end_m = p_end_msf->m;
|
||||
freebsd_play_msf.end_s = p_end_msf->s;
|
||||
freebsd_play_msf.end_f = p_end_msf->f;
|
||||
freebsd_play_msf.end_m = cdio_from_bcd8(p_end_msf->m);
|
||||
freebsd_play_msf.end_s = cdio_from_bcd8(p_end_msf->s);
|
||||
freebsd_play_msf.end_f = cdio_from_bcd8(p_end_msf->f);
|
||||
|
||||
return ioctl(p_env->gen.fd, CDIOCPLAYMSF, &freebsd_play_msf);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: win32_ioctl.c,v 1.18 2005/03/06 00:54:50 rocky Exp $
|
||||
$Id: win32_ioctl.c,v 1.19 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.18 2005/03/06 00:54:50 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: win32_ioctl.c,v 1.19 2005/03/06 11:21:52 rocky Exp $";
|
||||
|
||||
#ifdef HAVE_WIN32_CDROM
|
||||
|
||||
@@ -140,13 +140,13 @@ audio_play_msf_win32ioctl (void *p_user_data, msf_t *p_start_msf,
|
||||
CDROM_PLAY_AUDIO_MSF play;
|
||||
DWORD dw_bytes_returned;
|
||||
|
||||
play.StartingM = p_start_msf->m;
|
||||
play.StartingS = p_start_msf->s;
|
||||
play.StartingF = p_start_msf->f;
|
||||
play.StartingM = cdio_from_bcd8(p_start_msf->m);
|
||||
play.StartingS = cdio_from_bcd8(p_start_msf->s);
|
||||
play.StartingF = cdio_from_bcd8(p_start_msf->f);
|
||||
|
||||
play.EndingM = p_end_msf->m;
|
||||
play.EndingS = p_end_msf->s;
|
||||
play.EndingF = p_end_msf->f;
|
||||
play.EndingM = cdio_from_bcd8(p_end_msf->m);
|
||||
play.EndingS = cdio_from_bcd8(p_end_msf->s);
|
||||
play.EndingF = cdio_from_bcd8(p_end_msf->f);
|
||||
|
||||
bool b_success =
|
||||
DeviceIoControl(p_env->h_device_handle, IOCTL_CDROM_PLAY_AUDIO_MSF,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: audio.c,v 1.4 2005/03/05 09:26:52 rocky Exp $
|
||||
$Id: audio.c,v 1.5 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -148,3 +148,30 @@ cdio_audio_set_volume (CdIo_t *p_cdio, cdio_audio_volume_t *p_volume)
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Resume playing an audio CD.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
driver_return_code_t
|
||||
cdio_audio_stop (CdIo_t *p_cdio)
|
||||
{
|
||||
if (!p_cdio) return DRIVER_OP_UNINIT;
|
||||
|
||||
if (!p_cdio->op.audio_stop) {
|
||||
return p_cdio->op.audio_stop(p_cdio->env);
|
||||
} else {
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-file-style: "gnu"
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio_private.h,v 1.21 2005/03/05 10:48:41 rocky Exp $
|
||||
$Id: cdio_private.h,v 1.22 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -111,14 +111,30 @@ extern "C" {
|
||||
*/
|
||||
driver_return_code_t (*audio_set_volume)
|
||||
( void *p_env, cdio_audio_volume_t *p_volume );
|
||||
|
||||
/*!
|
||||
Stop playing an audio CD.
|
||||
|
||||
@param p_env the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
driver_return_code_t (*audio_stop) ( void *p_env );
|
||||
|
||||
/*!
|
||||
Close media tray in CD drive if there is a routine to do so.
|
||||
|
||||
@param p_env the CD object to be acted upon.
|
||||
*/
|
||||
driver_return_code_t (*close_tray) ( void *p_env );
|
||||
|
||||
/*!
|
||||
Eject media in CD drive. If successful, as a side effect we
|
||||
also free obj. Return 0 if success and 1 for failure.
|
||||
also free p_env.
|
||||
|
||||
@param p_env the CD object to be acted upon.
|
||||
If the CD is ejected *p_env is freed and p_env set to NULL.
|
||||
*/
|
||||
int (*eject_media) (void *p_env);
|
||||
driver_return_code_t (*eject_media) ( void *p_env );
|
||||
|
||||
/*!
|
||||
Release and free resources associated with cd.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: device.c,v 1.12 2005/03/05 10:48:41 rocky Exp $
|
||||
$Id: device.c,v 1.13 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -288,6 +288,24 @@ cdio_destroy (CdIo_t *p_cdio)
|
||||
free (p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
Close media tray in CD drive if there is a routine to do so.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
|
||||
*/
|
||||
driver_return_code_t
|
||||
cdio_close_tray (CdIo_t *p_cdio)
|
||||
{
|
||||
if (!p_cdio) return DRIVER_OP_UNINIT;
|
||||
|
||||
if (!p_cdio->op.close_tray) {
|
||||
return p_cdio->op.close_tray(p_cdio->env);
|
||||
} else {
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: gnu_linux.c,v 1.4 2005/03/06 00:03:53 rocky Exp $
|
||||
$Id: gnu_linux.c,v 1.5 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.4 2005/03/06 00:03:53 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.5 2005/03/06 11:21:52 rocky Exp $";
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -233,13 +233,13 @@ audio_play_msf_linux (void *p_user_data, msf_t *p_start_msf, msf_t *p_end_msf)
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
struct cdrom_msf cdrom_msf;
|
||||
|
||||
cdrom_msf.cdmsf_min0 = p_start_msf->m;
|
||||
cdrom_msf.cdmsf_sec0 = p_start_msf->s;
|
||||
cdrom_msf.cdmsf_frame0 = p_start_msf->f;
|
||||
cdrom_msf.cdmsf_min0 = cdio_from_bcd8(p_start_msf->m);
|
||||
cdrom_msf.cdmsf_sec0 = cdio_from_bcd8(p_start_msf->s);
|
||||
cdrom_msf.cdmsf_frame0 = cdio_from_bcd8(p_start_msf->f);
|
||||
|
||||
cdrom_msf.cdmsf_min1 = p_end_msf->m;
|
||||
cdrom_msf.cdmsf_sec1 = p_end_msf->s;
|
||||
cdrom_msf.cdmsf_frame1 = p_end_msf->f;
|
||||
cdrom_msf.cdmsf_min1 = cdio_from_bcd8(p_end_msf->m);
|
||||
cdrom_msf.cdmsf_sec1 = cdio_from_bcd8(p_end_msf->s);
|
||||
cdrom_msf.cdmsf_frame1 = cdio_from_bcd8(p_end_msf->f);
|
||||
|
||||
return ioctl(p_env->gen.fd, CDROMPLAYMSF, &cdrom_msf);
|
||||
}
|
||||
@@ -283,7 +283,6 @@ audio_read_subchannel_linux (void *p_user_data,
|
||||
static driver_return_code_t
|
||||
audio_resume_linux (void *p_user_data)
|
||||
{
|
||||
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
return ioctl(p_env->gen.fd, CDROMRESUME, 0);
|
||||
}
|
||||
@@ -291,17 +290,42 @@ audio_resume_linux (void *p_user_data)
|
||||
/*!
|
||||
Set the volume of an audio CD.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
@param p_user_data the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
static driver_return_code_t
|
||||
audio_set_volume_linux (void *p_user_data, cdio_audio_volume_t *p_volume)
|
||||
{
|
||||
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
return ioctl(p_env->gen.fd, CDROMVOLCTRL, p_volume);
|
||||
}
|
||||
|
||||
/*!
|
||||
Stop playing an audio CD.
|
||||
|
||||
@param p_user_data the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
static driver_return_code_t
|
||||
audio_stop_linux (void *p_user_data)
|
||||
{
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
return ioctl(p_env->gen.fd, CDROMSTOP);
|
||||
}
|
||||
|
||||
/*!
|
||||
Stop playing an audio CD.
|
||||
|
||||
@param p_user_data the CD object to be acted upon.
|
||||
|
||||
*/
|
||||
static driver_return_code_t
|
||||
close_tray_linux (void *p_user_data)
|
||||
{
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
return ioctl(p_env->gen.fd, CDROMCLOSETRAY);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the value associated with the key "arg".
|
||||
*/
|
||||
@@ -1329,6 +1353,8 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
|
||||
#endif
|
||||
.audio_resume = audio_resume_linux,
|
||||
.audio_set_volume = audio_set_volume_linux,
|
||||
.audio_stop = audio_stop_linux,
|
||||
.close_tray = close_tray_linux,
|
||||
.eject_media = eject_media_linux,
|
||||
.free = cdio_generic_free,
|
||||
.get_arg = get_arg_linux,
|
||||
|
||||
@@ -20,6 +20,8 @@ cdio_audio_play_track_index
|
||||
cdio_audio_read_subchannel
|
||||
cdio_audio_resume
|
||||
cdio_audio_set_volume
|
||||
cdio_audio_stop
|
||||
cdio_close_tray
|
||||
cdio_debug
|
||||
cdio_destroy
|
||||
cdio_driver_describe
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: solaris.c,v 1.3 2005/03/06 00:55:42 rocky Exp $
|
||||
$Id: solaris.c,v 1.4 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#ifdef HAVE_SOLARIS_CDROM
|
||||
|
||||
static const char _rcsid[] = "$Id: solaris.c,v 1.3 2005/03/06 00:55:42 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: solaris.c,v 1.4 2005/03/06 11:21:52 rocky Exp $";
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
#include <glob.h>
|
||||
@@ -144,12 +144,12 @@ audio_play_msf_solaris (void *p_user_data, msf_t *p_start_msf,
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
|
||||
struct cdrom_msf solaris_msf;
|
||||
solaris_msf.cdmsf_min0 = p_start_msf->m;
|
||||
solaris_msf.cdmsf_sec0 = p_start_msf->s;
|
||||
solaris_msf.cdmsf_frame0 = p_start_msf->f;
|
||||
solaris_msf.cdmsf_min1 = p_end_msf->m;
|
||||
solaris_msf.cdmsf_sec1 = p_end_msf->s;
|
||||
solaris_msf.cdmsf_frame1 = p_end_msf->f;
|
||||
solaris_msf.cdmsf_min0 = cdio_from_bcd8(p_start_msf->m);
|
||||
solaris_msf.cdmsf_sec0 = cdio_from_bcd8(p_start_msf->s);
|
||||
solaris_msf.cdmsf_frame0 = cdio_from_bcd8(p_start_msf->f);
|
||||
solaris_msf.cdmsf_min1 = cdio_from_bcd8(p_end_msf->m);
|
||||
solaris_msf.cdmsf_sec1 = cdio_from_bcd8(p_end_msf->s);
|
||||
solaris_msf.cdmsf_frame1 = cdio_from_bcd8(p_end_msf->f);
|
||||
|
||||
return ioctl(p_env->gen.fd, CDROMPLAYMSF, &solaris_msf);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cd-info.c,v 1.131 2005/03/06 02:59:26 rocky Exp $
|
||||
$Id: cd-info.c,v 1.132 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include "cddb.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_CDDB
|
||||
@@ -349,60 +350,6 @@ parse_options (int argc, const char *argv[])
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* CDDB */
|
||||
|
||||
/*
|
||||
Returns the sum of the decimal digits in a number. Eg. 1955 = 20
|
||||
*/
|
||||
static int
|
||||
cddb_dec_digit_sum(int n)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
for (;;) {
|
||||
ret += n%10;
|
||||
n = n/10;
|
||||
if (!n)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the number of seconds (discarding frame portion) of an MSF */
|
||||
static inline unsigned int
|
||||
msf_seconds(msf_t *msf)
|
||||
{
|
||||
return cdio_from_bcd8(msf->m)*CDIO_CD_SECS_PER_MIN + cdio_from_bcd8(msf->s);
|
||||
}
|
||||
|
||||
/*
|
||||
Compute the CDDB disk ID for an Audio disk. This is a funny checksum
|
||||
consisting of the concatenation of 3 things:
|
||||
the sum of the decimal digits of sizes of all tracks,
|
||||
the total length of the disk, and
|
||||
the number of tracks.
|
||||
*/
|
||||
static unsigned long
|
||||
cddb_discid(CdIo_t *p_cdio, int i_tracks)
|
||||
{
|
||||
int i,t,n=0;
|
||||
msf_t start_msf;
|
||||
msf_t msf;
|
||||
|
||||
for (i = 1; i <= i_tracks; i++) {
|
||||
cdio_get_track_msf(p_cdio, i, &msf);
|
||||
n += cddb_dec_digit_sum(msf_seconds(&msf));
|
||||
}
|
||||
|
||||
cdio_get_track_msf(p_cdio, 1, &start_msf);
|
||||
cdio_get_track_msf(p_cdio, CDIO_CDROM_LEADOUT_TRACK, &msf);
|
||||
|
||||
t = msf_seconds(&msf) - msf_seconds(&start_msf);
|
||||
|
||||
return ((n % 0xff) << 24 | t << 8 | i_tracks);
|
||||
}
|
||||
|
||||
|
||||
/* CDIO logging routines */
|
||||
|
||||
static cdio_log_handler_t gl_default_cdio_log_handler = NULL;
|
||||
|
||||
77
src/cddb.c
Normal file
77
src/cddb.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
$Id: cddb.c,v 1.1 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/util.h>
|
||||
#include "cddb.h"
|
||||
|
||||
/* Return the number of seconds (discarding frame portion) of an MSF */
|
||||
static inline unsigned int
|
||||
msf_seconds(msf_t *p_msf)
|
||||
{
|
||||
return
|
||||
cdio_from_bcd8(p_msf->m)*CDIO_CD_SECS_PER_MIN + cdio_from_bcd8(p_msf->s);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the sum of the decimal digits in a number. Eg. 1955 = 20
|
||||
*/
|
||||
static int
|
||||
cddb_dec_digit_sum(int n)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
for (;;) {
|
||||
ret += n%10;
|
||||
n = n/10;
|
||||
if (!n) return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Compute the CDDB disk ID for an Audio disk. This is a funny checksum
|
||||
consisting of the concatenation of 3 things:
|
||||
the sum of the decimal digits of sizes of all tracks,
|
||||
the total length of the disk, and
|
||||
the number of tracks.
|
||||
*/
|
||||
unsigned long
|
||||
cddb_discid(CdIo_t *p_cdio, track_t i_tracks)
|
||||
{
|
||||
int i,t,n=0;
|
||||
msf_t start_msf;
|
||||
msf_t msf;
|
||||
|
||||
for (i = 1; i <= i_tracks; i++) {
|
||||
cdio_get_track_msf(p_cdio, i, &msf);
|
||||
n += cddb_dec_digit_sum(msf_seconds(&msf));
|
||||
}
|
||||
|
||||
cdio_get_track_msf(p_cdio, 1, &start_msf);
|
||||
cdio_get_track_msf(p_cdio, CDIO_CDROM_LEADOUT_TRACK, &msf);
|
||||
|
||||
t = msf_seconds(&msf) - msf_seconds(&start_msf);
|
||||
|
||||
return ((n % 0xff) << 24 | t << 8 | i_tracks);
|
||||
}
|
||||
28
src/cddb.h
Normal file
28
src/cddb.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
$Id: cddb.h,v 1.1 2005/03/06 11:21:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
Compute the CDDB disk ID for an Audio disk. This is a funny checksum
|
||||
consisting of the concatenation of 3 things:
|
||||
the sum of the decimal digits of sizes of all tracks,
|
||||
the total length of the disk, and
|
||||
the number of tracks.
|
||||
*/
|
||||
unsigned long cddb_discid(CdIo_t *p_cdio, track_t i_tracks);
|
||||
Reference in New Issue
Block a user