aboutsummaryrefslogtreecommitdiff
path: root/audio/audio_template.h
diff options
context:
space:
mode:
Diffstat (limited to 'audio/audio_template.h')
-rw-r--r--audio/audio_template.h62
1 files changed, 30 insertions, 32 deletions
diff --git a/audio/audio_template.h b/audio/audio_template.h
index 1232bb54db..2562bf5f00 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -36,9 +36,9 @@
#define HWBUF hw->conv_buf
#endif
-static void glue (audio_init_nb_voices_, TYPE) (struct audio_driver *drv)
+static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
+ struct audio_driver *drv)
{
- AudioState *s = &glob_audio_state;
int max_voices = glue (drv->max_voices_, TYPE);
int voice_size = glue (drv->voice_size_, TYPE);
@@ -75,16 +75,16 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
HWBUF = NULL;
}
-static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw)
+static bool glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
{
HWBUF = audio_calloc(__func__, hw->samples, sizeof(struct st_sample));
if (!HWBUF) {
- dolog ("Could not allocate " NAME " buffer (%d samples)\n",
- hw->samples);
- return -1;
+ dolog("Could not allocate " NAME " buffer (%zu samples)\n",
+ hw->samples);
+ return false;
}
- return 0;
+ return true;
}
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
@@ -183,8 +183,8 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)
static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
{
- AudioState *s = &glob_audio_state;
HW *hw = *hwp;
+ AudioState *s = hw->s;
if (!hw->sw_head.lh_first) {
#ifdef DAC
@@ -199,15 +199,14 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
}
}
-static HW *glue (audio_pcm_hw_find_any_, TYPE) (HW *hw)
+static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioState *s, HW *hw)
{
- AudioState *s = &glob_audio_state;
return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first;
}
-static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (HW *hw)
+static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw)
{
- while ((hw = glue (audio_pcm_hw_find_any_, TYPE) (hw))) {
+ while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
if (hw->enabled) {
return hw;
}
@@ -215,12 +214,10 @@ static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (HW *hw)
return NULL;
}
-static HW *glue (audio_pcm_hw_find_specific_, TYPE) (
- HW *hw,
- struct audsettings *as
- )
+static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw,
+ struct audsettings *as)
{
- while ((hw = glue (audio_pcm_hw_find_any_, TYPE) (hw))) {
+ while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
if (audio_pcm_info_eq (&hw->info, as)) {
return hw;
}
@@ -228,10 +225,10 @@ static HW *glue (audio_pcm_hw_find_specific_, TYPE) (
return NULL;
}
-static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
+static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
+ struct audsettings *as)
{
HW *hw;
- AudioState *s = &glob_audio_state;
struct audio_driver *drv = s->drv;
if (!glue (s->nb_hw_voices_, TYPE)) {
@@ -255,6 +252,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
return NULL;
}
+ hw->s = s;
hw->pcm_ops = drv->pcm_ops;
hw->ctl_caps = drv->ctl_caps;
@@ -267,7 +265,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
}
if (audio_bug(__func__, hw->samples <= 0)) {
- dolog ("hw->samples=%d\n", hw->samples);
+ dolog("hw->samples=%zd\n", hw->samples);
goto err1;
}
@@ -281,7 +279,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
[hw->info.swap_endianness]
[audio_bits_to_index (hw->info.bits)];
- if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) {
+ if (!glue(audio_pcm_hw_alloc_resources_, TYPE)(hw)) {
goto err1;
}
@@ -328,33 +326,33 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
abort();
}
-static HW *glue (audio_pcm_hw_add_, TYPE) (struct audsettings *as)
+static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings *as)
{
HW *hw;
- AudioState *s = &glob_audio_state;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
if (pdo->fixed_settings) {
- hw = glue (audio_pcm_hw_add_new_, TYPE) (as);
+ hw = glue(audio_pcm_hw_add_new_, TYPE)(s, as);
if (hw) {
return hw;
}
}
- hw = glue (audio_pcm_hw_find_specific_, TYPE) (NULL, as);
+ hw = glue(audio_pcm_hw_find_specific_, TYPE)(s, NULL, as);
if (hw) {
return hw;
}
- hw = glue (audio_pcm_hw_add_new_, TYPE) (as);
+ hw = glue(audio_pcm_hw_add_new_, TYPE)(s, as);
if (hw) {
return hw;
}
- return glue (audio_pcm_hw_find_any_, TYPE) (NULL);
+ return glue(audio_pcm_hw_find_any_, TYPE)(s, NULL);
}
-static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
+static SW *glue(audio_pcm_create_voice_pair_, TYPE)(
+ AudioState *s,
const char *sw_name,
struct audsettings *as
)
@@ -362,7 +360,6 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
SW *sw;
HW *hw;
struct audsettings hw_as;
- AudioState *s = &glob_audio_state;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
if (pdo->fixed_settings) {
@@ -378,8 +375,9 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
sw_name ? sw_name : "unknown", sizeof (*sw));
goto err1;
}
+ sw->s = s;
- hw = glue (audio_pcm_hw_add_, TYPE) (&hw_as);
+ hw = glue(audio_pcm_hw_add_, TYPE)(s, &hw_as);
if (!hw) {
goto err2;
}
@@ -430,7 +428,7 @@ SW *glue (AUD_open_, TYPE) (
struct audsettings *as
)
{
- AudioState *s = &glob_audio_state;
+ AudioState *s = card->state;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
if (audio_bug(__func__, !card || !name || !callback_fn || !as)) {
@@ -476,7 +474,7 @@ SW *glue (AUD_open_, TYPE) (
}
}
else {
- sw = glue (audio_pcm_create_voice_pair_, TYPE) (name, as);
+ sw = glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as);
if (!sw) {
dolog ("Failed to create voice `%s'\n", name);
return NULL;