formats: clarify setting of reverse_bytes
[sox.git] / src / cdr.c
blob0b6b061ff5038b4554c91792e4ecc644634cfcf0
1 /* libSoX file format: cdda (c) 2006-8 SoX contributors
2 * Based on an original idea by David Elliott
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or (at
7 * your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
12 * General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "sox_i.h"
21 static int start(sox_format_t * ft)
23 return lsx_check_read_params(ft, 2, 44100., SOX_ENCODING_SIGN2, 16, (uint64_t)0, sox_true);
26 static int stopwrite(sox_format_t * ft)
28 unsigned const sector_num_samples = 588 * ft->signal.channels;
29 unsigned i = ft->olength % sector_num_samples;
31 if (i) while (i++ < sector_num_samples) /* Pad with silence to multiple */
32 lsx_writew(ft, 0); /* of 1/75th of a second. */
33 return SOX_SUCCESS;
36 LSX_FORMAT_HANDLER(cdr)
38 static char const * const names[] = {"cdda", "cdr", NULL};
39 static unsigned const write_encodings[] = {SOX_ENCODING_SIGN2, 16, 0, 0};
40 static sox_rate_t const write_rates[] = {44100, 0};
41 static sox_format_handler_t handler = {SOX_LIB_VERSION_CODE,
42 "Red Book Compact Disc Digital Audio",
43 names, SOX_FILE_BIG_END|SOX_FILE_STEREO,
44 start, lsx_rawread, NULL,
45 NULL, lsx_rawwrite, stopwrite,
46 lsx_rawseek, write_encodings, write_rates, 0
48 return &handler;