mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-24 03:49:14 -05:00
Fix duration scanning for wav files
This commit is contained in:
parent
14626a0174
commit
34a4bb998e
@ -70,8 +70,8 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
uint32_t current_offset;
|
uint32_t current_offset;
|
||||||
uint32_t block_len;
|
uint32_t block_len;
|
||||||
|
|
||||||
int found_fmt = 0;
|
int found_fmt = FALSE;
|
||||||
int found_data = 0;
|
int found_data = FALSE;
|
||||||
|
|
||||||
DPRINTF(E_DBG,L_SCAN,"Getting WAV file info\n");
|
DPRINTF(E_DBG,L_SCAN,"Getting WAV file info\n");
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
/* now, walk through the chunks */
|
/* now, walk through the chunks */
|
||||||
current_offset = 12;
|
current_offset = 12;
|
||||||
|
|
||||||
while(!found_fmt && !found_data) {
|
while(!found_fmt || !found_data) {
|
||||||
len = 8;
|
len = 8;
|
||||||
if(!io_read(hfile,hdr,&len) || (len != 8)) {
|
if(!io_read(hfile,hdr,&len) || (len != 8)) {
|
||||||
io_close(hfile);
|
io_close(hfile);
|
||||||
@ -148,7 +148,7 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
compression_code = GET_WAV_INT16(fmt);
|
compression_code = GET_WAV_INT16(fmt);
|
||||||
channel_count = GET_WAV_INT16(fmt+2);
|
channel_count = GET_WAV_INT16(fmt+2);
|
||||||
sample_rate = GET_WAV_INT32(fmt + 4);
|
sample_rate = GET_WAV_INT32(fmt + 4);
|
||||||
sample_bit_length = GET_WAV_INT16(hdr + 14);
|
sample_bit_length = GET_WAV_INT16(fmt + 14);
|
||||||
DPRINTF(E_DBG,L_SCAN,"Compression code: %d\n",compression_code);
|
DPRINTF(E_DBG,L_SCAN,"Compression code: %d\n",compression_code);
|
||||||
DPRINTF(E_DBG,L_SCAN,"Channel count: %d\n",channel_count);
|
DPRINTF(E_DBG,L_SCAN,"Channel count: %d\n",channel_count);
|
||||||
DPRINTF(E_DBG,L_SCAN,"Sample Rate: %d\n",sample_rate);
|
DPRINTF(E_DBG,L_SCAN,"Sample Rate: %d\n",sample_rate);
|
||||||
@ -175,6 +175,11 @@ int scan_get_wavinfo(char *filename, MP3FILE *pmp3) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bit_rate = sample_rate * channel_count * ((sample_bit_length + 7) / 8) * 8;
|
bit_rate = sample_rate * channel_count * ((sample_bit_length + 7) / 8) * 8;
|
||||||
|
if(!bit_rate) {
|
||||||
|
DPRINTF(E_WARN,L_SCAN,"Couldn't get bitrate\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
pmp3->bitrate = bit_rate / 1000;
|
pmp3->bitrate = bit_rate / 1000;
|
||||||
pmp3->samplerate = sample_rate;
|
pmp3->samplerate = sample_rate;
|
||||||
sec = data_length / (bit_rate / 8);
|
sec = data_length / (bit_rate / 8);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user