loop over cdtext using length reported back by MMC TOC command.
Test sequence number only for valid blocks. cdtext_private.h: add enumeration to facilitate debugging cdtext.c: On Windows CD-Text was off by 4. Hack for this.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdtext.c,v 1.3 2005/02/24 06:32:57 rocky Exp $
|
||||
$Id: cdtext.c,v 1.4 2005/03/23 11:15:25 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
toc reading routine adapted from cuetools
|
||||
@@ -153,11 +153,11 @@ cdtext_set (cdtext_field_t key, const char *p_value, cdtext_t *p_cdtext)
|
||||
*/
|
||||
bool
|
||||
cdtext_data_init(void *p_user_data, track_t i_first_track,
|
||||
unsigned char *wdata,
|
||||
unsigned char *wdata, int i_data,
|
||||
set_cdtext_field_fn_t set_cdtext_field_fn)
|
||||
{
|
||||
CDText_data_t *p_data;
|
||||
int i;
|
||||
int i = -1;
|
||||
int j;
|
||||
char buffer[256];
|
||||
int idx;
|
||||
@@ -168,7 +168,22 @@ cdtext_data_init(void *p_user_data, track_t i_first_track,
|
||||
idx = 0;
|
||||
|
||||
p_data = (CDText_data_t *) (&wdata[4]);
|
||||
for( i=0; i < CDIO_CDTEXT_MAX_PACK_DATA; i++ ) {
|
||||
|
||||
/* For reasons I don't understand - incorrect CDROM TOC reading?
|
||||
we are off sometimes by 4.
|
||||
*/
|
||||
if( (p_data->type < 0x80) || (p_data->type > 0x85)
|
||||
|| (p_data->block == 0) ) {
|
||||
CDText_data_t *p_data_test = (CDText_data_t *) (&wdata[8]);
|
||||
if( (p_data_test->type >= 0x80)
|
||||
&& (p_data_test->type <= 0x85) && (p_data_test->block == 0) ) {
|
||||
p_data = p_data_test;
|
||||
i_data -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
for( ; i_data > 0;
|
||||
i_data -= sizeof(CDText_data_t), p_data++ ) {
|
||||
|
||||
#if TESTED
|
||||
if ( p_data->bDBC ) {
|
||||
@@ -177,13 +192,13 @@ cdtext_data_init(void *p_user_data, track_t i_first_track,
|
||||
}
|
||||
#endif
|
||||
|
||||
if( p_data->seq != i )
|
||||
break;
|
||||
|
||||
if( (p_data->type >= 0x80)
|
||||
&& (p_data->type <= 0x85) && (p_data->block == 0) ) {
|
||||
i_track = p_data->i_track;
|
||||
|
||||
i++;
|
||||
if( p_data->seq != i ) break;
|
||||
|
||||
for( j=0; j < CDIO_CDTEXT_MAX_TEXT_DATA; j++ ) {
|
||||
if( p_data->text[j] == 0x00 ) {
|
||||
bool b_field_set=true;
|
||||
@@ -225,7 +240,6 @@ cdtext_data_init(void *p_user_data, track_t i_first_track,
|
||||
buffer[idx] = 0x00;
|
||||
}
|
||||
}
|
||||
p_data++;
|
||||
}
|
||||
return b_ret;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
$Id: cdtext_private.h,v 1.1 2004/12/18 17:29:32 rocky Exp $
|
||||
$Id: cdtext_private.h,v 1.2 2005/03/23 11:15:25 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 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
|
||||
@@ -24,6 +24,28 @@
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/cdtext.h>
|
||||
|
||||
/*! An enumeration for some of the CDIO_CDTEXT_* #defines below. This isn't
|
||||
really an enumeration one would really use in a program it is here
|
||||
to be helpful in debuggers where wants just to refer to the
|
||||
ISO_*_ names and get something.
|
||||
*/
|
||||
extern enum cdtext_enum1_s {
|
||||
CDIO_CDTEXT_MAX_PACK_DATA = 255,
|
||||
CDIO_CDTEXT_MAX_TEXT_DATA = 12,
|
||||
CDIO_CDTEXT_TITLE = 0x80,
|
||||
CDIO_CDTEXT_PERFORMER = 0x81,
|
||||
CDIO_CDTEXT_SONGWRITER = 0x82,
|
||||
CDIO_CDTEXT_COMPOSER = 0x83,
|
||||
CDIO_CDTEXT_ARRANGER = 0x84,
|
||||
CDIO_CDTEXT_MESSAGE = 0x85,
|
||||
CDIO_CDTEXT_DISCID = 0x86,
|
||||
CDIO_CDTEXT_GENRE = 0x87,
|
||||
CDIO_CDTEXT_TOC = 0x88,
|
||||
CDIO_CDTEXT_TOC2 = 0x89,
|
||||
CDIO_CDTEXT_UPC = 0x8E,
|
||||
CDIO_CDTEXT_BLOCKSIZE = 0x8F
|
||||
} cdtext_enums1;
|
||||
|
||||
#define CDIO_CDTEXT_MAX_PACK_DATA 255
|
||||
#define CDIO_CDTEXT_MAX_TEXT_DATA 12
|
||||
|
||||
@@ -70,7 +92,6 @@
|
||||
/* Size information of the Block */
|
||||
#define CDIO_CDTEXT_BLOCKSIZE 0x8F
|
||||
|
||||
|
||||
PRAGMA_BEGIN_PACKED
|
||||
|
||||
struct CDText_data
|
||||
@@ -104,7 +125,7 @@ typedef void (*set_cdtext_field_fn_t) (void *user_data, track_t i_track,
|
||||
Internal routine to parse all CD-TEXT data retrieved.
|
||||
*/
|
||||
bool cdtext_data_init(void *user_data, track_t i_first_track,
|
||||
unsigned char *wdata,
|
||||
unsigned char *wdata, int i_data,
|
||||
set_cdtext_field_fn_t set_cdtext_field_fn);
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Common Multimedia Command (MMC) routines.
|
||||
|
||||
$Id: mmc.c,v 1.24 2005/03/19 16:17:13 rocky Exp $
|
||||
$Id: mmc.c,v 1.25 2005/03/23 11:15:25 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -470,7 +470,7 @@ mmc_init_cdtext_private ( void *p_user_data,
|
||||
return false;
|
||||
}
|
||||
p_env->b_cdtext_init = true;
|
||||
return cdtext_data_init(p_env, p_env->i_first_track, wdata,
|
||||
return cdtext_data_init(p_env, p_env->i_first_track, wdata, i_cdtext-2,
|
||||
set_cdtext_field_fn);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user