Logo Search packages:      
Sourcecode: tcd version File versions  Download package

cd-utils.c

#include "cd-utils.h"

extern int cd_length(const SDL_CD * cdrom)
{
    int len = 0, i;
    for (i = 0; i < cdrom->numtracks; i++) {
        len += cdrom->track[i].length;
    }
    return len;
}

static int cddb_sum(unsigned int n)
{
    int result = 0;
    while (n != 0) {
        result += n % 10;
        n /= 10;
    }
    return result;
}

extern unsigned long cddb_discid(const SDL_CD * cdrom)
{
    unsigned int n = 0, t = 0, i;
    for (i = 0; i < (unsigned int) cdrom->numtracks; i++) {
        n += cddb_sum(cdrom->track[i].offset / CD_FPS);
    }
    t = (cdrom->track[cdrom->numtracks].offset / CD_FPS) -
        (cdrom->track[0].offset / CD_FPS);
    return ((n % 0xff) << 24 | t << 8 | cdrom->numtracks);
}

Generated by  Doxygen 1.6.0   Back to index