struct filter_node *fn = btr_context(btrn);
struct private_aacdec_data *padd = fn->private_data;
- if (!strcmp(cmd, "sample_rate")) {
- if (padd->sample_rate == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", padd->sample_rate);
- return 1;
- }
- if (!strcmp(cmd, "channels")) {
- if (padd->channels == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", padd->channels);
- return 1;
- }
- return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ return decoder_execute(cmd, padd->sample_rate, padd->channels, result);
}
static void aacdec_open(struct filter_node *fn)
int check_filter_arg(char *filter_arg, void **conf);
void print_filter_helps(int detailed);
void generic_filter_pre_select(struct sched *s, struct task *t);
+int decoder_execute(const char *cmd, unsigned sample_rate, unsigned channels,
+ char **result);
static inline void write_int16_host_endian(char *buf, int val)
{
if (btr_node_status(fn->btrn, fn->min_iqs, BTR_NT_INTERNAL) != 0)
sched_min_delay(s);
}
+
+/**
+ * Execute a btr command for a decoder.
+ *
+ * The buffer tree nodes of the writers ask the parent nodes about sample_rate
+ * and the channels count. This function is called by all decoders to answer
+ * these queries.
+ *
+ * \param cmd The command to be executed by the child node.
+ * \param sample_rate Known to the decoder.
+ * \param channels Known to the decoder.
+ * \param result Ascii representation on the answer is stored here.
+ */
+int decoder_execute(const char *cmd, unsigned sample_rate, unsigned channels,
+ char **result)
+{
+ if (!strcmp(cmd, "sample_rate")) {
+ if (sample_rate == 0)
+ return -E_BTR_NAVAIL;
+ *result = make_message("%u", sample_rate);
+ return 1;
+ }
+ if (!strcmp(cmd, "channels")) {
+ if (channels == 0)
+ return -E_BTR_NAVAIL;
+ *result = make_message("%u", channels);
+ return 1;
+ }
+ return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+}
struct filter_node *fn = btr_context(btrn);
struct private_mp3dec_data *pmd = fn->private_data;
- if (!strcmp(cmd, "sample_rate")) {
- if (pmd->sample_rate == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pmd->sample_rate);
- return 1;
- }
- if (!strcmp(cmd, "channels")) {
- if (pmd->channels == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pmd->channels);
- return 1;
- }
- return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ return decoder_execute(cmd, pmd->sample_rate, pmd->channels, result);
}
static void mp3dec_free_config(void *conf)
struct filter_node *fn = btr_context(btrn);
struct private_oggdec_data *pod = fn->private_data;
- if (!strcmp(cmd, "sample_rate")) {
- if (pod->sample_rate == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pod->sample_rate);
- return 1;
- }
- if (!strcmp(cmd, "channels")) {
- if (pod->channels == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pod->channels);
- return 1;
- }
- return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ return decoder_execute(cmd, pod->sample_rate, pod->channels, result);
}
static int ogg_init(struct filter_node *fn)
struct filter_node *fn = btr_context(btrn);
struct private_wmadec_data *pwd = fn->private_data;
- if (!strcmp(cmd, "sample_rate")) {
- if (pwd->ahi.sample_rate == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pwd->ahi.sample_rate);
- return 1;
- }
- if (!strcmp(cmd, "channels")) {
- if (pwd->ahi.channels == 0)
- return -E_BTR_NAVAIL;
- *result = make_message("%u", pwd->ahi.channels);
- return 1;
- }
- return -ERRNO_TO_PARA_ERROR(ENOTSUP);
+ return decoder_execute(cmd, pwd->ahi.sample_rate, pwd->ahi.channels,
+ result);
}
#define WMA_OUTPUT_BUFFER_SIZE (128 * 1024)