Mercurial > mplayer.hg
annotate libmpdemux/cdinfo.c @ 12011:15fc081c071c
--disable-xmms option was missing, noticed by Enrico Weigelt.
author | diego |
---|---|
date | Fri, 05 Mar 2004 04:44:32 +0000 |
parents | 4304d0980a62 |
children | 32e2c59c8e86 |
rev | line source |
---|---|
7430
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
1 /* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
2 * CD Info |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
3 * by Bertrand Baudet <bertrand_baudet@yahoo.com> |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
4 * (C) 2002, MPlayer team. |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
5 */ |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
6 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
7 #include "config.h" |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
8 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
9 #if defined(HAVE_CDDA) |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
10 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
11 #include <stdio.h> |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
12 #include <stdlib.h> |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
13 #include <string.h> |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
14 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
15 #include "cdd.h" |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
16 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
17 /******************************************************************************************************************* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
18 * |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
19 * xmcd parser, cd info list |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
20 * |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
21 *******************************************************************************************************************/ |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
22 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
23 cd_info_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
24 cd_info_new() { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
25 cd_info_t *cd_info = NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
26 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
27 cd_info = (cd_info_t*)malloc(sizeof(cd_info_t)); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
28 if( cd_info==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
29 printf("Memory allocation failed\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
30 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
31 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
32 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
33 memset(cd_info, 0, sizeof(cd_info_t)); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
34 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
35 return cd_info; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
36 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
37 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
38 void |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
39 cd_info_free(cd_info_t *cd_info) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
40 cd_track_t *cd_track, *cd_track_next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
41 if( cd_info==NULL ) return; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
42 if( cd_info->artist!=NULL ) free(cd_info->artist); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
43 if( cd_info->album!=NULL ) free(cd_info->album); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
44 if( cd_info->genre!=NULL ) free(cd_info->genre); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
45 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
46 cd_track_next = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
47 while( cd_track_next!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
48 cd_track = cd_track_next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
49 cd_track_next = cd_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
50 if( cd_track->name!=NULL ) free(cd_track->name); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
51 free(cd_track); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
52 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
53 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
54 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
55 cd_track_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
56 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) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
57 cd_track_t *cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
58 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
59 if( cd_info==NULL || track_name==NULL ) return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
60 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
61 cd_track = (cd_track_t*)malloc(sizeof(cd_track_t)); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
62 if( cd_track==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
63 printf("Memory allocation failed\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
64 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
65 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
66 memset(cd_track, 0, sizeof(cd_track_t)); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
67 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
68 cd_track->name = (char*)malloc(strlen(track_name)+1); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
69 if( cd_track->name==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
70 printf("Memory allocation failed\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
71 free(cd_track); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
72 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
73 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
74 strcpy(cd_track->name, track_name); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
75 cd_track->track_nb = track_nb; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
76 cd_track->min = min; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
77 cd_track->sec = sec; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
78 cd_track->msec = msec; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
79 cd_track->frame_begin = frame_begin; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
80 cd_track->frame_length = frame_length; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
81 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
82 if( cd_info->first==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
83 cd_info->first = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
84 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
85 if( cd_info->last!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
86 cd_info->last->next = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
87 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
88 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
89 cd_track->prev = cd_info->last; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
90 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
91 cd_info->last = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
92 cd_info->current = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
93 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
94 cd_info->nb_tracks++; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
95 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
96 return cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
97 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
98 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
99 cd_track_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
100 cd_info_get_track(cd_info_t *cd_info, unsigned int track_nb) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
101 cd_track_t *cd_track=NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
102 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
103 if( cd_info==NULL ) return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
104 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
105 cd_track = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
106 while( cd_track!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
107 if( cd_track->track_nb==track_nb ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
108 return cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
109 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
110 cd_track = cd_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
111 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
112 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
113 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
114 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
115 void |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
116 cd_info_debug(cd_info_t *cd_info) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
117 cd_track_t *current_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
118 printf("================ CD INFO === start =========\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
119 if( cd_info==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
120 printf("cd_info is NULL\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
121 return; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
122 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
123 printf(" artist=[%s]\n", cd_info->artist); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
124 printf(" album=[%s]\n", cd_info->album); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
125 printf(" genre=[%s]\n", cd_info->genre); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
126 printf(" nb_tracks=%d\n", cd_info->nb_tracks); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
127 printf(" length= %2d:%02d.%02d\n", cd_info->min, cd_info->sec, cd_info->msec); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
128 current_track = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
129 while( current_track!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
130 printf(" #%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); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
131 current_track = current_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
132 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
133 printf("================ CD INFO === end =========\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
134 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
135 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
136 #endif |