[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/51] coreaudio: port to -audiodev config
From: |
Kővágó, Zoltán |
Subject: |
[Qemu-devel] [PATCH 08/51] coreaudio: port to -audiodev config |
Date: |
Thu, 14 Jan 2016 14:45:21 +0100 |
Signed-off-by: Kővágó, Zoltán <address@hidden>
---
audio/audio_legacy.c | 10 ++++++++++
audio/coreaudio.c | 47 ++++++++++-------------------------------------
2 files changed, 20 insertions(+), 37 deletions(-)
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index bc830c5..4be972e 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -58,6 +58,14 @@ SimpleEnvMap alsa_map[] = {
{ /* End of list */ }
};
+SimpleEnvMap coreaudio_map[] = {
+ { "QEMU_COREAUDIO_BUFFER_SIZE", "buffer-len",
+ ENV_TRANSFORM_FRAMES_TO_USECS_OUT },
+ { "QEMU_COREAUDIO_BUFFER_COUNT", "buffer-count" },
+
+ { /* End of list */ }
+};
+
static unsigned long long toull(const char *str)
{
unsigned long long ret;
@@ -228,6 +236,8 @@ static void legacy_opt(const char *drv)
if (strcmp(drv, "alsa") == 0) {
handle_env_opts(opts, alsa_map);
handle_alsa(opts);
+ } else if (strcmp(drv, "coreaudio") == 0) {
+ handle_env_opts(opts, coreaudio_map);
}
}
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index f927c0f..46438a2 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -38,11 +38,6 @@
static int isAtexit;
-typedef struct {
- int buffer_frames;
- int nbuffers;
-} CoreaudioConf;
-
typedef struct coreaudioVoiceOut {
HWVoiceOut hw;
pthread_mutex_t mutex;
@@ -514,7 +509,9 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct
audsettings *as,
int err;
const char *typ = "playback";
AudioValueRange frameRange;
- CoreaudioConf *conf = drv_opaque;
+ Audiodev *dev = drv_opaque;
+ AudiodevPerDirectionOptions *pdo = dev->out;
+ int frames;
/* create mutex */
err = pthread_mutex_init(&core->mutex, NULL);
@@ -545,16 +542,17 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct
audsettings *as,
return -1;
}
- if (frameRange.mMinimum > conf->buffer_frames) {
+ frames = audio_buffer_frames(pdo, as, 11610);
+ if (frameRange.mMinimum > frames) {
core->audioDevicePropertyBufferFrameSize = (UInt32)
frameRange.mMinimum;
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
}
- else if (frameRange.mMaximum < conf->buffer_frames) {
+ else if (frameRange.mMaximum < frames) {
core->audioDevicePropertyBufferFrameSize = (UInt32)
frameRange.mMaximum;
dolog ("warning: Downsizing Buffer Frames to %f\n",
frameRange.mMaximum);
}
else {
- core->audioDevicePropertyBufferFrameSize = conf->buffer_frames;
+ core->audioDevicePropertyBufferFrameSize = frames;
}
/* set Buffer Frame Size */
@@ -575,7 +573,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct
audsettings *as,
"Could not get device buffer frame size\n");
return -1;
}
- hw->samples = conf->nbuffers * core->audioDevicePropertyBufferFrameSize;
+ hw->samples = (pdo->has_buffer_count ? pdo->buffer_count : 4) *
+ core->audioDevicePropertyBufferFrameSize;
/* get StreamFormat */
status = coreaudio_get_streamformat(core->outputDeviceID,
@@ -687,41 +686,16 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd,
...)
return 0;
}
-static CoreaudioConf glob_conf = {
- .buffer_frames = 512,
- .nbuffers = 4,
-};
-
static void *coreaudio_audio_init(Audiodev *dev)
{
- CoreaudioConf *conf = g_malloc(sizeof(CoreaudioConf));
- *conf = glob_conf;
-
atexit(coreaudio_atexit);
- return conf;
+ return dev;
}
static void coreaudio_audio_fini (void *opaque)
{
- g_free(opaque);
}
-static struct audio_option coreaudio_options[] = {
- {
- .name = "BUFFER_SIZE",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.buffer_frames,
- .descr = "Size of the buffer in frames"
- },
- {
- .name = "BUFFER_COUNT",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.nbuffers,
- .descr = "Number of buffers"
- },
- { /* End of list */ }
-};
-
static struct audio_pcm_ops coreaudio_pcm_ops = {
.init_out = coreaudio_init_out,
.fini_out = coreaudio_fini_out,
@@ -733,7 +707,6 @@ static struct audio_pcm_ops coreaudio_pcm_ops = {
struct audio_driver coreaudio_audio_driver = {
.name = "coreaudio",
.descr = "CoreAudio
http://developer.apple.com/audio/coreaudio.html",
- .options = coreaudio_options,
.init = coreaudio_audio_init,
.fini = coreaudio_audio_fini,
.pcm_ops = &coreaudio_pcm_ops,
--
2.7.0
- [Qemu-devel] [PATCH 00/51] audio 5.1 patches, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 03/51] qapi: qapi for audio backends, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 01/51] qapi: support implicit structs in OptsVisitor, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 02/51] qapi: support nested structs in OptsVisitor, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 05/51] audio: -audiodev command line option: documentation, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 04/51] audio: use qapi AudioFormat instead of audfmt_e, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 08/51] coreaudio: port to -audiodev config,
Kővágó, Zoltán <=
- [Qemu-devel] [PATCH 13/51] sdlaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 16/51] audio: -audiodev command line option: cleanup, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 15/51] wavaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 10/51] noaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 11/51] ossaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 07/51] alsaaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 14/51] spiceaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 09/51] dsoundaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 12/51] paaudio: port to -audiodev config, Kővágó, Zoltán, 2016/01/14
- [Qemu-devel] [PATCH 06/51] audio: -audiodev command line option basic implementation, Kővágó, Zoltán, 2016/01/14