Преглед изворни кода

update:没有ID3头的MP3也能播放

alienwalker пре 3 година
родитељ
комит
c478b201f6
1 измењених фајлова са 14 додато и 7 уклоњено
  1. 14 7
      application/src/luat_audio_air105.c

+ 14 - 7
application/src/luat_audio_air105.c

@@ -269,16 +269,23 @@ int luat_audio_play_file(uint8_t multimedia_id, const char *path)
 		return -1;
 	}
 	luat_fs_fread(temp, 12, 1, fd);
-	if (!memcmp(temp, "ID3", 3))
+	if (!memcmp(temp, "ID3", 3) || (temp[0] == 0xff))
 	{
-		jump = 0;
-		for(i = 0; i < 4; i++)
+		if (temp[0] != 0xff)
 		{
-			jump <<= 7;
-			jump |= temp[6 + i] & 0x7f;
+			jump = 0;
+			for(i = 0; i < 4; i++)
+			{
+				jump <<= 7;
+				jump |= temp[6 + i] & 0x7f;
+			}
+	//		LLOGD("jump head %d", jump);
+			luat_fs_fseek(fd, jump, SEEK_SET);
+		}
+		else
+		{
+			luat_fs_fseek(fd, 0, SEEK_SET);
 		}
-//		LLOGD("jump head %d", jump);
-		luat_fs_fseek(fd, jump, SEEK_SET);
 		mp3_decoder = luat_heap_malloc(sizeof(mp3dec_t));
 		memset(mp3_decoder, 0, sizeof(mp3dec_t));
 		mp3dec_init(mp3_decoder);