To support this change, turn on lots more compiler warnings, and fix all the warnings generated.
Showing the changes to src/sndrtool.c (1 of 93 files). Show all
Unified · Split
| @@ -20,9 +20,27 @@ typedef struct sndpriv { · 19 unmodified lines | |||
| 20 | st_size_t dataStart; | 20 | st_size_t dataStart; |
| 21 | } *snd_t; | 21 | } *snd_t; |
| 22 | 22 | ||
| 23 | static void sndtwriteheader(ft_t ft, st_size_t nsamples); | 23 | static void sndtwriteheader(ft_t ft, st_size_t nsamples) |
| 24 | { | ||
| 25 | char name_buf[97]; | ||
| 24 | 26 | ||
| 25 | int st_sndseek(ft_t ft, st_size_t offset) | 27 | /* sndtool header */ |
| 28 | st_writes(ft, "SOUND"); /* magic */ | ||
| 29 | st_writeb(ft, 0x1a); | ||
| 30 | st_writew (ft,0); /* hGSound */ | ||
| 31 | st_writedw (ft,nsamples); | ||
| 32 | st_writedw (ft,0); | ||
| 33 | st_writedw (ft,nsamples); | ||
| 34 | st_writew (ft,(int) ft->info.rate); | ||
| 35 | st_writew (ft,0); | ||
| 36 | st_writew (ft,10); | ||
| 37 | st_writew (ft,4); | ||
| 38 | memset (name_buf, 0, 96); | ||
| 39 | sprintf (name_buf,"%.62s - File created by SoX",ft->filename); | ||
| 40 | st_writebuf(ft, name_buf, 1, 96); | ||
| 41 | } | ||
| 42 | |||
| 43 | static int st_sndseek(ft_t ft, st_size_t offset) | ||
| 26 | { | 44 | { |
| 27 | st_size_t new_offset, channel_block, alignment; | 45 | st_size_t new_offset, channel_block, alignment; |
| 28 | snd_t snd = (snd_t ) ft->priv; | 46 | snd_t snd = (snd_t ) ft->priv; |
| @@ -41,11 +59,8 @@ int st_sndseek(ft_t ft, st_size_t offset) · 12 unmodified lines | |||
| 41 | 59 | ||
| 42 | return st_seeki(ft, new_offset, SEEK_SET); | 60 | return st_seeki(ft, new_offset, SEEK_SET); |
| 43 | } | 61 | } |
| 44 | /*======================================================================*/ | ||
| 45 | /* SNDSTARTREAD */ | ||
| 46 | /*======================================================================*/ | ||
| 47 | 62 | ||
| 48 | int st_sndtstartread(ft_t ft) | 63 | static int st_sndtstartread(ft_t ft) |
| 49 | { | 64 | { |
| 50 | snd_t snd = (snd_t ) ft->priv; | 65 | snd_t snd = (snd_t ) ft->priv; |
| 51 | 66 | ||
| @@ -122,10 +137,7 @@ int st_sndtstartread(ft_t ft) · 70 unmodified lines | |||
| 122 | return (ST_SUCCESS); | 137 | return (ST_SUCCESS); |
| 123 | } | 138 | } |
| 124 | 139 | ||
| 125 | /*======================================================================*/ | 140 | static int st_sndtstartwrite(ft_t ft) |
| 126 | /* SNDTSTARTWRITE */ | ||
| 127 | /*======================================================================*/ | ||
| 128 | int st_sndtstartwrite(ft_t ft) | ||
| 129 | { | 141 | { |
| 130 | snd_t p = (snd_t ) ft->priv; | 142 | snd_t p = (snd_t ) ft->priv; |
| 131 | int rc; | 143 | int rc; |
| @@ -143,66 +155,24 @@ int st_sndtstartwrite(ft_t ft) · 11 unmodified lines | |||
| 143 | ft->swap = ft->swap ? 0 : 1; | 155 | ft->swap = ft->swap ? 0 : 1; |
| 144 | } | 156 | } |
| 145 | 157 | ||
| 146 | /* write header */ | 158 | /* write header */ |
| 147 | ft->info.channels = 1; | 159 | ft->info.channels = 1; |
| 148 | ft->info.encoding = ST_ENCODING_UNSIGNED; | 160 | ft->info.encoding = ST_ENCODING_UNSIGNED; |
| 149 | ft->info.size = ST_SIZE_BYTE; | 161 | ft->info.size = ST_SIZE_BYTE; |
| 150 | p->nsamples = 0; | 162 | p->nsamples = 0; |
| 151 | sndtwriteheader(ft, 0); | 163 | sndtwriteheader(ft, 0); |
| 152 | |||
| 153 | return(ST_SUCCESS); | ||
| 154 | } | ||
| 155 | |||
| 156 | /*======================================================================*/ | ||
| 157 | /* SNDRSTARTWRITE */ | ||
| 158 | /*======================================================================*/ | ||
| 159 | int st_sndrstartwrite(ft_t ft) | ||
| 160 | { | ||
| 161 | int rc; | ||
| 162 | |||
| 163 | /* Needed for rawread() */ | ||
| 164 | rc = st_rawstartread(ft); | ||
| 165 | if (rc) | ||
| 166 | return rc; | ||
| 167 | |||
| 168 | /* sndr is in little endian format so | ||
| 169 | * swap bytes on big endian machines | ||
| 170 | */ | ||
| 171 | if (ST_IS_BIGENDIAN) | ||
| 172 | { | ||
| 173 | ft->swap = ft->swap ? 0 : 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | /* write header */ | ||
| 177 | ft->info.channels = 1; | ||
| 178 | ft->info.encoding = ST_ENCODING_UNSIGNED; | ||
| 179 | ft->info.size = ST_SIZE_BYTE; | ||
| 180 | |||
| 181 | /* sounder header */ | ||
| 182 | st_writew (ft,0); /* sample size code */ | ||
| 183 | st_writew (ft,(int) ft->info.rate); /* sample rate */ | ||
| 184 | st_writew (ft,10); /* volume */ | ||
| 185 | st_writew (ft,4); /* shift */ | ||
| 186 | 164 | ||
| 187 | return(ST_SUCCESS); | 165 | return(ST_SUCCESS); |
| 188 | } | 166 | } |
| 189 | 167 | ||
| 190 | /*======================================================================*/ | 168 | static st_size_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len) |
| 191 | /* SNDTWRITE */ | ||
| 192 | /*======================================================================*/ | ||
| 193 | |||
| 194 | st_ssize_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len) | ||
| 195 | { | 169 | { |
| 196 | snd_t p = (snd_t ) ft->priv; | 170 | snd_t p = (snd_t ) ft->priv; |
| 197 | p->nsamples += len; | 171 | p->nsamples += len; |
| 198 | return st_rawwrite(ft, buf, len); | 172 | return st_rawwrite(ft, buf, len); |
| 199 | } | 173 | } |
| 200 | 174 | ||
| 201 | /*======================================================================*/ | 175 | static int st_sndtstopwrite(ft_t ft) |
| 202 | /* SNDTSTOPWRITE */ | ||
| 203 | /*======================================================================*/ | ||
| 204 | |||
| 205 | int st_sndtstopwrite(ft_t ft) | ||
| 206 | { | 176 | { |
| 207 | snd_t p = (snd_t ) ft->priv; | 177 | snd_t p = (snd_t ) ft->priv; |
| 208 | int rc; | 178 | int rc; |
| @@ -224,29 +194,6 @@ int st_sndtstopwrite(ft_t ft) · 15 unmodified lines | |||
| 224 | return(ST_SUCCESS); | 194 | return(ST_SUCCESS); |
| 225 | } | 195 | } |
| 226 | 196 | ||
| 227 | /*======================================================================*/ | ||
| 228 | /* SNDTWRITEHEADER */ | ||
| 229 | /*======================================================================*/ | ||
| 230 | static void sndtwriteheader(ft_t ft, st_size_t nsamples) | ||
| 231 | { | ||
| 232 | char name_buf[97]; | ||
| 233 | |||
| 234 | /* sndtool header */ | ||
| 235 | st_writes(ft, "SOUND"); /* magic */ | ||
| 236 | st_writeb(ft, 0x1a); | ||
| 237 | st_writew (ft,0); /* hGSound */ | ||
| 238 | st_writedw (ft,nsamples); | ||
| 239 | st_writedw (ft,0); | ||
| 240 | st_writedw (ft,nsamples); | ||
| 241 | st_writew (ft,(int) ft->info.rate); | ||
| 242 | st_writew (ft,0); | ||
| 243 | st_writew (ft,10); | ||
| 244 | st_writew (ft,4); | ||
| 245 | memset (name_buf, 0, 96); | ||
| 246 | sprintf (name_buf,"%.62s - File created by Sound Exchange",ft->filename); | ||
| 247 | st_writebuf(ft, name_buf, 1, 96); | ||
| 248 | } | ||
| 249 | |||
| 250 | /* Sndtool Sound File */ | 197 | /* Sndtool Sound File */ |
| 251 | static const char *sndtnames[] = { | 198 | static const char *sndtnames[] = { |
| 252 | "sndt", | 199 | "sndt", |