Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

FS#11933: Check for external album art if embedded album art fails to load.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29319 a1c6a512-1295-4272-9138-f99709370657

+56 -49
+56 -49
apps/playback.c
··· 1264 1264 return true; 1265 1265 } 1266 1266 1267 + #ifdef HAVE_ALBUMART 1268 + /* Load any album art for the file */ 1269 + static void audio_load_albumart(struct mp3entry *track_id3) 1270 + { 1271 + int i; 1272 + 1273 + FOREACH_ALBUMART(i) 1274 + { 1275 + struct bufopen_bitmap_data user_data; 1276 + int hid = ERR_HANDLE_NOT_FOUND; 1277 + 1278 + /* albumart_slots may change during a yield of bufopen, 1279 + * but that's no problem */ 1280 + if (tracks[track_widx].aa_hid[i] >= 0 || !albumart_slots[i].used) 1281 + continue; 1282 + 1283 + memset(&user_data, 0, sizeof(user_data)); 1284 + user_data.dim = &(albumart_slots[i].dim); 1285 + 1286 + /* we can only decode jpeg for embedded AA */ 1287 + if (track_id3->embed_albumart && track_id3->albumart.type == AA_TYPE_JPG) 1288 + { 1289 + user_data.embedded_albumart = &(track_id3->albumart); 1290 + hid = bufopen(track_id3->path, 0, TYPE_BITMAP, &user_data); 1291 + } 1292 + 1293 + if (hid < 0 && hid != ERR_BUFFER_FULL) 1294 + { 1295 + /* no embedded AA or it couldn't be loaded, try other sources */ 1296 + char path[MAX_PATH]; 1297 + 1298 + if (find_albumart(track_id3, path, sizeof(path), 1299 + &(albumart_slots[i].dim))) 1300 + { 1301 + user_data.embedded_albumart = NULL; 1302 + hid = bufopen(path, 0, TYPE_BITMAP, &user_data); 1303 + } 1304 + } 1305 + 1306 + if (hid == ERR_BUFFER_FULL) 1307 + { 1308 + filling = STATE_FULL; 1309 + logf("buffer is full for now (get album art)"); 1310 + } 1311 + else if (hid < 0) 1312 + { 1313 + logf("Album art loading failed"); 1314 + } 1315 + 1316 + tracks[track_widx].aa_hid[i] = hid; 1317 + } 1318 + } 1319 + #endif 1320 + 1267 1321 /* Second part of the track loading: We now have the metadata available, so we 1268 1322 can load the codec, the album art and finally the audio data. 1269 1323 This is called on the audio thread after the buffering thread calls the ··· 1327 1381 } 1328 1382 } 1329 1383 } 1330 - #ifdef HAVE_ALBUMART 1331 - { 1332 - int i; 1333 - char aa_path[MAX_PATH]; 1334 1384 1335 - FOREACH_ALBUMART(i) 1336 - { 1337 - /* albumart_slots may change during a yield of bufopen, 1338 - * but that's no problem */ 1339 - if (tracks[track_widx].aa_hid[i] >= 0 || !albumart_slots[i].used) 1340 - continue; 1341 - 1342 - /* we can only decode jpeg for embedded AA */ 1343 - bool embedded_albumart = 1344 - track_id3->embed_albumart && track_id3->albumart.type == AA_TYPE_JPG; 1345 - /* find_albumart will error out if the wps doesn't have AA */ 1346 - if (embedded_albumart || find_albumart(track_id3, aa_path, 1347 - sizeof(aa_path), &(albumart_slots[i].dim))) 1348 - { 1349 - int aa_hid; 1350 - struct bufopen_bitmap_data user_data = { 1351 - .dim = &(albumart_slots[i].dim), 1352 - .embedded_albumart = NULL, 1353 - }; 1354 - if (embedded_albumart) 1355 - { 1356 - user_data.embedded_albumart = &(track_id3->albumart); 1357 - aa_hid = bufopen(track_id3->path, 0, 1358 - TYPE_BITMAP, &user_data); 1359 - } 1360 - else 1361 - { 1362 - aa_hid = bufopen(aa_path, 0, TYPE_BITMAP, 1363 - &user_data); 1364 - } 1365 - if(aa_hid == ERR_BUFFER_FULL) 1366 - { 1367 - filling = STATE_FULL; 1368 - logf("buffer is full for now (get album art)"); 1369 - return; /* No space for track's album art, not an error */ 1370 - } 1371 - else if (aa_hid < 0) 1372 - { 1373 - /* another error, ignore AlbumArt */ 1374 - logf("Album art loading failed"); 1375 - } 1376 - tracks[track_widx].aa_hid[i] = aa_hid; 1377 - } 1378 - } 1379 - } 1385 + #ifdef HAVE_ALBUMART 1386 + audio_load_albumart(track_id3); 1380 1387 #endif 1381 1388 1382 1389 /* Load the codec. */