comparison src/xs_sidplayfp.cpp @ 954:a5b118c853f5

Use xs_fread_str() and improve the probing of each backend to be more specific about what is accepted for the said backend.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 20 Nov 2012 21:27:26 +0200
parents 8f1027a6b4a0
children 0e60e5d56fdd
comparison
equal deleted inserted replaced
953:b2caef664524 954:a5b118c853f5
114 114
115 /* Check if we can play the given file 115 /* Check if we can play the given file
116 */ 116 */
117 gboolean xs_sidplayfp_probe(XSFile *f) 117 gboolean xs_sidplayfp_probe(XSFile *f)
118 { 118 {
119 gchar tmpBuf[5]; 119 gchar probe[16];
120 120
121 if (!f) return FALSE; 121 if (f == NULL || !xs_fread_str(f, (guint8 *) probe, sizeof(probe)))
122 122 return FALSE;
123 if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) 123
124 return FALSE; 124 // Basically support all variants ..
125 125 if (!strncmp(probe, "PSID", 4) && probe[4] == 0 &&
126 if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) 126 probe[5] >= 1 && probe[5] <= 3)
127 return TRUE;
128 else
129 if (!strncmp(probe, "RSID", 4) &&
130 probe[4] == 0 && probe[5] >= 2 && probe[5] <= 3)
127 return TRUE; 131 return TRUE;
128 else 132 else
129 return FALSE; 133 return FALSE;
130 } 134 }
131 135