AFSI_LYRICS_ID_OFFSET = 24,
/** Storage position of the .audio_format_id field. */
AFSI_AUDIO_FORMAT_ID_OFFSET = 28,
- /** 3 bytes reserved space for future usage. */
- AFSI_AUDIO_FORMAT_UNUSED_OFFSET = 29,
+ /** Storage position of the amplification field. */
+ AFSI_AMP_OFFSET = 29,
+ /** 2 bytes reserved space for future usage. */
+ AFSI_AUDIO_FORMAT_UNUSED_OFFSET = 30,
/** On-disk storage space needed. */
AFSI_SIZE = 32
};
write_u32(buf + AFSI_LYRICS_ID_OFFSET, afsi->lyrics_id);
write_u8(buf + AFSI_AUDIO_FORMAT_ID_OFFSET,
afsi->audio_format_id);
- memset(buf + AFSI_AUDIO_FORMAT_UNUSED_OFFSET, 0, 3);
+ write_u8(buf + AFSI_AMP_OFFSET, afsi->amp);
+ memset(buf + AFSI_AUDIO_FORMAT_UNUSED_OFFSET, 0, 2);
}
/**
afsi->lyrics_id = read_u32(buf + AFSI_LYRICS_ID_OFFSET);
afsi->audio_format_id = read_u8(buf +
AFSI_AUDIO_FORMAT_ID_OFFSET);
+ afsi->amp = read_u8(buf + AFSI_AMP_OFFSET);
return 1;
}
static int add_one_audio_file(const char *path, void *private_data)
{
- int ret, send_ret = 1;
+ int ret, send_ret = 1, fd;
uint8_t format_num = -1;
struct private_add_data *pad = private_data;
struct afh_info afhi, *afhi_ptr = NULL;
goto out_free;
}
/* We still want to add this file. Compute its hash. */
- ret = mmap_full_file(path, O_RDONLY, &map.data, &map.size, NULL);
+ ret = mmap_full_file(path, O_RDONLY, &map.data, &map.size, &fd);
if (ret < 0)
goto out_free;
hash_function(map.data, map.size, hash);
* there is a hash sister and FORCE was not given.
*/
if (!hs || (pad->flags & ADD_FLAG_FORCE)) {
- ret = compute_afhi(path, map.data, map.size, &afhi);
+ ret = compute_afhi(path, map.data, map.size, fd, &afhi);
if (ret < 0)
goto out_unmap;
format_num = ret;
goto out_free;
out_unmap:
+ close(fd);
munmap(map.data, map.size);
out_free:
if (ret < 0 && send_ret >= 0)