mirror of
https://github.com/nu774/fdkaac.git
synced 2025-01-30 07:15:36 +01:00
update compat layer, mainly for MSVC14 issue
This commit is contained in:
parent
80b476bad9
commit
19a6b7f10c
@ -20,9 +20,18 @@
|
||||
|
||||
int64_t aacenc_timer(void);
|
||||
FILE *aacenc_fopen(const char *name, const char *mode);
|
||||
#ifdef _WIN32
|
||||
void aacenc_getmainargs(int *argc, char ***argv);
|
||||
#else
|
||||
#define aacenc_getmainargs(argc, argv) (void)0
|
||||
#endif
|
||||
char *aacenc_to_utf8(const char *s);
|
||||
#ifdef _WIN32
|
||||
int aacenc_fprintf(FILE *fp, const char *fmt, ...);
|
||||
#else
|
||||
#define aacenc_fprintf fprintf
|
||||
#endif
|
||||
const char *aacenc_basename(const char *path);
|
||||
int aacenc_seekable(FILE *fp);
|
||||
|
||||
#endif
|
||||
|
@ -32,20 +32,9 @@ FILE *aacenc_fopen(const char *name, const char *mode)
|
||||
return fp;
|
||||
}
|
||||
|
||||
void aacenc_getmainargs(int *argc, char ***argv)
|
||||
int aacenc_seekable(FILE *fp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int aacenc_fprintf(FILE *fp, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int cnt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
cnt = vfprintf(fp, fmt, ap);
|
||||
va_end(ap);
|
||||
return cnt;
|
||||
return fseek(fp, 0, SEEK_CUR) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -20,14 +20,7 @@
|
||||
#include "compat.h"
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int newmode;
|
||||
} _startupinfo;
|
||||
|
||||
extern
|
||||
int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, _startupinfo *);
|
||||
#include <shellapi.h>
|
||||
|
||||
int64_t aacenc_timer(void)
|
||||
{
|
||||
@ -41,6 +34,11 @@ int64_t aacenc_timer(void)
|
||||
return (int64_t)tv.time * 1000 + tv.millitm;
|
||||
}
|
||||
|
||||
int aacenc_seekable(FILE *fp)
|
||||
{
|
||||
return GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) == FILE_TYPE_DISK;
|
||||
}
|
||||
|
||||
static
|
||||
int codepage_decode_wchar(int codepage, const char *from, wchar_t **to)
|
||||
{
|
||||
@ -97,19 +95,14 @@ void aacenc_free_mainargs(void)
|
||||
|
||||
void aacenc_getmainargs(int *argc, char ***argv)
|
||||
{
|
||||
static int (*fp__wgetmainargs)(int *, wchar_t ***, wchar_t ***,
|
||||
int, _startupinfo *);
|
||||
int i;
|
||||
wchar_t **wargv, **envp;
|
||||
_startupinfo si = { 0 };
|
||||
HMODULE h = LoadLibraryA("msvcrt.dll");
|
||||
fp__wgetmainargs = (void *)GetProcAddress(h, "__wgetmainargs");
|
||||
(*fp__wgetmainargs)(argc, &wargv, &envp, 1, &si);
|
||||
FreeLibrary(h);
|
||||
int i;
|
||||
wchar_t **wargv;
|
||||
|
||||
*argv = malloc((*argc + 1) * sizeof(char*));
|
||||
wargv = CommandLineToArgvW(GetCommandLineW(), argc);
|
||||
*argv = malloc((*argc + 1) * sizeof(char*));
|
||||
for (i = 0; i < *argc; ++i)
|
||||
codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]);
|
||||
LocalFree(wargv);
|
||||
(*argv)[*argc] = 0;
|
||||
__aacenc_argv__ = *argv;
|
||||
atexit(aacenc_free_mainargs);
|
||||
|
@ -702,7 +702,6 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
{
|
||||
pcm_io_context_t io = { 0 };
|
||||
pcm_reader_t *reader = 0;
|
||||
struct stat stb = { 0 };
|
||||
|
||||
if ((params->input_fp = aacenc_fopen(params->input_filename, "rb")) == 0) {
|
||||
aacenc_fprintf(stderr, "ERROR: %s: %s\n", params->input_filename,
|
||||
@ -710,8 +709,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
goto FAIL;
|
||||
}
|
||||
io.cookie = params->input_fp;
|
||||
if (fstat(fileno(params->input_fp), &stb) == 0
|
||||
&& (stb.st_mode & S_IFMT) == S_IFREG)
|
||||
if (aacenc_seekable(params->input_fp))
|
||||
io.vtbl = &pcm_io_vtbl;
|
||||
else
|
||||
io.vtbl = &pcm_io_vtbl_noseek;
|
||||
|
Loading…
x
Reference in New Issue
Block a user