Mercurial > hg > xmms-sid
annotate src/xs_sidplay.h @ 130:84bff1a4bb1c dev-0_8_0b8
Fixed minor bugs in configuration dialog handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Jan 2004 22:03:02 +0000 |
parents | 54e4557859dc |
children | fe684a2ccdc7 |
rev | line source |
---|---|
76 | 1 /* |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
2 * Here comes the really ugly code... |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
3 * |
76 | 4 * Create the SID-tune description string from the tune's information |
5 * formatted by the user-specified format-string. | |
6 */ | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
7 #define VBUFSIZE (1024) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
8 #define VPUTCH(MCH) if (iIndex < VBUFSIZE) tmpBuf[iIndex++] = MCH; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
9 #define VPUTSTR(MSTR) {if (MSTR) {if ((iIndex + strlen(MSTR) + 1) < VBUFSIZE){strcpy(&tmpBuf[iIndex], MSTR);iIndex += strlen(MSTR); } else iIndex = VBUFSIZE;}} |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
10 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
11 gchar * TFUNCTION1(gchar *pcFilename, TTUNEINFO *pfInfo, gint iSubTune) |
76 | 12 { |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
13 gchar *sFileName, *sFilePath, *sFileExt, *pcStr, *pcResult, |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
14 tmpStr[VBUFSIZE], tmpBuf[VBUFSIZE]; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
15 gint iIndex; |
76 | 16 #ifdef HAVE_XMMSEXTRA |
17 TitleInput *ptInput; | |
18 #endif | |
19 | |
20 /* Check the info strings */ | |
21 if (pfInfo->numberOfInfoStrings < 3) | |
22 { | |
23 if (pfInfo->numberOfInfoStrings < 1) | |
24 return 0; | |
25 | |
26 return g_strdup(pfInfo->infoString[0]); | |
27 } | |
28 | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
29 /* Split the filename into path */ |
93 | 30 sFilePath = g_strdup(pcFilename); |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
31 sFileName = strrchr(sFilePath, '/'); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
32 if (sFileName) |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
33 sFileName[1] = 0; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
34 |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
35 /* Filename */ |
93 | 36 sFileName = strrchr(pcFilename, '/'); |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
37 if (sFileName) |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
38 sFileName = g_strdup(sFileName + 1); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
39 else |
93 | 40 sFileName = g_strdup(pcFilename); |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
41 |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
42 sFileExt = strrchr(sFileName, '.'); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
43 sFileExt[0] = 0; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
44 |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
45 /* Extension */ |
93 | 46 sFileExt = strrchr(pcFilename, '.'); |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
47 |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
48 |
76 | 49 #ifdef HAVE_XMMSEXTRA |
50 /* Check if the titles are overridden or not */ | |
51 if (!xs_cfg.titleOverride) | |
52 { | |
53 /* Use generic XMMS titles */ | |
54 /* XMMS_NEW_TITLEINPUT(ptInput); | |
55 * We duplicate and add typecast to the code here due to XMMS's braindead headers | |
56 */ | |
57 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput)); | |
58 ptInput->__size = XMMS_TITLEINPUT_SIZE; | |
59 ptInput->__version = XMMS_TITLEINPUT_VERSION; | |
60 | |
61 /* Create the input fields */ | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
62 ptInput->file_name = sFileName; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
63 ptInput->file_ext = sFileExt; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
64 ptInput->file_path = sFilePath; |
76 | 65 |
66 ptInput->track_name = pfInfo->infoString[0]; | |
67 ptInput->track_number = iSubTune; | |
68 ptInput->album_name = NULL; | |
69 ptInput->performer = pfInfo->infoString[1]; | |
115
54e4557859dc
Added SID-prefix to chip names
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
70 ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "SID6581" : "SID8580"); |
76 | 71 |
72 ptInput->year = 0; | |
73 ptInput->genre = g_strdup("SID-tune"); | |
74 ptInput->comment = pfInfo->infoString[2]; | |
75 | |
76 /* Create the string */ | |
77 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); | |
78 | |
79 /* Dispose all allocated memory */ | |
80 g_free(ptInput->date); | |
81 g_free(ptInput->genre); | |
82 g_free(ptInput); | |
83 } | |
84 else | |
85 #endif | |
86 { | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
87 /* Create the string */ |
76 | 88 pcStr = xs_cfg.titleFormat; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
89 iIndex = 0; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
90 while (*pcStr && (iIndex < VBUFSIZE)) |
76 | 91 { |
92 if (*pcStr == '%') | |
93 { | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
94 pcStr++; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
95 switch (*pcStr) { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
96 case '%': VPUTCH('%'); break; |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
97 case 'f': VPUTSTR(sFileName); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
98 case 'F': VPUTSTR(sFilePath); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
99 case 'e': VPUTSTR(sFileExt); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
100 case 'p': VPUTSTR(pfInfo->infoString[1]); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
101 case 't': VPUTSTR(pfInfo->infoString[0]); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
102 case 'c': VPUTSTR(pfInfo->infoString[2]); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
103 case 's': VPUTSTR(pfInfo->formatString); break; |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
104 case 'n': |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
105 snprintf(tmpStr, VBUFSIZE, "%i", iSubTune); |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
106 VPUTSTR(tmpStr); |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
107 break; |
76 | 108 } |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
109 } else { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
110 VPUTCH(*pcStr); |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
111 } |
76 | 112 pcStr++; |
113 } | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
114 |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
115 tmpBuf[iIndex] = 0; |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
116 |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
117 /* Make resulting string */ |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
118 pcResult = g_strdup(tmpBuf); |
76 | 119 } |
120 | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
121 /* Free temporary strings */ |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
122 g_free(sFileName); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
123 g_free(sFilePath); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
124 |
76 | 125 return pcResult; |
126 } | |
127 | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
128 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
129 /* |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
130 * Get all SID-tune information (for all sub-tunes) including name, length, etc. |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
131 */ |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
132 t_xs_tune * TFUNCTION2(gchar *pcFilename) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
133 { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
134 t_xs_sldb_node *tuneLen = NULL; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
135 t_xs_tune *pResult; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
136 TTUNEINFO tuneInfo; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
137 TTUNE *testTune; |
100 | 138 gboolean haveInfo = TRUE; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
139 gint i; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
140 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
141 /* Check if the tune exists and is readable */ |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
142 if ((testTune = new TTUNE(pcFilename)) == NULL) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
143 return NULL; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
144 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
145 if (!testTune->getStatus()) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
146 { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
147 delete testTune; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
148 return NULL; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
149 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
150 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
151 /* Get general tune information */ |
95 | 152 #ifdef _XS_SIDPLAY1_H |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
153 haveInfo = testTune->getInfo(tuneInfo); |
95 | 154 #endif |
155 #ifdef _XS_SIDPLAY2_H | |
100 | 156 testTune->getInfo(tuneInfo); |
95 | 157 haveInfo = TRUE; |
158 #endif | |
159 | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
160 /* Get length information (NOTE: Do not free this!) */ |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
161 tuneLen = xs_songlen_get(pcFilename); |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
162 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
163 /* Allocate tuneinfo structure */ |
106
98a72c44f56b
Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
164 pResult = xs_tune_new(pcFilename, tuneInfo.songs, tuneInfo.startSong, |
98a72c44f56b
Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
165 tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2]); |
98a72c44f56b
Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
166 |
98a72c44f56b
Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents:
100
diff
changeset
|
167 if (!pResult) |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
168 { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
169 delete testTune; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
170 return NULL; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
171 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
172 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
173 /* Get information for subtunes */ |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
174 for (i = 0; i < pResult->nsubTunes; i++) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
175 { |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
176 /* Make the title */ |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
177 if (haveInfo) |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
178 pResult->subTunes[i].tuneTitle = TFUNCTION1(pcFilename, &tuneInfo, i+1); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
179 else |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
180 pResult->subTunes[i].tuneTitle = g_strdup(pcFilename); |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
181 |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
182 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
183 /* Get song length */ |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
184 if (tuneLen && (i < tuneLen->nLengths)) |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
185 pResult->subTunes[i].tuneLength = tuneLen->sLengths[i]; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
186 else |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
187 pResult->subTunes[i].tuneLength = -1; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
188 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
189 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
190 delete testTune; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
191 |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
192 return pResult; |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
193 } |
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
76
diff
changeset
|
194 |
95 | 195 /* Undefine these */ |
196 #undef TFUNCTION1 | |
197 #undef TFUNCTION2 | |
198 #undef TTUNEINFO | |
199 #undef TTUNE |