mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-26 19:40:24 +00:00
Fix a bunch of minor issues found by John Pavel using the Intel compiler.
This commit is contained in:
parent
5ff27b2e3b
commit
0c7b227de0
@ -1,3 +1,12 @@
|
||||
2005-09-03 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/float32.c src/double64.c
|
||||
Replace floating point equality comparisons with greater/less comparisons.
|
||||
Found by John Pavel using the Intel compiler.
|
||||
|
||||
* src/*.(c|h) tests/*.(c|tpl) examples/*.c
|
||||
Fixed a bunch of other stuff found by John Pavel using the Intel compiler.
|
||||
|
||||
2005-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/w64.c
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#ifdef HAVE_ALSA_ASOUNDLIB_H
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.h>
|
||||
@ -63,7 +63,7 @@
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#ifdef HAVE_ALSA_ASOUNDLIB_H
|
||||
|
||||
static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ;
|
||||
static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ;
|
||||
@ -927,7 +927,7 @@ main (int argc, char *argv [])
|
||||
} ;
|
||||
|
||||
#if defined (__linux__)
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#ifdef HAVE_ALSA_ASOUNDLIB_H
|
||||
if (access ("/proc/asound/cards", R_OK) == 0)
|
||||
alsa_play (argc, argv) ;
|
||||
else
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "regtest.h"
|
||||
|
||||
#if HAVE_SQLITE3
|
||||
#ifdef HAVE_SQLITE3
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#if HAVE_SQLITE3
|
||||
#ifdef HAVE_SQLITE3
|
||||
|
||||
#include "regtest.h"
|
||||
|
||||
|
@ -145,12 +145,12 @@ enum
|
||||
{ basc_SCALE_MINOR = 1,
|
||||
basc_SCALE_MAJOR,
|
||||
basc_SCALE_NEITHER,
|
||||
basc_SCALE_BOTH,
|
||||
basc_SCALE_BOTH
|
||||
} ;
|
||||
|
||||
enum
|
||||
{ basc_TYPE_LOOP = 0,
|
||||
basc_TYPE_ONE_SHOT,
|
||||
basc_TYPE_ONE_SHOT
|
||||
} ;
|
||||
|
||||
|
||||
@ -326,7 +326,7 @@ static int
|
||||
aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
||||
{ SSND_CHUNK ssnd_fmt ;
|
||||
unsigned marker, dword, FORMsize, SSNDsize, bytesread ;
|
||||
int k, filetype, found_chunk = 0, done = 0, error = 0 ;
|
||||
int k, found_chunk = 0, done = 0, error = 0 ;
|
||||
char *cptr, byte ;
|
||||
|
||||
/* Set position to start of file to begin reading header. */
|
||||
@ -371,9 +371,8 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
||||
|
||||
case AIFC_MARKER :
|
||||
case AIFF_MARKER :
|
||||
if (! (found_chunk & HAVE_FORM))
|
||||
if ((found_chunk & HAVE_FORM) == 0)
|
||||
return SFE_AIFF_AIFF_NO_FORM ;
|
||||
filetype = marker ;
|
||||
psf_log_printf (psf, " %M\n", marker) ;
|
||||
found_chunk |= HAVE_AIFF ;
|
||||
break ;
|
||||
|
10
src/avr.c
10
src/avr.c
@ -78,8 +78,7 @@ static int avr_write_header (SF_PRIVATE *psf, int calc_length) ;
|
||||
|
||||
int
|
||||
avr_open (SF_PRIVATE *psf)
|
||||
{ int subformat ;
|
||||
int error = 0 ;
|
||||
{ int error = 0 ;
|
||||
|
||||
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
|
||||
{ if ((error = avr_read_header (psf)))
|
||||
@ -89,8 +88,6 @@ avr_open (SF_PRIVATE *psf)
|
||||
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AVR)
|
||||
return SFE_BAD_OPEN_FORMAT ;
|
||||
|
||||
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
{ psf->endian = psf->sf.format & SF_FORMAT_ENDMASK ;
|
||||
psf->endian = SF_ENDIAN_BIG ;
|
||||
@ -150,7 +147,6 @@ avr_read_header (SF_PRIVATE *psf)
|
||||
default :
|
||||
psf_log_printf (psf, "Error : bad rez/sign combination.\n") ;
|
||||
return SFE_AVR_X ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
psf_binheader_readf (psf, "E4444", &hdr.srate, &hdr.frames, &hdr.lbeg, &hdr.lend) ;
|
||||
@ -190,7 +186,7 @@ avr_read_header (SF_PRIVATE *psf)
|
||||
static int
|
||||
avr_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
{ sf_count_t current ;
|
||||
int sign, datalength ;
|
||||
int sign ;
|
||||
|
||||
if (psf->pipeoffset > 0)
|
||||
return 0 ;
|
||||
@ -218,8 +214,6 @@ avr_write_header (SF_PRIVATE *psf, int calc_length)
|
||||
if (psf->is_pipe == SF_FALSE)
|
||||
psf_fseek (psf, 0, SEEK_SET) ;
|
||||
|
||||
datalength = (int) (psf->datalength & 0x7FFFFFFF) ;
|
||||
|
||||
psf_binheader_writef (psf, "Emz22", TWOBIT_MARKER, (size_t) 8,
|
||||
psf->sf.channels == 2 ? 0xFFFF : 0, psf->bytewidth * 8) ;
|
||||
|
||||
|
@ -276,19 +276,20 @@ double64_init (SF_PRIVATE *psf)
|
||||
|
||||
double
|
||||
double64_be_read (unsigned char *cptr)
|
||||
{ int exponent, negative ;
|
||||
{ int exponent, negative, upper, lower ;
|
||||
double dvalue ;
|
||||
|
||||
negative = (cptr [0] & 0x80) ? 1 : 0 ;
|
||||
exponent = ((cptr [0] & 0x7F) << 4) | ((cptr [1] >> 4) & 0xF) ;
|
||||
|
||||
/* Might not have a 64 bit long, so load the mantissa into a double. */
|
||||
dvalue = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ;
|
||||
dvalue += ((cptr [5] << 16) | (cptr [6] << 8) | cptr [7]) / ((double) 0x1000000) ;
|
||||
upper = (((cptr [1] & 0xF) << 24) | (cptr [2] << 16) | (cptr [3] << 8) | cptr [4]) ;
|
||||
lower = (cptr [5] << 16) | (cptr [6] << 8) | cptr [7] ;
|
||||
|
||||
if (exponent == 0 && dvalue == 0.0)
|
||||
if (exponent == 0 && upper == 0 && lower == 0)
|
||||
return 0.0 ;
|
||||
|
||||
dvalue = upper + lower / ((double) 0x1000000) ;
|
||||
dvalue += 0x10000000 ;
|
||||
|
||||
exponent = exponent - 0x3FF ;
|
||||
@ -308,19 +309,20 @@ double64_be_read (unsigned char *cptr)
|
||||
|
||||
double
|
||||
double64_le_read (unsigned char *cptr)
|
||||
{ int exponent, negative ;
|
||||
{ int exponent, negative, upper, lower ;
|
||||
double dvalue ;
|
||||
|
||||
negative = (cptr [7] & 0x80) ? 1 : 0 ;
|
||||
exponent = ((cptr [7] & 0x7F) << 4) | ((cptr [6] >> 4) & 0xF) ;
|
||||
|
||||
/* Might not have a 64 bit long, so load the mantissa into a double. */
|
||||
dvalue = (((cptr [6] & 0xF) << 24) | (cptr [5] << 16) | (cptr [4] << 8) | cptr [3]) ;
|
||||
dvalue += ((cptr [2] << 16) | (cptr [1] << 8) | cptr [0]) / ((double) 0x1000000) ;
|
||||
upper = ((cptr [6] & 0xF) << 24) | (cptr [5] << 16) | (cptr [4] << 8) | cptr [3] ;
|
||||
lower = (cptr [2] << 16) | (cptr [1] << 8) | cptr [0] ;
|
||||
|
||||
if (exponent == 0 && dvalue == 0.0)
|
||||
if (exponent == 0 && upper == 0 && lower == 0)
|
||||
return 0.0 ;
|
||||
|
||||
dvalue = upper + lower / ((double) 0x1000000) ;
|
||||
dvalue += 0x10000000 ;
|
||||
|
||||
exponent = exponent - 0x3FF ;
|
||||
@ -344,7 +346,7 @@ double64_be_write (double in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (double)) ;
|
||||
|
||||
if (in == 0.0)
|
||||
if (fabs (in) < 1e-30)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -384,7 +386,7 @@ double64_le_write (double in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (double)) ;
|
||||
|
||||
if (in == 0.0)
|
||||
if (fabs (in) < 1e-30)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -306,7 +306,7 @@ float32_le_write (float in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (int)) ;
|
||||
|
||||
if (in == 0.0)
|
||||
if (fabs (in) < 1e-30)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
@ -341,7 +341,7 @@ float32_be_write (float in, unsigned char *out)
|
||||
|
||||
memset (out, 0, sizeof (int)) ;
|
||||
|
||||
if (in == 0.0)
|
||||
if (fabs (in) < 1e-30)
|
||||
return ;
|
||||
|
||||
if (in < 0.0)
|
||||
|
@ -45,6 +45,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_LRINT
|
||||
#define HAVE_LRINT 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LRINTF
|
||||
#define HAVE_LRINTF 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The presence of the required functions are detected during the configure
|
||||
** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
|
||||
|
@ -51,15 +51,13 @@ static int nist_read_header (SF_PRIVATE *psf) ;
|
||||
|
||||
int
|
||||
nist_open (SF_PRIVATE *psf)
|
||||
{ int subformat, error ;
|
||||
{ int error ;
|
||||
|
||||
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
|
||||
{ if ((error = nist_read_header (psf)))
|
||||
return error ;
|
||||
} ;
|
||||
|
||||
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
{ if (psf->is_pipe)
|
||||
return SFE_NO_PIPE_WRITE ;
|
||||
|
@ -102,7 +102,7 @@ static int sds_write (SF_PRIVATE *psf, SDS_PRIVATE *psds, const int *iptr, int w
|
||||
int
|
||||
sds_open (SF_PRIVATE *psf)
|
||||
{ SDS_PRIVATE *psds ;
|
||||
int subformat, error = 0 ;
|
||||
int error = 0 ;
|
||||
|
||||
/* Hmmmm, need this here to pass update_header_test. */
|
||||
psf->sf.frames = 0 ;
|
||||
@ -119,8 +119,6 @@ sds_open (SF_PRIVATE *psf)
|
||||
if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SDS)
|
||||
return SFE_BAD_OPEN_FORMAT ;
|
||||
|
||||
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
{ if (sds_write_header (psf, SF_FALSE))
|
||||
return psf->error ;
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
@ -34,7 +34,7 @@ typedef __int64 int64_t ;
|
||||
#error "No 64 bit integer type."
|
||||
#endif
|
||||
|
||||
#if HAVE_BYTESWAP_H
|
||||
#ifdef HAVE_BYTESWAP_H
|
||||
|
||||
#include <byteswap.h>
|
||||
|
||||
@ -43,6 +43,8 @@ typedef __int64 int64_t ;
|
||||
|
||||
#else
|
||||
|
||||
#define HAVE_BYTESWAP_H 0
|
||||
|
||||
#define ENDSWAP_SHORT(x) ((((x)>>8)&0xFF)+(((x)&0xFF)<<8))
|
||||
#define ENDSWAP_INT(x) ((((x)>>24)&0xFF)+(((x)>>8)&0xFF00)+(((x)&0xFF00)<<8)+(((x)&0xFF)<<24))
|
||||
|
||||
|
@ -80,7 +80,7 @@ static int svx_read_header (SF_PRIVATE *psf) ;
|
||||
|
||||
int
|
||||
svx_open (SF_PRIVATE *psf)
|
||||
{ int error, subformat ;
|
||||
{ int error ;
|
||||
|
||||
if (psf->mode == SFM_READ || (psf->mode == SFM_RDWR && psf->filelength > 0))
|
||||
{ if ((error = svx_read_header (psf)))
|
||||
@ -95,8 +95,6 @@ svx_open (SF_PRIVATE *psf)
|
||||
psf_fseek (psf, psf->dataoffset, SEEK_SET) ;
|
||||
} ;
|
||||
|
||||
subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
{ if (psf->is_pipe)
|
||||
return SFE_NO_PIPE_WRITE ;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
|
@ -97,7 +97,7 @@ void test_seek_or_die
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if (HAVE_DECL_S_IRGRP == 0)
|
||||
#ifndef HAVE_DECL_S_IRGRP
|
||||
#include <sf_unistd.h>
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user