mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Add a function psf_sanitize_string and use it in aiff.c.
This commit is contained in:
parent
0f0193ad8b
commit
d4d3f1c402
@ -4,6 +4,9 @@
|
||||
Fix a bug in parsing AIFF files with a slightly unusual 'basc' chunk. Thanks
|
||||
to David Viens for providing two example files.
|
||||
|
||||
* src/common.(c|h) src/aiff.c
|
||||
Add a function psf_sanitize_string and use it in aiff.c.
|
||||
|
||||
2006-10-18 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/wav_w64.c
|
||||
|
@ -519,6 +519,9 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
|
||||
cptr = psf->u.cbuf ;
|
||||
psf_binheader_readf (psf, "b", cptr, dword + (dword & 1)) ;
|
||||
cptr [dword] = 0 ;
|
||||
|
||||
psf_sanitize_string (cptr, dword) ;
|
||||
|
||||
psf_log_printf (psf, " %M : %s\n", marker, cptr) ;
|
||||
psf_store_string (psf, SF_STR_COPYRIGHT, cptr) ;
|
||||
break ;
|
||||
|
52
src/common.c
52
src/common.c
@ -1169,25 +1169,6 @@ psf_log_SF_INFO (SF_PRIVATE *psf)
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
SF_INSTRUMENT *
|
||||
psf_instrument_alloc (void)
|
||||
{ SF_INSTRUMENT *instr ;
|
||||
|
||||
instr = calloc (1, sizeof (SF_INSTRUMENT)) ;
|
||||
|
||||
if (instr == NULL)
|
||||
return NULL ;
|
||||
|
||||
/* Set non-zero default values. */
|
||||
instr->basenote = -1 ;
|
||||
instr->velocity_lo = -1 ;
|
||||
instr->velocity_hi = -1 ;
|
||||
instr->key_lo = -1 ;
|
||||
instr->key_hi = -1 ;
|
||||
|
||||
return instr ;
|
||||
} /* psf_instrument_alloc */
|
||||
|
||||
void*
|
||||
psf_memset (void *s, int c, sf_count_t len)
|
||||
{ char *ptr ;
|
||||
@ -1207,7 +1188,38 @@ psf_memset (void *s, int c, sf_count_t len)
|
||||
return s ;
|
||||
} /* psf_memset */
|
||||
|
||||
void psf_get_date_str (char *str, int maxlen)
|
||||
SF_INSTRUMENT *
|
||||
psf_instrument_alloc (void)
|
||||
{ SF_INSTRUMENT *instr ;
|
||||
|
||||
instr = calloc (1, sizeof (SF_INSTRUMENT)) ;
|
||||
|
||||
if (instr == NULL)
|
||||
return NULL ;
|
||||
|
||||
/* Set non-zero default values. */
|
||||
instr->basenote = -1 ;
|
||||
instr->velocity_lo = -1 ;
|
||||
instr->velocity_hi = -1 ;
|
||||
instr->key_lo = -1 ;
|
||||
instr->key_hi = -1 ;
|
||||
|
||||
return instr ;
|
||||
} /* psf_instrument_alloc */
|
||||
|
||||
void
|
||||
psf_sanitize_string (char * cptr, int len)
|
||||
{
|
||||
do
|
||||
{
|
||||
len -- ;
|
||||
cptr [len] = isprint (cptr [len]) ? cptr [len] : '.' ;
|
||||
}
|
||||
while (len > 0) ;
|
||||
} /* psf_sanitize_string */
|
||||
|
||||
void
|
||||
psf_get_date_str (char *str, int maxlen)
|
||||
{ time_t current ;
|
||||
struct tm timedata, *tmptr ;
|
||||
|
||||
|
@ -616,9 +616,6 @@ int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) ;
|
||||
/* Default seek function. Use for PCM and float encoded data. */
|
||||
sf_count_t psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) ;
|
||||
|
||||
/* Generate the currebt date as a string. */
|
||||
void psf_get_date_str (char *str, int maxlen) ;
|
||||
|
||||
int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ;
|
||||
|
||||
/*------------------------------------------------------------------------------------
|
||||
@ -724,6 +721,10 @@ void *psf_memset (void *s, int c, sf_count_t n) ;
|
||||
|
||||
SF_INSTRUMENT * psf_instrument_alloc (void) ;
|
||||
|
||||
void psf_sanitize_string (char * cptr, int len) ;
|
||||
|
||||
/* Generate the current date as a string. */
|
||||
void psf_get_date_str (char *str, int maxlen) ;
|
||||
|
||||
SF_BROADCAST_INFO* broadcast_info_alloc (void) ;
|
||||
int broadcast_info_copy (SF_BROADCAST_INFO* dst, SF_BROADCAST_INFO* src) ;
|
||||
|
Loading…
Reference in New Issue
Block a user