3 * by Bertrand Baudet <bertrand_baudet@yahoo.com>
4 * (C) 2002, MPlayer team.
16 /*******************************************************************************************************************
18 * xmcd parser, cd info list
20 *******************************************************************************************************************/
24 cd_info_t
*cd_info
= NULL
;
26 cd_info
= malloc(sizeof(cd_info_t
));
28 mp_msg(MSGT_DEMUX
, MSGL_ERR
, MSGTR_MemAllocFailed
);
32 memset(cd_info
, 0, sizeof(cd_info_t
));
38 cd_info_free(cd_info_t
*cd_info
) {
39 cd_track_t
*cd_track
, *cd_track_next
;
40 if( cd_info
==NULL
) return;
41 if( cd_info
->artist
!=NULL
) free(cd_info
->artist
);
42 if( cd_info
->album
!=NULL
) free(cd_info
->album
);
43 if( cd_info
->genre
!=NULL
) free(cd_info
->genre
);
45 cd_track_next
= cd_info
->first
;
46 while( cd_track_next
!=NULL
) {
47 cd_track
= cd_track_next
;
48 cd_track_next
= cd_track
->next
;
49 if( cd_track
->name
!=NULL
) free(cd_track
->name
);
55 cd_info_add_track(cd_info_t
*cd_info
, char *track_name
, unsigned int track_nb
, unsigned int min
, unsigned int sec
, unsigned int msec
, unsigned long frame_begin
, unsigned long frame_length
) {
58 if( cd_info
==NULL
|| track_name
==NULL
) return NULL
;
60 cd_track
= malloc(sizeof(cd_track_t
));
61 if( cd_track
==NULL
) {
62 mp_msg(MSGT_DEMUX
, MSGL_ERR
, MSGTR_MemAllocFailed
);
65 memset(cd_track
, 0, sizeof(cd_track_t
));
67 cd_track
->name
= malloc(strlen(track_name
)+1);
68 if( cd_track
->name
==NULL
) {
69 mp_msg(MSGT_DEMUX
, MSGL_ERR
, MSGTR_MemAllocFailed
);
73 strcpy(cd_track
->name
, track_name
);
74 cd_track
->track_nb
= track_nb
;
77 cd_track
->msec
= msec
;
78 cd_track
->frame_begin
= frame_begin
;
79 cd_track
->frame_length
= frame_length
;
81 if( cd_info
->first
==NULL
) {
82 cd_info
->first
= cd_track
;
84 if( cd_info
->last
!=NULL
) {
85 cd_info
->last
->next
= cd_track
;
88 cd_track
->prev
= cd_info
->last
;
90 cd_info
->last
= cd_track
;
91 cd_info
->current
= cd_track
;
99 cd_info_get_track(cd_info_t
*cd_info
, unsigned int track_nb
) {
100 cd_track_t
*cd_track
=NULL
;
102 if( cd_info
==NULL
) return NULL
;
104 cd_track
= cd_info
->first
;
105 while( cd_track
!=NULL
) {
106 if( cd_track
->track_nb
==track_nb
) {
109 cd_track
= cd_track
->next
;
115 cd_info_debug(cd_info_t
*cd_info
) {
116 cd_track_t
*current_track
;
117 mp_msg(MSGT_DEMUX
, MSGL_INFO
, "================ CD INFO === start =========\n");
118 if( cd_info
==NULL
) {
119 mp_msg(MSGT_DEMUX
, MSGL_INFO
, "cd_info is NULL\n");
122 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " artist=[%s]\n", cd_info
->artist
);
123 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " album=[%s]\n", cd_info
->album
);
124 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " genre=[%s]\n", cd_info
->genre
);
125 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " nb_tracks=%d\n", cd_info
->nb_tracks
);
126 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " length= %2d:%02d.%02d\n", cd_info
->min
, cd_info
->sec
, cd_info
->msec
);
127 current_track
= cd_info
->first
;
128 while( current_track
!=NULL
) {
129 mp_msg(MSGT_DEMUX
, MSGL_INFO
, " #%2d %2d:%02d.%02d @ %7ld\t[%s] \n", current_track
->track_nb
, current_track
->min
, current_track
->sec
, current_track
->msec
, current_track
->frame_begin
, current_track
->name
);
130 current_track
= current_track
->next
;
132 mp_msg(MSGT_DEMUX
, MSGL_INFO
, "================ CD INFO === end =========\n");