#define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
+#define audio_bug(fmt, ...) error_report("%s: " fmt, __func__, ##__VA_ARGS__)
+
const struct mixeng_volume nominal_volume = {
.mute = 0,
#ifdef FLOAT_MIXENG
#endif
};
-int audio_bug (const char *funcname, int cond)
-{
- if (cond) {
- static int shown;
-
- AUD_log (NULL, "A bug was just triggered in %s\n", funcname);
- if (!shown) {
- shown = 1;
- AUD_log (NULL, "Save all your work and restart without audio\n");
- AUD_log (NULL, "I am sorry\n");
- }
- AUD_log (NULL, "Context:\n");
- }
-
- return cond;
-}
-
/*
* Convert audio format to mixeng_clip index. Used by audio_pcm_sw_init_ and
* audio_mixeng_backend_add_capture()
static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw)
{
size_t live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
- if (audio_bug(__func__, live > hw->conv_buf.size)) {
- dolog("live=%zu hw->conv_buf.size=%zu\n", live, hw->conv_buf.size);
+ if (live > hw->conv_buf.size) {
+ audio_bug("live=%zu hw->conv_buf.size=%zu", live, hw->conv_buf.size);
return 0;
}
return live;
if (!live) {
return 0;
}
- if (audio_bug(__func__, live > hw->conv_buf.size)) {
- dolog("live_in=%zu hw->conv_buf.size=%zu\n", live, hw->conv_buf.size);
+ if (live > hw->conv_buf.size) {
+ audio_bug("live=%zu hw->conv_buf.size=%zu", live, hw->conv_buf.size);
return 0;
}
if (nb_live1) {
size_t live = smin;
- if (audio_bug(__func__, live > hw->mix_buf.size)) {
- dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
+ if (live > hw->mix_buf.size) {
+ audio_bug("live=%zu hw->mix_buf.size=%zu", live, hw->mix_buf.size);
return 0;
}
return live;
size_t frames_in_max, frames_out_max, total_in, total_out;
live = sw->total_hw_samples_mixed;
- if (audio_bug(__func__, live > hw->mix_buf.size)) {
- dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
+ if (live > hw->mix_buf.size) {
+ audio_bug("live=%zu hw->mix_buf.size=%zu", live, hw->mix_buf.size);
return 0;
}
}
live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
- if (audio_bug(__func__, live > sw->hw->conv_buf.size)) {
- dolog("live=%zu sw->hw->conv_buf.size=%zu\n", live,
- sw->hw->conv_buf.size);
+ if (live > sw->hw->conv_buf.size) {
+ audio_bug("live=%zu sw->hw->conv_buf.size=%zu", live,
+ sw->hw->conv_buf.size);
return 0;
}
live = sw->total_hw_samples_mixed;
- if (audio_bug(__func__, live > sw->hw->mix_buf.size)) {
- dolog("live=%zu sw->hw->mix_buf.size=%zu\n", live,
- sw->hw->mix_buf.size);
+ if (live > sw->hw->mix_buf.size) {
+ audio_bug("live=%zu sw->hw->mix_buf.size=%zu", live,
+ sw->hw->mix_buf.size);
return 0;
}
live = 0;
}
- if (audio_bug(__func__, live > hw->mix_buf.size)) {
- dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
+ if (live > hw->mix_buf.size) {
+ audio_bug("live=%zu hw->mix_buf.size=%zu", live, hw->mix_buf.size);
continue;
}
prev_rpos = hw->mix_buf.pos;
played = audio_pcm_hw_run_out(hw, live);
replay_audio_out(&played);
- if (audio_bug(__func__, hw->mix_buf.pos >= hw->mix_buf.size)) {
- dolog("hw->mix_buf.pos=%zu hw->mix_buf.size=%zu played=%zu\n",
- hw->mix_buf.pos, hw->mix_buf.size, played);
+ if (hw->mix_buf.pos >= hw->mix_buf.size) {
+ audio_bug("hw->mix_buf.pos=%zu hw->mix_buf.size=%zu played=%zu",
+ hw->mix_buf.pos, hw->mix_buf.size, played);
hw->mix_buf.pos = 0;
}
continue;
}
- if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) {
- dolog("played=%zu sw->total_hw_samples_mixed=%zu\n",
- played, sw->total_hw_samples_mixed);
+ if (played > sw->total_hw_samples_mixed) {
+ audio_bug("played=%zu sw->total_hw_samples_mixed=%zu",
+ played, sw->total_hw_samples_mixed);
played = sw->total_hw_samples_mixed;
}
continue;
}
- if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)) {
- dolog("captured=%zu sw->total_hw_samples_mixed=%zu\n",
- captured, sw->total_hw_samples_mixed);
+ if (captured > sw->total_hw_samples_mixed) {
+ audio_bug("captured=%zu sw->total_hw_samples_mixed=%zu",
+ captured, sw->total_hw_samples_mixed);
captured = sw->total_hw_samples_mixed;
}
min_voices);
}
- if (audio_bug(__func__, !voice_size && max_voices)) {
- dolog("drv=`%s' voice_size=0 max_voices=%d\n",
- k->name, max_voices);
+ if (!voice_size && max_voices) {
+ audio_bug("drv=`%s' voice_size=0 max_voices=%d",
+ k->name, max_voices);
glue(s->nb_hw_voices_, TYPE) = 0;
}
- if (audio_bug(__func__, voice_size && !max_voices)) {
- dolog("drv=`%s' voice_size=%zu max_voices=0\n",
- k->name, voice_size);
+ if (voice_size && !max_voices) {
+ audio_bug("drv=`%s' voice_size=%zu max_voices=0",
+ k->name, voice_size);
}
}
{
if (glue(audio_get_pdo_, TYPE)(hw->s->dev)->mixing_engine) {
size_t samples = hw->samples;
- if (audio_bug(__func__, samples == 0)) {
- dolog("Attempted to allocate empty buffer\n");
+ if (samples == 0) {
+ audio_bug("Attempted to allocate empty buffer");
}
HWBUF.buffer = g_new0(st_sample, samples);
return NULL;
}
- if (audio_bug(__func__, !glue(k->init_, TYPE))) {
- dolog("No host audio driver or missing init_%s\n", NAME);
+ if (!glue(k->init_, TYPE)) {
+ audio_bug("No host audio driver or missing init_%s", NAME);
return NULL;
}
goto err0;
}
- if (audio_bug(__func__, hw->samples <= 0)) {
- dolog("hw->samples=%zd\n", hw->samples);
+ if (hw->samples <= 0) {
+ audio_bug("hw->samples=%zd", hw->samples);
goto err1;
}
static void glue(audio_mixeng_backend_close_, TYPE)(AudioBackend *be, SW *sw)
{
if (sw) {
- if (audio_bug(__func__, !be)) {
- dolog("backend=%p\n", be);
+ if (!be) {
+ audio_bug("backend=%p", be);
return;
}
AudioMixengBackendClass *k;
AudiodevPerDirectionOptions *pdo;
- if (audio_bug(__func__, !be || !name || !callback_fn || !as)) {
- dolog("backend=%p name=%p callback_fn=%p as=%p\n",
- be, name, callback_fn, as);
+ if (!be || !name || !callback_fn || !as) {
+ audio_bug("backend=%p name=%p callback_fn=%p as=%p",
+ be, name, callback_fn, as);
goto fail;
}
goto fail;
}
- if (audio_bug(__func__, !glue(k->init_, TYPE))) {
- dolog("Can not open `%s' (no host audio driver)\n", name);
+ if (!glue(k->init_, TYPE)) {
+ error_report("audio: Can not open `%s' (no host audio driver)", name);
goto fail;
}