More audio control corrections.
This commit is contained in:
@@ -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