Fix for compiling when configured with --enable-experimental.

This commit is contained in:
Erik de Castro Lopo 2012-12-12 19:02:30 +11:00
parent b699e58000
commit e0be0ed962
4 changed files with 44 additions and 33 deletions

View File

@ -1,3 +1,9 @@
2012-12-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h src/dwd.c src/rx2.c src/txw.c
Fix for compiling when configured with --enable-experimental. Thanks to
Eric Wong for reporting this.
2012-12-01 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac programs/sndfile-play.c

View File

@ -122,16 +122,17 @@ typedef struct
static int
dwd_read_header (SF_PRIVATE *psf)
{ DWD_HEADER dwdh ;
{ BUF_UNION ubuf ;
DWD_HEADER dwdh ;
memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ;
memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ;
/* Set position to start of file to begin reading header. */
psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, DWD_IDENTIFIER_LEN) ;
psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, DWD_IDENTIFIER_LEN) ;
if (memcmp (psf->u.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0)
if (memcmp (ubuf.cbuf, DWD_IDENTIFIER, DWD_IDENTIFIER_LEN) != 0)
return SFE_DWD_NO_DWD ;
psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", psf->u.cbuf) ;
psf_log_printf (psf, "Read only : DiamondWare Digitized (.dwd)\n", ubuf.cbuf) ;
psf_binheader_readf (psf, "11", &dwdh.major, &dwdh.minor) ;
psf_binheader_readf (psf, "e4j1", &dwdh.id, 1, &dwdh.compression) ;

View File

@ -80,10 +80,9 @@ rx2_open (SF_PRIVATE *psf)
"Additional/PencilTool", "Disabled"
} ;
BUF_UNION ubuf ;
int error, marker, length, glob_offset, slce_count, frames ;
int sdat_length = 0, slce_total = 0 ;
int n_channels ;
@ -119,14 +118,14 @@ rx2_open (SF_PRIVATE *psf)
/* Get name length */
length = 0 ;
psf_binheader_readf (psf, "1", &length) ;
if (length >= SIGNED_SIZEOF (psf->u.cbuf))
if (length >= SIGNED_SIZEOF (ubuf.cbuf))
{ psf_log_printf (psf, " Text : %d *** Error : Too sf_count_t!\n") ;
return -1001 ;
}
memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ;
psf_binheader_readf (psf, "b", psf->u.cbuf, length) ;
psf_log_printf (psf, " Text : \"%s\"\n", psf->u.cbuf) ;
memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ;
psf_binheader_readf (psf, "b", ubuf.cbuf, length) ;
psf_log_printf (psf, " Text : \"%s\"\n", ubuf.cbuf) ;
/* Jump to GLOB offset position. */
if (glob_offset & 1)
@ -253,7 +252,7 @@ rx2_open (SF_PRIVATE *psf)
break ;
} ;
puts (psf->parselog) ;
puts (psf->parselog.buf) ;
puts ("-----------------------------------") ;
printf ("SDAT length : %d\n", sdat_length) ;
@ -270,7 +269,7 @@ rx2_open (SF_PRIVATE *psf)
puts (" ") ;
psf->parselog [0] = 0 ;
psf->parselog.buf [0] = 0 ;
/* OK, have the header although not too sure what it all means. */

View File

