#include <string.h>
#include <locale.h>
#include <errno.h>
+#include <sys/stat.h>
#include <getopt.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef _WIN32
+#include <io.h>
+#endif
#include "compat.h"
#include "wav_reader.h"
#include "aacenc.h"
static
int read_callback(void *cookie, void *data, uint32_t size)
{
- return fread(data, 1, size, (FILE*)cookie);
+ size_t rc = fread(data, 1, size, (FILE*)cookie);
+ return ferror((FILE*)cookie) ? -1 : (int)rc;
}
static
int write_callback(void *cookie, const void *data, uint32_t size)
{
- return fwrite(data, 1, size, (FILE*)cookie);
+ size_t rc = fwrite(data, 1, size, (FILE*)cookie);
+ return ferror((FILE*)cookie) ? -1 : (int)rc;
}
static
" parameter settings, sample rate, and\n"
" channel configuration)\n"
" -w, --bandwidth <n> Frequency bandwidth in Hz (AAC LC only)\n"
-" -a, --afterurner <n> Afterburner\n"
+" -a, --afterburner <n> Afterburner\n"
" 0: Off\n"
" 1: On(default)\n"
" -L, --lowdelay-sbr Enable ELD-SBR (AAC ELD only)\n"
{ "help", no_argument, 0, 'h' },
{ "profile", required_argument, 0, 'p' },
{ "bitrate", required_argument, 0, 'b' },
- { "biterate-mode", required_argument, 0, 'm' },
+ { "bitrate-mode", required_argument, 0, 'm' },
{ "bandwidth", required_argument, 0, 'w' },
{ "afterburner", required_argument, 0, 'a' },
{ "lowdelay-sbr", no_argument, 0, 'L' },
const void *data, uint32_t size, uint32_t duration)
{
if (!m4af) {
- if (fwrite(data, 1, size, ofp) < 0) {
+ fwrite(data, 1, size, ofp);
+ if (ferror(ofp)) {
fprintf(stderr, "ERROR: fwrite(): %s\n", strerror(errno));
return -1;
}
const pcm_sample_description_t *sample_format;
int downsampled_timescale = 0;
int frame_count = 0;
+ struct stat stb = { 0 };
setlocale(LC_CTYPE, "");
setbuf(stderr, 0);
goto END;
}
- if (ifp == stdin)
+ if (fstat(fileno(ifp), &stb) == 0 && (stb.st_mode & S_IFMT) != S_IFREG)
wav_io.seek = 0;
if ((wavf = wav_open(&wav_io, ifp, params.ignore_length)) == 0) {