nxplayer: add support which mp3 file which has no ID3 header

Signed-off-by: qiaohaijiao1 <qiaohaijiao1@xiaomi.com>
This commit is contained in:
qiaohaijiao1 2023-01-31 11:36:02 +08:00 committed by Xiang Xiao
parent 93b4dc2692
commit e949e207e0
2 changed files with 23 additions and 7 deletions

View File

@ -520,10 +520,19 @@ int nxplayer_getmidisubformat(int fd)
}
#endif
/****************************************************************************
* Name: nxplayer_getmp3subformat
*
* nxplayer_getmp3subformat() just return AUDIO_SUBFMT_PCM_MP3
*
****************************************************************************/
#ifdef CONFIG_AUDIO_FORMAT_MP3
int nxplayer_getmp3subformat(int fd)
{
return AUDIO_SUBFMT_PCM_MP3;
}
#endif
/****************************************************************************
* Name: nxplayer_fmtfromextension

View File

@ -235,15 +235,22 @@ int nxplayer_parse_mp3(int fd, FAR uint32_t *samplerate,
return -ENODATA;
}
position = (buffer[6] & ID3V2_BIT_MASK) * 0x200000 +
(buffer[7] & ID3V2_BIT_MASK) * 0x4000 +
(buffer[8] & ID3V2_BIT_MASK) * 0x80 +
(buffer[9] & ID3V2_BIT_MASK) +
sizeof(buffer);
if (!memcmp(buffer, "ID3", 3))
{
position = (buffer[6] & ID3V2_BIT_MASK) * 0x200000 +
(buffer[7] & ID3V2_BIT_MASK) * 0x4000 +
(buffer[8] & ID3V2_BIT_MASK) * 0x80 +
(buffer[9] & ID3V2_BIT_MASK) +
sizeof(buffer);
lseek(fd, position, SEEK_SET);
lseek(fd, position, SEEK_SET);
read(fd, buffer, 4);
}
else
{
position = 0;
}
read(fd, buffer, 4);
mpa_header = buffer[0] << 24 |
buffer[1] << 16 |
buffer[2] << 8 |