History

Fix read and write return types: now st_size_t, like the size inputs.

To support this change, turn on lots more compiler warnings, and fix all the warnings generated.

rrt committed 19 years ago

Commit 4d743c41 parent ce1f8f393 files · +875 −1236Browse files

Showing the changes to src/sndrtool.c (1 of 93 files). Show all

Unified · Split

src/sndrtool.c+31−84
@@ -20,9 +20,27 @@ typedef struct sndpriv { · 19 unmodified lines
2020 st_size_t dataStart;
2121 } *snd_t;
2222
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];
2426
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)
2644 {
2745 st_size_t new_offset, channel_block, alignment;
2846 snd_t snd = (snd_t ) ft->priv;
@@ -41,11 +59,8 @@ int st_sndseek(ft_t ft, st_size_t offset) · 12 unmodified lines
4159
4260 return st_seeki(ft, new_offset, SEEK_SET);
4361 }
44−/*======================================================================*/
45−/* SNDSTARTREAD */
46−/*======================================================================*/
4762
48−int st_sndtstartread(ft_t ft)
63+static int st_sndtstartread(ft_t ft)
4964 {
5065 snd_t snd = (snd_t ) ft->priv;
5166
@@ -122,10 +137,7 @@ int st_sndtstartread(ft_t ft) · 70 unmodified lines
122137 return (ST_SUCCESS);
123138 }
124139
125−/*======================================================================*/
126−/* SNDTSTARTWRITE */
127−/*======================================================================*/
128−int st_sndtstartwrite(ft_t ft)
140+static int st_sndtstartwrite(ft_t ft)
129141 {
130142 snd_t p = (snd_t ) ft->priv;
131143 int rc;
@@ -143,66 +155,24 @@ int st_sndtstartwrite(ft_t ft) · 11 unmodified lines
143155 ft->swap = ft->swap ? 0 : 1;
144156 }
145157
146−/* write header */
147−ft->info.channels = 1;
148−ft->info.encoding = ST_ENCODING_UNSIGNED;
149−ft->info.size = ST_SIZE_BYTE;
150−p->nsamples = 0;
151−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 */
158+ /* write header */
159+ ft->info.channels = 1;
160+ ft->info.encoding = ST_ENCODING_UNSIGNED;
161+ ft->info.size = ST_SIZE_BYTE;
162+ p->nsamples = 0;
163+ sndtwriteheader(ft, 0);
186164
187−return(ST_SUCCESS);
165+ return(ST_SUCCESS);
188166 }
189167
190−/*======================================================================*/
191−/* SNDTWRITE */
192−/*======================================================================*/
193−
194−st_ssize_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
168+static st_size_t st_sndtwrite(ft_t ft, const st_sample_t *buf, st_size_t len)
195169 {
196170 snd_t p = (snd_t ) ft->priv;
197171 p->nsamples += len;
198172 return st_rawwrite(ft, buf, len);
199173 }
200174
201−/*======================================================================*/
202−/* SNDTSTOPWRITE */
203−/*======================================================================*/
204−
205−int st_sndtstopwrite(ft_t ft)
175+static int st_sndtstopwrite(ft_t ft)
206176 {
207177 snd_t p = (snd_t ) ft->priv;
208178 int rc;
@@ -224,29 +194,6 @@ int st_sndtstopwrite(ft_t ft) · 15 unmodified lines
224194 return(ST_SUCCESS);
225195 }
226196
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−
250197 /* Sndtool Sound File */
251198 static const char *sndtnames[] = {
252199 "sndt",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t