mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Put the parselog buffer and the index inside a struct within SF_PRIVATE.
This commit is contained in:
parent
3d46c1f19f
commit
7588ad5a55
@ -2,6 +2,7 @@
|
||||
|
||||
* src/common.h src*.c
|
||||
Rename logbuffer field of SF_PRIVATE to parselog and reduce its size.
|
||||
Put the parselog buffer and the index inside a struct within SF_PRIVATE.
|
||||
|
||||
2012-01-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
|
@ -60,7 +60,7 @@ audio_detect (SF_PRIVATE * psf, AUDIO_DETECT *ad, const unsigned char * data, in
|
||||
" be_int_24_32 : %d\n",
|
||||
vote.le_float, vote.be_float, vote.le_int_24_32, vote.be_int_24_32) ;
|
||||
|
||||
if (0) puts (psf->parselog) ;
|
||||
if (0) puts (psf->parselog.buf) ;
|
||||
|
||||
if (ad->endianness == SF_ENDIAN_LITTLE && vote.le_float > (3 * datalen) / 4)
|
||||
{ /* Almost certainly 32 bit floats. */
|
||||
|
@ -40,9 +40,9 @@
|
||||
|
||||
static inline void
|
||||
log_putchar (SF_PRIVATE *psf, char ch)
|
||||
{ if (psf->logindex < SIGNED_SIZEOF (psf->parselog) - 1)
|
||||
{ psf->parselog [psf->logindex++] = ch ;
|
||||
psf->parselog [psf->logindex] = 0 ;
|
||||
{ if (psf->parselog.indx < SIGNED_SIZEOF (psf->parselog.buf) - 1)
|
||||
{ psf->parselog.buf [psf->parselog.indx++] = ch ;
|
||||
psf->parselog.buf [psf->parselog.indx] = 0 ;
|
||||
} ;
|
||||
return ;
|
||||
} /* log_putchar */
|
||||
|
@ -344,10 +344,14 @@ typedef struct sf_private_tag
|
||||
|
||||
char syserr [SF_SYSERR_LEN] ;
|
||||
|
||||
/* parselog and logindex should only be changed within the logging functions
|
||||
/* parselog and indx should only be changed within the logging functions
|
||||
** of common.c
|
||||
*/
|
||||
char parselog [SF_PARSELOG_LEN] ;
|
||||
struct
|
||||
{ char buf [SF_PARSELOG_LEN] ;
|
||||
int indx ;
|
||||
} parselog ;
|
||||
|
||||
unsigned char header [SF_HEADER_LEN] ; /* Must be unsigned */
|
||||
int rwf_endian ; /* Header endian-ness flag. */
|
||||
|
||||
@ -365,7 +369,6 @@ typedef struct sf_private_tag
|
||||
unsigned unique_id ;
|
||||
|
||||
/* Index variables for maintaining parselog and header above. */
|
||||
int logindex ;
|
||||
int headindex, headend ;
|
||||
int has_text ;
|
||||
|
||||
|
@ -1006,7 +1006,7 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
||||
case SFC_GET_LOG_INFO :
|
||||
if (data == NULL)
|
||||
return SFE_BAD_COMMAND_PARAM ;
|
||||
snprintf (data, datasize, "%s", psf->parselog) ;
|
||||
snprintf (data, datasize, "%s", psf->parselog.buf) ;
|
||||
break ;
|
||||
|
||||
case SFC_CALC_SIGNAL_MAX :
|
||||
@ -2508,7 +2508,7 @@ validate_psf (SF_PRIVATE *psf)
|
||||
|
||||
static void
|
||||
save_header_info (SF_PRIVATE *psf)
|
||||
{ snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog) ;
|
||||
{ snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ;
|
||||
} /* save_header_info */
|
||||
|
||||
static void
|
||||
@ -2915,7 +2915,7 @@ error_exit :
|
||||
|
||||
if (error == SFE_SYSTEM)
|
||||
snprintf (sf_syserr, sizeof (sf_syserr), "%s", psf->syserr) ;
|
||||
snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog) ;
|
||||
snprintf (sf_parselog, sizeof (sf_parselog), "%s", psf->parselog.buf) ;
|
||||
|
||||
switch (error)
|
||||
{ case SF_ERR_SYSTEM :
|
||||
|
@ -29,38 +29,38 @@
|
||||
#include "test_main.h"
|
||||
|
||||
#define CMP_0_ARGS(line, err, fmt) \
|
||||
{ psf->logindex = 0 ; \
|
||||
{ psf->parselog.indx = 0 ; \
|
||||
snprintf (buffer, sizeof (buffer), (fmt)) ; \
|
||||
psf_log_printf (psf, (fmt)) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \
|
||||
}
|
||||
|
||||
#define CMP_2_ARGS(line, err, fmt, a) \
|
||||
{ psf->logindex = 0 ; \
|
||||
{ psf->parselog.indx = 0 ; \
|
||||
snprintf (buffer, sizeof (buffer), (fmt), (a), (a)) ; \
|
||||
psf_log_printf (psf, (fmt), (a), (a)) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \
|
||||
}
|
||||
|
||||
#define CMP_4_ARGS(line, err, fmt, a) \
|
||||
{ psf->logindex = 0 ; \
|
||||
{ psf->parselog.indx = 0 ; \
|
||||
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a)) ; \
|
||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a)) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \
|
||||
}
|
||||
|
||||
#define CMP_5_ARGS(line, err, fmt, a) \
|
||||
{ psf->logindex = 0 ; \
|
||||
{ psf->parselog.indx = 0 ; \
|
||||
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a)) ; \
|
||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a)) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \
|
||||
}
|
||||
|
||||
#define CMP_6_ARGS(line, err, fmt, a) \
|
||||
{ psf->logindex = 0 ; \
|
||||
{ psf->parselog.indx = 0 ; \
|
||||
snprintf (buffer, sizeof (buffer), (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
||||
psf_log_printf (psf, (fmt), (a), (a), (a), (a), (a), (a)) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog) ; \
|
||||
err += compare_strings_or_die (line, fmt, buffer, psf->parselog.buf) ; \
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user