Lines Matching refs:ft
75 static int start_read(sox_format_t * ft) in start_read() argument
84 lsx_readdw(ft, &file_size); in start_read()
87 if (file_size >= 2 && ft->seekable) { in start_read()
91 lsx_readsw(ft, &int16); in start_read()
94 if (lsx_seeki(ft, (off_t)sizeof(file_size), SEEK_SET) != 0) in start_read()
97 lsx_warn("invalid checksum in input file %s", ft->filename); in start_read()
100 lsx_skipbytes(ft, (size_t)(2 + 4 + 6)); /* Checksum, version, time stamp. */ in start_read()
102 lsx_readchars(ft, read_id, sizeof(read_id)); in start_read()
104 lsx_fail_errno(ft, SOX_EHDR, "gsrt: invalid file name in header"); in start_read()
108 lsx_readsw(ft, &ft_encoding); in start_read()
112 ft->handler.read = NULL; in start_read()
114 lsx_skipbytes(ft, PADDING_SIZE); in start_read()
116 return lsx_check_read_params(ft, 1, 8000., encoding, in start_read()
120 static int start_write(sox_format_t * ft) in start_write() argument
122 int i, encoding = ft_enc(ft->encoding.bits_per_sample, ft->encoding.encoding); in start_write()
134 return lsx_writedw(ft, 0) in start_write()
135 || lsx_writesw(ft, -checksum) in start_write()
136 || lsx_writedw(ft, VERSION_) in start_write()
137 || lsx_writesw(ft, t->tm_year + 1900) in start_write()
138 || lsx_writesb(ft, t->tm_mon + 1) in start_write()
139 || lsx_writesb(ft, t->tm_mday) in start_write()
140 || lsx_writesb(ft, t->tm_hour) in start_write()
141 || lsx_writesb(ft, t->tm_min) in start_write()
142 || lsx_writechars(ft, id, sizeof(id)) in start_write()
143 || lsx_writesw(ft, encoding) in start_write()
144 || lsx_padbytes(ft, PADDING_SIZE) ? SOX_EOF : SOX_SUCCESS; in start_write()
148 sox_format_t * ft, sox_sample_t const * buf, size_t nsamp) in write_samples() argument
150 size_t n = min(nsamp, MAX_FILE_SIZE - (size_t)ft->tell_off); in write_samples()
153 return lsx_rawwrite(ft, buf, n); in write_samples()
156 static int stop_write(sox_format_t * ft) in stop_write() argument
158 long num_samples = ft->tell_off - HEADER_SIZE; in stop_write()
162 lsx_rawwrite(ft, &pad, 1); in stop_write()
165 if (ft->seekable) { in stop_write()
166 unsigned i, file_size = ft->tell_off >> 1; in stop_write()
169 if (!lsx_seeki(ft, (off_t)sizeof(uint32_t), SEEK_SET)) { in stop_write()
170 lsx_readsw(ft, &int16); in stop_write()
172 if (!lsx_seeki(ft, (off_t)HEADER_SIZE, SEEK_SET)) { in stop_write()
174 lsx_readsw(ft, &int16); in stop_write()
177 if (!lsx_seeki(ft, (off_t)0, SEEK_SET)) { in stop_write()
178 lsx_writedw(ft, file_size); in stop_write()
179 lsx_writesw(ft, -checksum); in stop_write()
186 "length in file header will be unspecified", ft->filename); in stop_write()