31417de6e1a4fe9ec2c5b8f996ff6c37ff669398
[paraslash.git] / check_wav.h
1 /*
2 * Copyright (C) 2012 Andre Noll <maan@tuebingen.mpg.de>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file check_wav.h Detect, process and cut a wav header. */
8
9 struct check_wav_context;
10
11 /**
12 * These come from the command line arguments.
13 *
14 * Different users of the check_wav API have different arg_info structs,
15 * so we need a universal variant for these.
16 */
17 struct wav_params {
18 /** Number of channels, or the default value. */
19 int channels_arg;
20 /** Whether the channel count was given. */
21 int channels_given;
22 /** Same semantics as \a channels_count. */
23 int sample_rate_arg;
24 /** Whether the sample rate was given. */
25 int sample_rate_given;
26 /** Same semantics as \a sample_rate. */
27 int sample_format_arg;
28 /** Whether the sample format was given. */
29 int sample_format_given;
30 };
31
32 /**
33 * Copy the wav parameters.
34 *
35 * \param dst Usually a pointer to struct wav_params.
36 * \param src Usually a pointer to some args_info struct.
37 *
38 * This can not be implemented as a function since the type of the structure
39 * pointed to by \a src depends on the application.
40 */
41 #define COPY_WAV_PARMS(dst, src) \
42 (dst)->channels_arg = (src)->channels_arg; \
43 (dst)->channels_given = (src)->channels_given; \
44 (dst)->sample_rate_arg = (src)->sample_rate_arg; \
45 (dst)->sample_rate_given = (src)->sample_rate_given; \
46 (dst)->sample_format_arg = (src)->sample_format_arg; \
47 (dst)->sample_format_given = (src)->sample_format_given;
48
49 #define LLS_COPY_WAV_PARMS(_dst, _pfx, _lpr) \
50 (_dst)->channels_given = lls_opt_given(lls_opt_result( \
51 _pfx ## _OPT_CHANNELS, (_lpr))); \
52 (_dst)->sample_rate_given = lls_opt_given(lls_opt_result( \
53 _pfx ## _OPT_SAMPLE_RATE, (_lpr))); \
54 (_dst)->sample_format_given = lls_opt_given(lls_opt_result( \
55 _pfx ## _OPT_SAMPLE_FORMAT, (_lpr))); \
56 (_dst)->channels_arg = lls_uint32_val(0, lls_opt_result( \
57 _pfx ## _OPT_CHANNELS, (_lpr))); \
58 (_dst)->sample_rate_arg = lls_uint32_val(0, lls_opt_result( \
59 _pfx ## _OPT_SAMPLE_RATE, (_lpr))); \
60 (_dst)->sample_format_arg = lls_uint32_val(0, lls_opt_result( \
61 _pfx ## _OPT_SAMPLE_FORMAT, (_lpr)));
62
63 struct check_wav_context *check_wav_init(struct btr_node *parent,
64 struct btr_node *child, struct wav_params *params,
65 struct btr_node **cw_btrn);
66 void check_wav_pre_select(struct sched *s, struct check_wav_context *cwc);
67 int check_wav_post_select(struct check_wav_context *cwc);
68 void check_wav_shutdown(struct check_wav_context *cwc);