When stderr (flac) or stdout (metaflac) is redirected to a file,
output of non-ASCII characters fails. This commit should fix that.
Fixes https://github.com/xiph/flac/issues/713
NOTE: To enable this change, metaflac no longer outputs
application block data as binary directly, because that would
potentially result in incorrect UTF-8 codepoint. Instead, all
bytes that cannot be represented as printable ASCII are
replaced with the Unicode replacement character
`which` is an external command which isn't required by POSIX.
Debian and other distributions (like Gentoo!) are looking
to drop it from their base set of packages.
Switch to `command -v` which is, however, POSIX. See https://lwn.net/Articles/874049/.
Commit d4daa86167 ("Check for bps% 8 != 0 if no streaminfo is present")
breaks fallback to frame header bps as it tests decoder_session->bps at
a point where it is guaranteed to be 0 as this is the else case of the
if(decoder_session->bps) block.
Some corrupted FLAC files that used to play before the above mentioned
commit no longer can be played.
Move decoder_session->bps = bps to before the decoder_session->bps
validation to restore functionality more similar to before.
It can be linked in the NDK so check_function_exists detects it. But it's only supporting _FILE_OFFSET_BITS=64
since Android API 24 [1].
With NDK 26 it's no longer possible to build assuming the API is always available.
[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md
In case of encoder failure within a thread, asserts were false
and a locked mutex would be destroyed. This fix leaves in a race
condition: encoder->protected_->state is written without a lock.
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62650
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
src/flac/foreign_metadata.c:803:33: warning: allocation of insufficient size ‘1’ for type ‘foreign_metadata_t’ with size ‘64’ [-Walloc-size]
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(foreign_metadata_t)`. GCC then sees we're not
doing anything wrong.
Signed-off-by: Sam James <sam@gentoo.org>
process_frame_thread_ should return NULL instead of false,
in C23 NULL and _Bool are not compatible and the code is rightfully
rejected by the compiler.
"stream_encoder.c:3595:48: error: incompatible types when returning type
‘_Bool’ but ‘void *’ was expected"