return;
}
if (!pad->handle) {
- struct alsa_write_args_info *conf = wn->conf;
+ int32_t val;
if (bytes == 0) /* no data available */
return;
- /* defaults */
- pad->sample_rate = conf->sample_rate_arg;
- pad->channels = conf->channels_arg;
- if (!conf->sample_rate_given) { /* config option trumps btr_exec */
- int32_t rate;
- if (get_btr_sample_rate(btrn, &rate) >= 0)
- pad->sample_rate = rate;
- }
- if (!conf->channels_given) {
- int32_t ch;
- if (get_btr_channels(btrn, &ch) >= 0)
- pad->channels = ch;
- }
- PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->sample_rate);
+ ret = get_btr_sample_rate(btrn, &val);
+ if (ret < 0)
+ goto err;
+ pad->sample_rate = val;
+ ret = get_btr_channels(btrn, &val);
+ if (ret < 0)
+ goto err;
+ pad->channels = val;
+ PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels,
+ pad->sample_rate);
ret = alsa_init(pad, wn->conf);
if (ret < 0)
goto err;
On systems with dmix, a better choice than the default
value might be to use \"plug:swmix\".
"
-
-option "channels" c
-#~~~~~~~~~~~~~~~~~~
-"specify number of channels"
-int typestr="num"
-default="2"
-optional
-details="
- This option is only necessary for playing raw audio with
- para_write. In all other cases (plaing wav files with
- para_write or using this writer with para_audiod), the number
- of channels will be obtained from other resources.
-"
-
-option "sample_rate" s
-#~~~~~~~~~~~~~~~~~~~~~
-"force given sample rate"
-int typestr="num"
-default="44100"
-optional
-details="
- Again, it is only necessary to specify this when playing raw
- audio with para_write.
-"
</qu>
string typestr="device"
default="/dev/dsp"
optional
-
-option "channels" c
-#~~~~~~~~~~~~~~~~~~
-"specify number of channels"
-int typestr="num"
-default="2"
-optional
-details="
- This option is only necessary for playing raw audio with
- para_write. In all other cases (plaing wav files with
- para_write or using this writer with para_audiod), the number
- of channels will be obtained from other resources.
-"
-
-option "sample_rate" s
-#~~~~~~~~~~~~~~~~~~~~~
-"force given sample rate"
-int typestr="num"
-default="44100"
-optional
-details="
- Again, it is only necessary to specify this when playing raw
- audio with para_write.
-"
+details = ""
section "osx options"
#####################
-option "channels" c
-#~~~~~~~~~~~~~~~~~~
-"channel count"
-
-details = "
- Specify the number of channels. This is only neccessary for raw audio.
-"
-
- int typestr="num"
- default="2"
- optional
-
-option "sample_rate" s
-#~~~~~~~~~~~~~~~~~~~~~
-
-"force given sample rate (only neccessary for
-raw audio)"
-
- int typestr="num"
- default="44100"
- optional
-
option "numbuffers" n
#~~~~~~~~~~~~~~~~~~~~~
int typestr="num"
default="20"
optional
+ details = ""
May be give multiple times. The same writer may be specified
more than once.
"
+
+text "
+ The following options are only necessary for raw audio. When
+ playing wav files this information is obtained from the
+ wave header.
+"
+
+option "channels" c
+#~~~~~~~~~~~~~~~~~~
+"specify number of channels"
+int typestr = "num"
+default = "2"
+optional
+
+option "sample-rate" s
+#~~~~~~~~~~~~~~~~~~~~~
+"force given sample rate"
+int typestr = "num"
+default = "44100"
+optional
struct task *t)
{
struct writer_node *wn = container_of(t, struct writer_node, task);
- struct oss_write_args_info *conf = wn->conf;
struct private_oss_write_data *powd = wn->private_data;
struct btr_node *btrn = wn->btrn;
size_t frames, bytes;
return;
if (powd->fd < 0) {
int32_t rate, ch;
- ret = -1;
- if (!conf->sample_rate_given) /* config option trumps btr_exec */
- ret = get_btr_sample_rate(wn->btrn, &rate);
+ ret = get_btr_sample_rate(btrn, &rate);
if (ret < 0)
- rate = conf->sample_rate_arg;
- ret = -1;
- if (!conf->channels_given)
- ret = get_btr_channels(wn->btrn, &ch);
+ goto out;
+ ret = get_btr_channels(btrn, &ch);
if (ret < 0)
- ch = conf->channels_arg;
+ goto out;
ret = oss_init(wn, rate, ch);
if (ret < 0)
goto out;
AudioStreamBasicDescription format;
int ret;
struct btr_node *btrn = wn->btrn;
- struct osx_write_args_info *conf = wn->conf;
+ int32_t val;
wn->private_data = powd;
/* where did that default audio output go? */
if (AudioUnitInitialize(powd->audio_unit))
goto e1;
powd->play = 0;
- powd->sample_rate = conf->sample_rate_arg;
- powd->channels = conf->channels_arg;
- if (!conf->sample_rate_given) {
- int32_t rate;
- get_btr_sample_rate(btrn, &rate);
- powd->sample_rate = rate;
- }
- if (!conf->channels_given) {
- int32_t ch;
- get_btr_channels(btrn, &ch);
- powd->channels = ch;
- }
+ ret = get_btr_sample_rate(btrn, &val);
+ if (ret < 0)
+ goto e1;
+ powd->sample_rate = val;
+ ret = get_btr_channels(btrn, &val);
+ if (ret < 0)
+ goto e1;
+ powd->channels = val;
/*
* Choose PCM format. We tell the Output Unit what format we're going
* to supply data to it. This is necessary if you're providing data
sched_min_delay(s);
}
+#define HANDLE_EXEC(_cmd) \
+ if (!strcmp(cmd, #_cmd)) { \
+ if (!conf._cmd ## _given && cwt->state == CWS_NEED_HEADER) \
+ return -E_BTR_NAVAIL; \
+ *result = make_message("%d", cwt->state == CWS_NO_HEADER? \
+ conf._cmd ## _arg : cwt->_cmd); \
+ return 1; \
+ } \
+
+
static int check_wav_exec(struct btr_node *btrn, const char *cmd, char **result)
{
struct check_wav_task *cwt = btr_context(btrn);
-
- if (!strcmp(cmd, "sample_rate")) {
- if (cwt->state != CWS_HAVE_HEADER)
- return -E_BTR_NAVAIL;
- *result = make_message("%d", cwt->sample_rate);
- return 1;
- }
- if (!strcmp(cmd, "channels")) {
- if (cwt->state != CWS_HAVE_HEADER)
- return -E_BTR_NAVAIL;
- *result = make_message("%d", cwt->channels);
- return 1;
- }
+ HANDLE_EXEC(sample_rate);
+ HANDLE_EXEC(channels);
return -ERRNO_TO_PARA_ERROR(ENOTSUP);
}