From 89d671ef147e2cf272ecd8813e59003485202681 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 21 Mar 2023 14:40:24 +0300 Subject: [PATCH] mpg123-1.31.3 --- NEWS | 14 ++++++++++ configure | 24 ++++++++--------- configure.ac | 6 ++--- mpg123.spec | 2 +- ports/cmake/src/libmpg123/CMakeLists.txt | 34 ++++++++++-------------- src/common.c | 19 +++++++------ src/compat/compat.c | 9 ++++--- src/compat/compat_dl.c | 4 ++- src/compat/wpathconv.h | 2 ++ src/control_generic.c | 4 +-- src/libmpg123/layer3.c | 11 +++++--- src/libout123/modules/win32.c | 18 +++++++++++-- src/libout123/modules/win32_wasapi.c | 2 +- src/libsyn123/resample.c | 33 ++++++++++++++--------- src/mpg123app.h | 2 +- src/net123_winhttp.c | 12 ++++++--- src/net123_wininet.c | 13 +++++---- src/out123.c | 6 +++-- src/term_win32.c | 3 +-- src/win32_net.c | 2 ++ 20 files changed, 136 insertions(+), 84 deletions(-) diff --git a/NEWS b/NEWS index 7b06027..c28d7e3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,17 @@ +1.31.3 +------ +- build: +-- Fix --disable-8bit. +-- Fall back to generic decoder if no yasm for MSVC (bug 346). +-- Fix some pedantic compiler warnings, avoid breaking libtool wrappers. +- mpg123: +-- Fix verbose position printout for new resampling outside libmpg123 (where + output rate differs from decoding rate). +- libsyn123: +-- Fix reconfiguration of resampler to avoid double free when reducing + decimator stages to zero (bug 350). Thanks to Youngseok Choi for reporting + this fuzzed issue. + 1.31.2 ------ - Fix build --with-network=internal only (configure logic error, bug 348). diff --git a/configure b/configure index c478f85..ba131b5 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for mpg123 1.31.2. +# Generated by GNU Autoconf 2.69 for mpg123 1.31.3. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='mpg123' PACKAGE_TARNAME='mpg123' -PACKAGE_VERSION='1.31.2' -PACKAGE_STRING='mpg123 1.31.2' +PACKAGE_VERSION='1.31.3' +PACKAGE_STRING='mpg123 1.31.3' PACKAGE_BUGREPORT='maintainer@mpg123.org' PACKAGE_URL='' @@ -1687,7 +1687,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures mpg123 1.31.2 to adapt to many kinds of systems. +\`configure' configures mpg123 1.31.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1758,7 +1758,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of mpg123 1.31.2:";; + short | recursive ) echo "Configuration of mpg123 1.31.3:";; esac cat <<\_ACEOF @@ -1999,7 +1999,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -mpg123 configure 1.31.2 +mpg123 configure 1.31.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2605,7 +2605,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by mpg123 $as_me 1.31.2, which was +It was created by mpg123 $as_me 1.31.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2961,7 +2961,7 @@ OUTAPI_VERSION=4 OUTLIB_PATCHLEVEL=7 SYNAPI_VERSION=1 -SYNLIB_PATCHLEVEL=4 +SYNLIB_PATCHLEVEL=5 LIBMPG123_VERSION=$API_VERSION:$LIB_PATCHLEVEL:$API_VERSION LIBOUT123_VERSION=$OUTAPI_VERSION:$OUTLIB_PATCHLEVEL:$OUTAPI_VERSION @@ -3564,7 +3564,7 @@ fi # Define the identity of the package. PACKAGE='mpg123' - VERSION='1.31.2' + VERSION='1.31.3' cat >>confdefs.h <<_ACEOF @@ -15069,7 +15069,7 @@ $as_echo "#define NO_8BIT 1" >>confdefs.h fi - if test "x$int16" = "xenabled"; then + if test "x$int8" = "xenabled"; then HAVE_SYNTH8_TRUE= HAVE_SYNTH8_FALSE='#' else @@ -20754,7 +20754,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by mpg123 $as_me 1.31.2, which was +This file was extended by mpg123 $as_me 1.31.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20820,7 +20820,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -mpg123 config.status 1.31.2 +mpg123 config.status 1.31.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 06c1e83..412b7cc 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ dnl 2.69 at least. AC_PREREQ([2.69]) dnl ############# Initialisation -AC_INIT([mpg123], [1.31.2], [maintainer@mpg123.org]) +AC_INIT([mpg123], [1.31.3], [maintainer@mpg123.org]) dnl Increment API_VERSION when the API gets changes (new functions). dnl libmpg123 @@ -22,7 +22,7 @@ OUTLIB_PATCHLEVEL=7 dnl libsyn123 SYNAPI_VERSION=1 -SYNLIB_PATCHLEVEL=4 +SYNLIB_PATCHLEVEL=5 dnl Since we want to be backwards compatible, both sides get set to API_VERSION. LIBMPG123_VERSION=$API_VERSION:$LIB_PATCHLEVEL:$API_VERSION @@ -900,7 +900,7 @@ if test "x$int8" = "xdisabled"; then AC_DEFINE(NO_8BIT, 1, [ Define to disable 8 bit integer output. ]) fi -AM_CONDITIONAL([HAVE_SYNTH8], [test "x$int16" = "xenabled"]) +AM_CONDITIONAL([HAVE_SYNTH8], [test "x$int8" = "xenabled"]) if test "x$int32" = "xdisabled"; then AC_DEFINE(NO_32BIT, 1, [ Define to disable 32 bit and 24 bit integer output. ]) diff --git a/mpg123.spec b/mpg123.spec index e227289..98cc9a0 100644 --- a/mpg123.spec +++ b/mpg123.spec @@ -3,7 +3,7 @@ # - devel packages for alsa, sdl, etc... to build the respective output modules. Summary: The fast console mpeg audio decoder/player. Name: mpg123 -Version: 1.31.2 +Version: 1.31.3 Release: 1 URL: http://www.mpg123.org/ License: GPL diff --git a/ports/cmake/src/libmpg123/CMakeLists.txt b/ports/cmake/src/libmpg123/CMakeLists.txt index 9f0f75a..86fc17c 100644 --- a/ports/cmake/src/libmpg123/CMakeLists.txt +++ b/ports/cmake/src/libmpg123/CMakeLists.txt @@ -71,6 +71,19 @@ add_library(${TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/$<$:lfs_wrap.c>" $) +if(MSVC) + if(MACHINE MATCHES "x86|amd64") + find_program(YASM_ASSEMBLER yasm) + if(NOT YASM_ASSEMBLER) + message(WARNING "Couldn't find yasm assembler for optimizded decoders. Please set YASM_ASSEMBLER variable") + set(MACHINE generic) + endif() + else() + message(WARNING "Need work to support non-x86 assembly optimizations with MSVC.") + set(MACHINE generic) + endif() +endif() + if(MACHINE STREQUAL "amd64") if(HAVE_FPU) set(PLATFORM_DEFINITIONS OPT_MULTI OPT_X86_64 OPT_AVX OPT_GENERIC OPT_GENERIC_DITHER) @@ -135,10 +148,6 @@ elseif(MACHINE STREQUAL "x86") "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct64_i386.c") endif() elseif(MACHINE STREQUAL "arm64") - if(MSVC) - set(PLATFORM_DEFINITIONS OPT_GENERIC) - message(WARNING "Cannot use platform-specific assembly sources on MSVC") - else() set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON64) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon64.S" @@ -160,13 +169,8 @@ elseif(MACHINE STREQUAL "arm64") target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c" "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/getcpuflags_arm.c") - endif() elseif(MACHINE STREQUAL "arm32") if(HAVE_FPU) - if(MSVC) - set(PLATFORM_DEFINITIONS OPT_GENERIC) - message(WARNING "Cannot use platform-specific assembly sources on MSVC") - else() set(PLATFORM_DEFINITIONS OPT_MULTI OPT_GENERIC OPT_GENERIC_DITHER OPT_NEON) set(PLATFORM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dct36_neon.S" @@ -191,12 +195,7 @@ elseif(MACHINE STREQUAL "arm32") target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES}) target_sources(${TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/dither.c") - endif() else() - if(MSVC) - set(PLATFORM_DEFINITIONS OPT_GENERIC) - message(WARNING "Cannot use platform-specific assembly sources on MSVC") - else() set(PLATFORM_DEFINITIONS OPT_ARM) if(ACCURATE_ROUNDING) set(PLATFORM_SOURCES @@ -206,7 +205,6 @@ elseif(MACHINE STREQUAL "arm32") "${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libmpg123/synth_arm.S") endif() target_sources(${TARGET} PRIVATE ${PLATFORM_SOURCES}) - endif() endif() elseif(MACHINE STREQUAL "generic") set(PLATFORM_DEFINITIONS OPT_GENERIC) @@ -222,11 +220,7 @@ target_compile_definitions(${TARGET} PRIVATE $<$:REAL_IS_FLOAT> $<$>:REAL_IS_FIXED>) -if(MSVC AND MACHINE MATCHES "x86|amd64") - find_program(YASM_ASSEMBLER yasm) - if(NOT YASM_ASSEMBLER) - message(FATAL_ERROR "Couldn't find yasm assembler. Please set YASM_ASSEMBLER variable") - endif() +if(MSVC AND MACHINE MATCHES "x86|amd64" AND YASM_ASSEMBLER) list(TRANSFORM PLATFORM_DEFINITIONS PREPEND /D) foreach(FILE ${PLATFORM_SOURCES}) get_filename_component(FILENAME ${FILE} NAME) diff --git a/src/common.c b/src/common.c index 0ba12ab..9a97742 100644 --- a/src/common.c +++ b/src/common.c @@ -171,14 +171,15 @@ void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar static int old_term_width = -1; size_t buffered; off_t decoded; - off_t elapsed; - off_t remain; - off_t length; + double elapsed; + double remain; + double length; off_t frame; off_t frames; off_t rframes; int spf; double basevol, realvol; + long inrate; long rate; int framesize; struct mpg123_frameinfo mi; @@ -186,7 +187,7 @@ void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar char *line = NULL; #ifndef __OS2__ -#ifndef WIN32 +#ifndef _WIN32 #ifndef GENERIC /* Only generate new stat line when stderr is ready... don't overfill... */ { @@ -204,11 +205,13 @@ void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar #endif #endif #endif + if(mpg123_getformat(fr, &inrate, NULL, NULL)) + return; if(out123_getformat(ao, &rate, NULL, NULL, &framesize)) return; buffered = out123_buffered(ao)/framesize; decoded = mpg123_tell(fr); - length = mpg123_length(fr); + length = (double)mpg123_length(fr)/inrate; frame = mpg123_tellframe(fr); frames = mpg123_framelength(fr); spf = mpg123_spf(fr); @@ -222,7 +225,7 @@ void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar Buffering makes the relationships between the numbers non-trivial. */ rframes = frames-frame; // May be negative, a countdown. Buffer only confuses in paused (looping) mode, though. - elapsed = decoded + offset*spf - (paused ? 0 : buffered); + elapsed = (double)(decoded + offset*spf)/inrate - (double)(paused ? 0 : buffered)/rate; remain = elapsed > 0 ? length - elapsed : length; if( MPG123_OK == mpg123_info(fr, &mi) && MPG123_OK == mpg123_getvolume(fr, &basevol, &realvol, NULL) ) @@ -263,8 +266,8 @@ void print_stat(mpg123_handle *fr, long offset, out123_handle *ao, int draw_bar ? malloc(linelen+1) /* Only malloc if it is a really long line. */ : linebuf; /* Small buffer on stack is enough. */ - tim[0] = (double)elapsed/rate; - tim[1] = (double)remain/rate; + tim[0] = elapsed; + tim[1] = remain; tim[2] = (double)buffered/rate; for(ti=0; ti<3; ++ti) { diff --git a/src/compat/compat.c b/src/compat/compat.c index dacc77b..494f60f 100644 --- a/src/compat/compat.c +++ b/src/compat/compat.c @@ -179,6 +179,10 @@ void compat_binmode(int fd, int enable) it late to some official APIs, that's still fine with us. */ +#ifdef WANT_WIN32_UNICODE +typedef HRESULT (__stdcall *PCA_ptr)( const wchar_t *, const wchar_t*, unsigned long, wchar_t **); +#endif + char* compat_catpath(const char *prefix, const char* path) { char *ret = NULL; @@ -193,8 +197,7 @@ char* compat_catpath(const char *prefix, const char* path) ThOr: I presume this hack is for supporting pre-8 Windows, as from Windows 8 on, this is documented in the API. */ - HRESULT (__stdcall *mypac)( const wchar_t *in, const wchar_t* more - , unsigned long flags, wchar_t **out ) = NULL; + PCA_ptr mypac = NULL; HMODULE pathcch = NULL; if(!prefix && !path) @@ -207,7 +210,7 @@ char* compat_catpath(const char *prefix, const char* path) /* Again: I presume this whole fun is to get at PathAllocCombine even when pathcch.h is not available (like in MinGW32). */ if( (pathcch = GetModuleHandleA("kernelbase")) ) - mypac = (void *)GetProcAddress(pathcch, "PathAllocCombine"); + mypac = (PCA_ptr) GetProcAddress(pathcch, "PathAllocCombine"); if(mypac) /* PATHCCH_ALLOW_LONG_PATH = 1 per API docs */ { debug("Actually calling PathAllocCombine!"); diff --git a/src/compat/compat_dl.c b/src/compat/compat_dl.c index 8329036..a6cbff6 100644 --- a/src/compat/compat_dl.c +++ b/src/compat/compat_dl.c @@ -12,6 +12,8 @@ #include "config.h" /* This source file does need _POSIX_SOURCE to get some sigaction. */ #define _POSIX_SOURCE +/* Fix pedantic error about w2upath being unused */ +#define HIDE_w2upath #include "compat.h" #ifdef _MSC_VER @@ -87,7 +89,7 @@ void *compat_dlsym(void *handle, const char *name) if(!handle) return NULL; #ifdef WANT_WIN32_UNICODE - sym = GetProcAddress(handle, name); + sym = (void *)(uintptr_t)GetProcAddress(handle, name); #else sym = dlsym(handle, name); #endif diff --git a/src/compat/wpathconv.h b/src/compat/wpathconv.h index 78b4294..7ee5dff 100644 --- a/src/compat/wpathconv.h +++ b/src/compat/wpathconv.h @@ -26,6 +26,7 @@ static wchar_t* u2wpath(const char *upath) return wpath; } +#ifndef HIDE_w2upath /* Convert Windows wide character paths to unix UTF-8. */ static char* w2upath(const wchar_t *wpath) { @@ -37,6 +38,7 @@ static char* w2upath(const wchar_t *wpath) *p = '/'; return upath; } +#endif /* An absolute path that is too long and not already marked with \\?\ can be marked as a long one and still work. */ diff --git a/src/control_generic.c b/src/control_generic.c index 1eb2dd3..7eda574 100644 --- a/src/control_generic.c +++ b/src/control_generic.c @@ -26,7 +26,7 @@ #include "out123.h" #include #include -#if !defined (WIN32) || defined (__CYGWIN__) +#if !defined (_WIN32) || defined (__CYGWIN__) #include #include #endif @@ -397,7 +397,7 @@ int control_generic (mpg123_handle *fr) outstream = stdout; out_is_term = stdout_is_term; } -#ifndef WIN32 +#ifndef _WIN32 setlinebuf(outstream); #else /* perhaps just use setvbuf as it's C89 */ /* diff --git a/src/libmpg123/layer3.c b/src/libmpg123/layer3.c index a25ef09..58205f4 100644 --- a/src/libmpg123/layer3.c +++ b/src/libmpg123/layer3.c @@ -499,7 +499,10 @@ static unsigned char pretab_choice[2][22] = static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],int *scf, struct gr_info_s *gr_info,int sfreq,int part2bits) { int shift = 1 + gr_info->scalefac_scale; - real *xrpnt = (real *) xr; + // Pointer cast to make pedantic compilers happy. + real *xrpnt = (real*)xr; + // Some compiler freaks out over &xr[SBLIMIT][0], which is the same. + real *xrpntlimit = (real*)xr+SBLIMIT*SSLIMIT; int l[3],l3; int part2remain = gr_info->part2_3_length - part2bits; const short *me; @@ -552,10 +555,10 @@ static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],in } } -#define CHECK_XRPNT if(xrpnt >= &xr[SBLIMIT][0]) \ +#define CHECK_XRPNT if(xrpnt >= xrpntlimit) \ { \ if(NOQUIET) \ - error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) &xr[SBLIMIT][0]); \ + error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) xrpntlimit); \ return 1; \ } @@ -992,7 +995,7 @@ static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT],in gr_info->maxb = 1; } - while(xrpnt < &xr[SBLIMIT][0]) + while(xrpnt < xrpntlimit) *xrpnt++ = DOUBLE_TO_REAL(0.0); while( part2remain > 16 ) diff --git a/src/libout123/modules/win32.c b/src/libout123/modules/win32.c index 29c8a59..eea00ef 100644 --- a/src/libout123/modules/win32.c +++ b/src/libout123/modules/win32.c @@ -169,11 +169,10 @@ static void wait_for_buffer(WAVEHDR* hdr, HANDLE hEvent) static int get_formats_win32(out123_handle *ao) { WAVEOUTCAPSA caps; - MMRESULT mr; int ret = 0; UINT dev_id = dev_select(ao); - mr = waveOutGetDevCaps(dev_id, &caps, sizeof(caps)); + MMRESULT mr = waveOutGetDevCaps(dev_id, &caps, sizeof(caps)); if(mr != MMSYSERR_NOERROR) return 0; /* no formats? */ @@ -369,6 +368,21 @@ static int enumerate_win32( out123_handle *ao, int (*store_device)(void *devlist memset(id, 0, sizeof(id)); memset(&caps, 0, sizeof(caps)); mr = waveOutGetDevCaps(i, &caps, sizeof(caps)); + if (mr != MMSYSERR_NOERROR) { + switch(mr) { + case MMSYSERR_BADDEVICEID: + error("enumerate_win32: Specified device identifier is out of range."); + break; + case MMSYSERR_NODRIVER: + error("enumerate_win32: No device driver is present."); + break; + case MMSYSERR_NOMEM: + error("enumerate_win32: Unable to allocate or lock memory."); + break; + default: + merror("enumerate_win32: Uknown error 0x%x.", mr); + } + } mdebug("waveOutGetDevCaps mr %x", mr); snprintf(id, sizeof(id) - 1, "%u", i); store_device(devlist, id, caps.szPname); diff --git a/src/libout123/modules/win32_wasapi.c b/src/libout123/modules/win32_wasapi.c index 9764689..c7b567e 100644 --- a/src/libout123/modules/win32_wasapi.c +++ b/src/libout123/modules/win32_wasapi.c @@ -518,7 +518,6 @@ static int close_win32(out123_handle *ao) static int enumerate_win32( out123_handle *ao, int (*store_device)(void *devlist , const char *name, const char *description), void *devlist ) { - int len; char *pszID = NULL, *pszDesc = NULL; HRESULT hr = S_OK; UINT pcDevices = 0, i = 0; @@ -614,6 +613,7 @@ static int init_win32(out123_handle* ao){ ao->close = close_win32; ao->userptr = NULL; ao->enumerate = enumerate_win32; + ao->deinit = deinit_win32; /* Success */ return 0; diff --git a/src/libsyn123/resample.c b/src/libsyn123/resample.c index 3552ffa..991f610 100644 --- a/src/libsyn123/resample.c +++ b/src/libsyn123/resample.c @@ -2377,24 +2377,31 @@ syn123_setup_resample( syn123_handle *sh, long inrate, long outrate } rd->stage_history = sth; } - struct decimator_state *nd = safe_realloc( rd->decim - , sizeof(*rd->decim)*decim_stages ); - struct lpf4_hist *ndh = safe_realloc( rd->decim_hist - , sizeof(*rd->decim_hist)*decim_stages*channels ); - if(nd) - rd->decim = nd; - if(ndh) - rd->decim_hist = ndh; - if(!nd || !ndh) + if(decim_stages) { - perror("cannot allocate decimator state"); - err = SYN123_DOOM; - goto setup_resample_cleanup; + struct decimator_state *nd = safe_realloc( rd->decim + , sizeof(*rd->decim)*decim_stages ); + struct lpf4_hist *ndh = safe_realloc( rd->decim_hist + , sizeof(*rd->decim_hist)*decim_stages*channels ); + if(nd) + rd->decim = nd; + if(ndh) + rd->decim_hist = ndh; + if(!nd || !ndh) + { + perror("cannot allocate decimator state"); + err = SYN123_DOOM; + goto setup_resample_cleanup; + } + } else + { + free(rd->decim); rd->decim = NULL; + free(rd->decim_hist); rd->decim_hist = NULL; } // Link up the common memory blocks after each realloc. for(unsigned int dc=0; dcdecim[dc].ch = ndh+dc*channels; + rd->decim[dc].ch = rd->decim_hist+dc*channels; rd->decim[dc].out_hist = rd->stage_history ? rd->stage_history+(dc+1)*STAGE_HISTORY*channels : NULL; diff --git a/src/mpg123app.h b/src/mpg123app.h index 4d3be29..fef7361 100644 --- a/src/mpg123app.h +++ b/src/mpg123app.h @@ -18,7 +18,7 @@ /* import DLL symbols on windows */ #include "httpget.h" -#if WIN32 +#if _WIN32 #include "win32_support.h" #endif diff --git a/src/net123_winhttp.c b/src/net123_winhttp.c index 4d1562b..17ec7ce 100644 --- a/src/net123_winhttp.c +++ b/src/net123_winhttp.c @@ -53,6 +53,7 @@ static DWORD wrap_auth(winhttp_handle *nh){ ret = WinHttpSetCredentials(nh->request, WINHTTP_AUTH_TARGET_SERVER, mode, nh->comps.lpszUserName, nh->comps.lpszPassword, NULL); return GetLastError(); } + return TRUE; } #if DEBUG @@ -95,6 +96,7 @@ net123_handle *net123_open_winhttp(const char *url, const char * const *client_h DWORD headerlen; const LPCWSTR useragent = MPG123WSTR(PACKAGE_NAME) L"/" MPG123WSTR(PACKAGE_VERSION); WINHTTP_STATUS_CALLBACK cb; + net123_handle *handle = NULL; if(!WinHttpCheckPlatform()) return NULL; @@ -105,7 +107,7 @@ net123_handle *net123_open_winhttp(const char *url, const char * const *client_h winhttp_handle *ret = calloc(1, sizeof(winhttp_handle)); if (!ret) goto cleanup; - net123_handle *handle = calloc(1, sizeof(net123_handle)); + handle = calloc(1, sizeof(net123_handle)); if (!handle) { free(ret); goto cleanup; @@ -178,7 +180,7 @@ net123_handle *net123_open_winhttp(const char *url, const char * const *client_h if (!res) { res = GetLastError(); - error1("WinHttpSendRequest failed with %lu", res); + error1("WinHttpSendRequest failed with %d", res); if(res == ERROR_WINHTTP_SECURE_FAILURE){ res = *(DWORD *)ret->additionalInfo; error("Additionally, the ERROR_WINHTTP_SECURE_FAILURE failed with:"); @@ -221,8 +223,10 @@ net123_handle *net123_open_winhttp(const char *url, const char * const *client_h cleanup: debug("net123_open error"); if (urlW) free(urlW); - net123_close(handle); - handle = NULL; + if (handle) { + net123_close(handle); + handle = NULL; + } return handle; } diff --git a/src/net123_wininet.c b/src/net123_wininet.c index 520c099..6cf6e50 100644 --- a/src/net123_wininet.c +++ b/src/net123_wininet.c @@ -73,13 +73,14 @@ net123_handle *net123_open_wininet(const char *url, const char * const *client_h size_t ii; WINBOOL res; DWORD headerlen; + net123_handle *ret = NULL; const LPCWSTR useragent = MPG123WSTR(PACKAGE_NAME) L"/" MPG123WSTR(PACKAGE_VERSION); INTERNET_STATUS_CALLBACK cb; win32_utf8_wide(url, &urlW, NULL); if(urlW == NULL) goto cleanup; - net123_handle *ret = calloc(1, sizeof(net123_handle)); + ret = calloc(1, sizeof(net123_handle)); wininet_handle *wh = calloc(1, sizeof(wininet_handle)); if(!ret || !wh) { @@ -158,7 +159,7 @@ net123_handle *net123_open_wininet(const char *url, const char * const *client_h if (!res) { res = GetLastError(); - error1("HttpSendRequestW failed with %lu", res); + error1("HttpSendRequestW failed with %d", res); goto cleanup; } debug("HttpSendRequestW OK"); @@ -196,8 +197,10 @@ net123_handle *net123_open_wininet(const char *url, const char * const *client_h cleanup: debug("net123_open error"); if (urlW) free(urlW); - net123_close(ret); - ret = NULL; + if(ret) { + net123_close(ret); + ret = NULL; + } return ret; } @@ -219,7 +222,7 @@ static size_t net123_read(net123_handle *nh, void *buf, size_t bufsize){ /* is this needed? */ to_copy = bufsize > ULONG_MAX ? ULONG_MAX : bufsize; if(!InternetReadFile(wh->request, buf, to_copy, &bytesread)){ - error1("InternetReadFile exited with %d", GetLastError()); + error1("InternetReadFile exited with %ld", GetLastError()); return EOF; } return bytesread; diff --git a/src/out123.c b/src/out123.c index cde049f..91d5878 100644 --- a/src/out123.c +++ b/src/out123.c @@ -30,10 +30,10 @@ #include "config.h" #include "compat.h" #include -#if WIN32 +#if _WIN32 #include "win32_support.h" #endif -#if defined(WIN32) && defined(DYNAMIC_BUILD) +#if defined(_WIN32) && defined(DYNAMIC_BUILD) #define LINK_MPG123_DLL #endif #include "out123.h" @@ -108,7 +108,9 @@ static int realtime = FALSE; #ifdef HAVE_WINDOWS_H static int w32_priority = 0; #endif +#ifdef HAVE_SETPRIORITY static int aggressive = FALSE; +#endif static double preload = 0.2; static long outflags = 0; double preamp = 0.; diff --git a/src/term_win32.c b/src/term_win32.c index aad82d6..88faa22 100644 --- a/src/term_win32.c +++ b/src/term_win32.c @@ -29,7 +29,7 @@ static HANDLE consoleintput = INVALID_HANDLE_VALUE; static HANDLE consoleoutput = INVALID_HANDLE_VALUE; static HANDLE getconsoleintput(void){ - DWORD mode, r; + DWORD mode; if(consoleintput == INVALID_HANDLE_VALUE){ consoleintput = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(consoleintput == INVALID_HANDLE_VALUE || consoleintput == NULL) @@ -55,7 +55,6 @@ int term_have_fun(int fd, int want_visuals) return 0; } -static DWORD lastmode; int term_setup(void) { return 0; diff --git a/src/win32_net.c b/src/win32_net.c index e43ddd4..1689213 100755 --- a/src/win32_net.c +++ b/src/win32_net.c @@ -99,6 +99,7 @@ ssize_t win32_net_read (int fildes, void *buf, size_t nbyte) return ret; } +/* static int get_sock_ch (int sock) { char c; @@ -108,6 +109,7 @@ static int get_sock_ch (int sock) return (((int) c)&0xff); return -1; } +*/ ssize_t win32_net_write (int fildes, const void *buf, size_t nbyte) {