@ -124,14 +124,15 @@ txw_open (SF_PRIVATE *psf)
static int
txw_read_header (SF_PRIVATE *psf)
{ TXW_HEADER txwh ;
{ BUF_UNION ubuf ;
TXW_HEADER txwh ;
const char *strptr ;
memset (&txwh, 0, sizeof (txwh)) ;
memset (psf->u.cbuf, 0, sizeof (psf->u.cbuf)) ;
psf_binheader_readf (psf, "pb", 0, psf->u.cbuf, 16) ;
memset (ubuf.cbuf, 0, sizeof (ubuf.cbuf)) ;
psf_binheader_readf (psf, "pb", 0, ubuf.cbuf, 16) ;
if (memcmp (psf->u.cbuf, "LM8953\0\0\0\0\0\0\0\0\0\0", 16) != 0)
if (memcmp (ubuf.cbuf, "LM8953\0\0\0\0\0\0\0\0\0\0", 16) != 0)
return ERROR_666 ;
psf_log_printf (psf, "Read only : Yamaha TX-16 Sampler (.txw)\nLM8953\n") ;
@ -235,18 +236,19 @@ txw_read_header (SF_PRIVATE *psf)
static sf_count_t
txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
{ unsigned char *ucptr ;
{ BUF_UNION ubuf ;
unsigned char *ucptr ;
short sample ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
bufferlen = sizeof (psf->u.cbuf) / 3 ;
bufferlen = sizeof (ubuf.cbuf) / 3 ;
bufferlen -= (bufferlen & 1) ;
while (len > 0)
{ readcount = (len >= bufferlen) ? bufferlen : len ;
count = psf_fread (psf->u.cbuf, 3, readcount, psf) ;
count = psf_fread (ubuf.cbuf, 3, readcount, psf) ;
ucptr = psf->u.ucbuf ;
ucptr = ubuf.ucbuf ;
for (k = 0 ; k < readcount ; k += 2)
{ sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ;
ptr [total + k] = sample ;
@ -264,18 +266,19 @@ txw_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
static sf_count_t
txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
{ unsigned char *ucptr ;
{ BUF_UNION ubuf ;
unsigned char *ucptr ;
short sample ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
bufferlen = sizeof (psf->u.cbuf) / 3 ;
bufferlen = sizeof (ubuf.cbuf) / 3 ;
bufferlen -= (bufferlen & 1) ;
while (len > 0)
{ readcount = (len >= bufferlen) ? bufferlen : len ;
count = psf_fread (psf->u.cbuf, 3, readcount, psf) ;
count = psf_fread (ubuf.cbuf, 3, readcount, psf) ;
ucptr = psf->u.ucbuf ;
ucptr = ubuf.ucbuf ;
for (k = 0 ; k < readcount ; k += 2)
{ sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ;
ptr [total + k] = sample << 16 ;
@ -293,7 +296,8 @@ txw_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
static sf_count_t
txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
{ unsigned char *ucptr ;
{ BUF_UNION ubuf ;
unsigned char *ucptr ;
short sample ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
@ -304,13 +308,13 @@ txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
else
normfact = 1.0 / 0x10 ;
bufferlen = sizeof (psf->u.cbuf) / 3 ;
bufferlen = sizeof (ubuf.cbuf) / 3 ;
bufferlen -= (bufferlen & 1) ;
while (len > 0)
{ readcount = (len >= bufferlen) ? bufferlen : len ;
count = psf_fread (psf->u.cbuf, 3, readcount, psf) ;
count = psf_fread (ubuf.cbuf, 3, readcount, psf) ;
ucptr = psf->u.ucbuf ;
ucptr = ubuf.ucbuf ;
for (k = 0 ; k < readcount ; k += 2)
{ sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ;
ptr [total + k] = normfact * sample ;
@ -328,7 +332,8 @@ txw_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
static sf_count_t
txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
{ unsigned char *ucptr ;
{ BUF_UNION ubuf ;
unsigned char *ucptr ;
short sample ;
int k, bufferlen, readcount, count ;
sf_count_t total = 0 ;
@ -339,13 +344,13 @@ txw_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
else
normfact = 1.0 / 0x10 ;
bufferlen = sizeof (psf->u.cbuf) / 3 ;
bufferlen = sizeof (ubuf.cbuf) / 3 ;
bufferlen -= (bufferlen & 1) ;
while (len > 0)
{ readcount = (len >= bufferlen) ? bufferlen : len ;
count = psf_fread (psf->u.cbuf, 3, readcount, psf) ;
count = psf_fread (ubuf.cbuf, 3, readcount, psf) ;
ucptr = psf->u.ucbuf ;
ucptr = ubuf.ucbuf ;
for (k = 0 ; k < readcount ; k += 2)
{ sample = (ucptr [0] << 8) | (ucptr [1] & 0xF0) ;
ptr [total + k] = normfact * sample ;