Mercurial > hg > xmms-sid
comparison src/xs_sidplay2.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 | 3a9bf45178ff |
children | 0e60e5d56fdd |
comparison
equal
deleted
inserted
replaced
953:b2caef664524 | 954:a5b118c853f5 |
---|---|
77 | 77 |
78 /* Check if we can play the given file | 78 /* Check if we can play the given file |
79 */ | 79 */ |
80 gboolean xs_sidplay2_probe(XSFile *f) | 80 gboolean xs_sidplay2_probe(XSFile *f) |
81 { | 81 { |
82 gchar tmpBuf[5]; | 82 gchar probe[16]; |
83 | 83 |
84 if (!f) return FALSE; | 84 if (f == NULL || !xs_fread_str(f, (guint8 *) probe, sizeof(probe))) |
85 | 85 return FALSE; |
86 if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) | 86 |
87 return FALSE; | 87 // Old libSIDPlay2 does not support PSIDv3, afaik |
88 | 88 if (!strncmp(probe, "PSID", 4) && probe[4] == 0 && |
89 if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) | 89 probe[5] >= 1 && probe[5] <= 2) |
90 return TRUE; | |
91 else | |
92 if (!strncmp(probe, "RSID", 4) && | |
93 probe[4] == 0 && probe[5] == 2) | |
90 return TRUE; | 94 return TRUE; |
91 else | 95 else |
92 return FALSE; | 96 return FALSE; |
93 } | 97 } |
94 | 98 |