summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKővágó, Zoltán <dirty.ice.hu@gmail.com>2015-06-03 23:03:47 +0200
committerGerd Hoffmann <kraxel@redhat.com>2015-06-15 12:42:47 +0200
commit5706db1deb061ee9affdcea81e59c4c2cad7c41e (patch)
tree95bcad953310cc46fc8924cb52369b862cd31fb0
parent307119e7d948bcdb5918fd762153deda471e695b (diff)
downloadqemu-5706db1deb061ee9affdcea81e59c4c2cad7c41e.tar.gz
qemu-5706db1deb061ee9affdcea81e59c4c2cad7c41e.tar.bz2
qemu-5706db1deb061ee9affdcea81e59c4c2cad7c41e.zip
audio: expose drv_opaque to init_out and init_in
Currently the opaque pointer returned by audio_driver's init is only exposed to the driver's fini, but not to audio_pcm_ops. This way if someone wants to share a variable with the driver and the pcm, he must use global variables. This patch fixes it by adding a third parameter to audio_pcm_op's init_out and init_in. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--audio/alsaaudio.c5
-rw-r--r--audio/audio_int.h4
-rw-r--r--audio/audio_template.h2
-rw-r--r--audio/coreaudio.c3
-rw-r--r--audio/dsound_template.h6
-rw-r--r--audio/noaudio.c4
-rw-r--r--audio/ossaudio.c5
-rw-r--r--audio/paaudio.c5
-rw-r--r--audio/sdlaudio.c3
-rw-r--r--audio/spiceaudio.c5
-rw-r--r--audio/wavaudio.c5
11 files changed, 27 insertions, 20 deletions
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index ed7655de86..5a5bb1445d 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -807,7 +807,8 @@ static void alsa_fini_out (HWVoiceOut *hw)
alsa->pcm_buf = NULL;
}
-static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
struct alsa_params_req req;
@@ -916,7 +917,7 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...)
return -1;
}
-static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
+static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 0eba44f5a0..566df5edf4 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -156,13 +156,13 @@ struct audio_driver {
};
struct audio_pcm_ops {
- int (*init_out)(HWVoiceOut *hw, struct audsettings *as);
+ int (*init_out)(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque);
void (*fini_out)(HWVoiceOut *hw);
int (*run_out) (HWVoiceOut *hw, int live);
int (*write) (SWVoiceOut *sw, void *buf, int size);
int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
- int (*init_in) (HWVoiceIn *hw, struct audsettings *as);
+ int (*init_in) (HWVoiceIn *hw, struct audsettings *as, void *drv_opaque);
void (*fini_in) (HWVoiceIn *hw);
int (*run_in) (HWVoiceIn *hw);
int (*read) (SWVoiceIn *sw, void *buf, int size);
diff --git a/audio/audio_template.h b/audio/audio_template.h
index 584e536fac..f716d97c7e 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -262,7 +262,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
#ifdef DAC
QLIST_INIT (&hw->cap_head);
#endif
- if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) {
+ if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) {
goto err0;
}
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index 5964c62eaf..20346bce6e 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -287,7 +287,8 @@ static int coreaudio_write (SWVoiceOut *sw, void *buf, int len)
return audio_pcm_sw_write (sw, buf, len);
}
-static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
OSStatus status;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
diff --git a/audio/dsound_template.h b/audio/dsound_template.h
index 8b37d16a8c..98276fb019 100644
--- a/audio/dsound_template.h
+++ b/audio/dsound_template.h
@@ -174,9 +174,11 @@ static void dsound_fini_out (HWVoiceOut *hw)
}
#ifdef DSBTYPE_IN
-static int dsound_init_in (HWVoiceIn *hw, struct audsettings *as)
+static int dsound_init_in(HWVoiceIn *hw, struct audsettings *as,
+ void *drv_opaque)
#else
-static int dsound_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
#endif
{
int err;
diff --git a/audio/noaudio.c b/audio/noaudio.c
index cb386620ae..50db1f344b 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -63,7 +63,7 @@ static int no_write (SWVoiceOut *sw, void *buf, int len)
return audio_pcm_sw_write (sw, buf, len);
}
-static int no_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
{
audio_pcm_init_info (&hw->info, as);
hw->samples = 1024;
@@ -82,7 +82,7 @@ static int no_ctl_out (HWVoiceOut *hw, int cmd, ...)
return 0;
}
-static int no_init_in (HWVoiceIn *hw, struct audsettings *as)
+static int no_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
{
audio_pcm_init_info (&hw->info, as);
hw->samples = 1024;
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index b9c6b30ca1..27c6bc625e 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -510,7 +510,8 @@ static void oss_fini_out (HWVoiceOut *hw)
}
}
-static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
OSSVoiceOut *oss = (OSSVoiceOut *) hw;
struct oss_params req, obt;
@@ -677,7 +678,7 @@ static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...)
return 0;
}
-static int oss_init_in (HWVoiceIn *hw, struct audsettings *as)
+static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
{
OSSVoiceIn *oss = (OSSVoiceIn *) hw;
struct oss_params req, obt;
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 90ff24500b..bdf6cd52e1 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -534,7 +534,8 @@ fail:
return NULL;
}
-static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
int error;
static pa_sample_spec ss;
@@ -601,7 +602,7 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
return -1;
}
-static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as)
+static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
{
int error;
static pa_sample_spec ss;
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index d24daa5ead..b95a7e0ab4 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -332,7 +332,8 @@ static void sdl_fini_out (HWVoiceOut *hw)
sdl_close (&glob_sdl);
}
-static int sdl_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
SDLAudioState *s = &glob_sdl;
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index 7b79bedca2..5c6f726757 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -115,7 +115,8 @@ static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)
/* playback */
-static int line_out_init (HWVoiceOut *hw, struct audsettings *as)
+static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw);
struct audsettings settings;
@@ -243,7 +244,7 @@ static int line_out_ctl (HWVoiceOut *hw, int cmd, ...)
/* record */
-static int line_in_init (HWVoiceIn *hw, struct audsettings *as)
+static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
{
SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
struct audsettings settings;
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 6846a1a9f7..09083da2cf 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -105,7 +105,8 @@ static void le_store (uint8_t *buf, uint32_t val, int len)
}
}
-static int wav_init_out (HWVoiceOut *hw, struct audsettings *as)
+static int wav_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
int bits16 = 0, stereo = 0;
@@ -117,8 +118,6 @@ static int wav_init_out (HWVoiceOut *hw, struct audsettings *as)
};
struct audsettings wav_as = conf.settings;
- (void) as;
-
stereo = wav_as.nchannels == 2;
switch (wav_as.fmt) {
case AUD_FMT_S8: