diff --git a/src/streamfile.c b/src/streamfile.c index 3be09719..6ce0626a 100644 --- a/src/streamfile.c +++ b/src/streamfile.c @@ -77,7 +77,8 @@ static size_t read_stdio(STDIO_STREAMFILE *streamfile, uint8_t *dst, off_t offse /* Workaround a bug that appears when compiling with MSVC (later versions). * This bug is deterministic and seemingly appears randomly after seeking. * It results in fread returning data from the wrong area of the file. - * HPS is one format that is almost always affected by this. */ + * HPS is one format that is almost always affected by this. + * May be related/same as open_stdio's bug when using dup() */ fseek(streamfile->infile, ftell(streamfile->infile), SEEK_SET); #endif @@ -132,7 +133,12 @@ static STREAMFILE* open_stdio(STDIO_STREAMFILE *streamfile, const char * const f if (!filename) return NULL; -#if !defined (__ANDROID__) +#if !defined (__ANDROID__) && !defined (_MSC_VER) + /* when enabling this for MSVC it'll seemingly work, but there are issues possibly related to underlying + * IO buffers when using dup(), noticeable by re-opening the same streamfile with small buffer sizes + * (reads garbage). fseek bug in line 81 may be related/same thing and may be removed. + * this reportedly this causes issues in Android too */ + /* if same name, duplicate the file descriptor we already have open */ if (streamfile->infile && !strcmp(streamfile->name,filename)) { int new_fd;