Fix VGMStream so it handles EOF properly

The file prober in FFmpeg expects that when the read function reaches
end of file, it returns AVERROR_EOF, not zero. Otherwise, it will loop
endlessly until the process is terminated.

Fixes #217.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-01-27 00:09:40 -08:00
parent 9edf4ddc49
commit b53567edc5
2 changed files with 2 additions and 10 deletions

View File

@ -218,7 +218,7 @@ static int ffmpeg_read(void* opaque, uint8_t* buf, int read_size) {
if (data->logical_offset + read_size > data->logical_size)
read_size = data->logical_size - data->logical_offset;
if (read_size == 0)
return bytes;
return AVERROR_EOF;
/* handle reads on inserted header */
if (data->header_size && data->logical_offset < data->header_size) {
@ -232,7 +232,7 @@ static int ffmpeg_read(void* opaque, uint8_t* buf, int read_size) {
data->logical_offset += max_to_copy;
if (read_size == 0) {
return max_to_copy; /* offset still in header */
return max_to_copy ? max_to_copy : AVERROR_EOF; /* offset still in header */
}
}

View File

@ -303,14 +303,6 @@ static STREAMFILE* open_cog_streamfile_buffer_from_url(NSURL* url, const char* c
if (![infile seekable])
return NULL;
// XXX Goddammit, FFmpeg
uint8_t sig[3];
if ([infile read:sig amount:3] == 3) {
[infile seek:0 whence:SEEK_SET];
if (memcmp(sig, "PSF", 3) == 0)
return NULL;
}
return open_cog_streamfile_buffer_by_file(infile, filename, bufsize);
}