aft: Avoid invalid read.
[paraslash.git] / check_wav.h
1 /* Copyright (C) 2012 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file check_wav.h Detect, process and cut a wav header. */
4
5 struct check_wav_context;
6
7 /**
8  * These come from the command line arguments.
9  *
10  * Different users of the check_wav API have different arg_info structs,
11  * so we need a universal variant for these.
12  */
13 struct wav_params {
14         /** Number of channels, or the default value. */
15         int channels_arg;
16         /** Whether the channel count was given. */
17         int channels_given;
18         /** Same semantics as \a channels_count. */
19         int sample_rate_arg;
20         /** Whether the sample rate was given. */
21         int sample_rate_given;
22         /** Same semantics as \a sample_rate. */
23         int sample_format_arg;
24         /** Whether the sample format was given. */
25         int sample_format_given;
26 };
27
28 #define LLS_COPY_WAV_PARMS(_dst, _pfx, _lpr) \
29         (_dst)->channels_given = lls_opt_given(lls_opt_result( \
30                 _pfx ## _OPT_CHANNELS, (_lpr))); \
31         (_dst)->sample_rate_given = lls_opt_given(lls_opt_result( \
32                 _pfx ## _OPT_SAMPLE_RATE, (_lpr))); \
33         (_dst)->sample_format_given = lls_opt_given(lls_opt_result( \
34                 _pfx ## _OPT_SAMPLE_FORMAT, (_lpr))); \
35         (_dst)->channels_arg = lls_uint32_val(0, lls_opt_result( \
36                 _pfx ## _OPT_CHANNELS, (_lpr))); \
37         (_dst)->sample_rate_arg = lls_uint32_val(0, lls_opt_result( \
38                 _pfx ## _OPT_SAMPLE_RATE, (_lpr))); \
39         (_dst)->sample_format_arg = lls_uint32_val(0, lls_opt_result( \
40                 _pfx ## _OPT_SAMPLE_FORMAT, (_lpr)));
41
42 struct check_wav_context *check_wav_init(struct btr_node *parent,
43                 struct btr_node *child, struct wav_params *params,
44                 struct btr_node **cw_btrn);
45 void check_wav_pre_select(struct sched *s, struct check_wav_context *cwc);
46 int check_wav_post_select(struct check_wav_context *cwc);
47 void check_wav_shutdown(struct check_wav_context *cwc);