Mercurial > mplayer.hg
annotate libmpdemux/cdinfo.c @ 18696:e469a96bd99a
review of large parts of xml documentation
based on patches by Kurt Lettmaier (k . lettmaier @at@ onlinehome.de)
author | kraymer |
---|---|
date | Tue, 13 Jun 2006 21:40:48 +0000 |
parents | 32e2c59c8e86 |
children | 83c3afeab35d |
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> |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
7430
diff
changeset
|
14 #include "mp_msg.h" |
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
7430
diff
changeset
|
15 #include "help_mp.h" |
7430
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
16 #include "cdd.h" |
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 * |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
20 * xmcd parser, cd info list |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
24 cd_info_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
25 cd_info_new() { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
26 cd_info_t *cd_info = NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
27 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
28 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
|
29 if( cd_info==NULL ) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
7430
diff
changeset
|
30 mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed); |
7430
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
31 return NULL; |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
34 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
|
35 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
36 return cd_info; |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
39 void |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
40 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
|
41 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
|
42 if( cd_info==NULL ) return; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
43 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
|
44 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
|
45 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
|
46 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
47 cd_track_next = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
48 while( cd_track_next!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
49 cd_track = cd_track_next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
50 cd_track_next = cd_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
51 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
|
52 free(cd_track); |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
56 cd_track_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
57 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
|
58 cd_track_t *cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
59 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
60 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
|
61 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
62 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
|
63 if( cd_track==NULL ) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
7430
diff
changeset
|
64 mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed); |
7430
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
65 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
66 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
67 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
|
68 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
69 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
|
70 if( cd_track->name==NULL ) { |
16967
32e2c59c8e86
[TRIVIAL] More translatables to help_mp and printfs to mp_msg on libmpdemux
reynaldo
parents:
7430
diff
changeset
|
71 mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed); |
7430
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
72 free(cd_track); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
73 return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
74 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
75 strcpy(cd_track->name, track_name); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
76 cd_track->track_nb = track_nb; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
77 cd_track->min = min; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
78 cd_track->sec = sec; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
79 cd_track->msec = msec; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
80 cd_track->frame_begin = frame_begin; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
81 cd_track->frame_length = frame_length; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
82 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
83 if( cd_info->first==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
84 cd_info->first = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
85 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
86 if( cd_info->last!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
87 cd_info->last->next = cd_track; |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
90 cd_track->prev = cd_info->last; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
91 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
92 cd_info->last = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
93 cd_info->current = cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
94 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
95 cd_info->nb_tracks++; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
96 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
97 return cd_track; |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
100 cd_track_t* |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
101 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
|
102 cd_track_t *cd_track=NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
103 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
104 if( cd_info==NULL ) return NULL; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
105 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
106 cd_track = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
107 while( cd_track!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
108 if( cd_track->track_nb==track_nb ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
109 return cd_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
110 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
111 cd_track = cd_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
112 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
113 return NULL; |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
116 void |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
117 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
|
118 cd_track_t *current_track; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
119 printf("================ CD INFO === start =========\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
120 if( cd_info==NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
121 printf("cd_info is NULL\n"); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
122 return; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
123 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
124 printf(" artist=[%s]\n", cd_info->artist); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
125 printf(" album=[%s]\n", cd_info->album); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
126 printf(" genre=[%s]\n", cd_info->genre); |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
127 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
|
128 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
|
129 current_track = cd_info->first; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
130 while( current_track!=NULL ) { |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
131 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
|
132 current_track = current_track->next; |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
133 } |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
134 printf("================ CD INFO === end =========\n"); |
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 |
4304d0980a62
Moved all the cdinfo specific from cddb to a standalone file, so
bertrand
parents:
diff
changeset
|
137 #endif |