Skip to contentSkip to conversation

Use C99 struct initializers in audio/*

PATCH Superseded Juan Quintela 5 participants 22 messages Jul 27, 2009 – Jul 28, 2009

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Use C99 struct initializers in audio/*

Hi

Cleanup all audio/* using C99 struct initializers, remove INIT_FIELD() once there.

Later, Juan.

Juan Quintela (4):
Use proper struct initializers and remove INIT_FIELD() macro use C99 initializers for audio_pcm_ops
Use C99 initializers for audio_option
use C99 initializers for all audio/*

 audio/alsaaudio.c   |  141 ++++++++++++++++++++++++++++------------------
 audio/audio.c       |  109 ++++++++++++++++++++++--------------
 audio/audio_int.h   |    2 -
 audio/coreaudio.c   |   57 ++++++++++---------
 audio/dsoundaudio.c |  139 ++++++++++++++++++++++++++++------------------
 audio/esdaudio.c    |   87 ++++++++++++++++-------------
 audio/fmodaudio.c   |  154 ++++++++++++++++++++++++++++++++------------------
 audio/noaudio.c     |   44 +++++++-------
 audio/ossaudio.c    |   99 ++++++++++++++++++++------------
 audio/paaudio.c     |   94 +++++++++++++++++--------------
 audio/sdlaudio.c    |   51 ++++++++---------
 audio/wavaudio.c    |   83 ++++++++++++++-------------
 12 files changed, 617 insertions(+), 443 deletions(-)
#1 lore raw

PATCH 1/4 Use proper struct initializers and remove INIT_FIELD() macro

---
 audio/alsaaudio.c   |   22 +++++++++++-----------
 audio/audio_int.h   |    2 --
 audio/coreaudio.c   |   23 +++++++++++------------
 audio/dsoundaudio.c |   23 +++++++++++------------
 audio/esdaudio.c    |   23 +++++++++++------------
 audio/fmodaudio.c   |   22 +++++++++++-----------
 audio/noaudio.c     |   22 +++++++++++-----------
 audio/ossaudio.c    |   22 +++++++++++-----------
 audio/paaudio.c     |   22 +++++++++++-----------
 audio/sdlaudio.c    |   22 +++++++++++-----------
 audio/wavaudio.c    |   23 +++++++++++------------
 11 files changed, 110 insertions(+), 116 deletions(-)
audio/alsaaudio.c +11 -11
index d0b7cd0..c1f4dd4 100644
@@ -938,15 +938,15 @@ static struct audio_pcm_ops alsa_pcm_ops = {
 };
 
 struct audio_driver alsa_audio_driver = {
-    INIT_FIELD (name           = ) "alsa",
-    INIT_FIELD (descr          = ) "ALSA http://www.alsa-project.org",
-    INIT_FIELD (options        = ) alsa_options,
-    INIT_FIELD (init           = ) alsa_audio_init,
-    INIT_FIELD (fini           = ) alsa_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &alsa_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (ALSAVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (ALSAVoiceIn)
+    .name = "alsa",
+    .descr = "ALSA http://www.alsa-project.org",
+    .options = alsa_options,
+    .init = alsa_audio_init,
+    .fini = alsa_audio_fini,
+    .pcm_ops = &alsa_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (ALSAVoiceOut),
+    .voice_size_in = sizeof (ALSAVoiceIn)
 };
audio/audio_int.h +0 -2
index 0abed38..f3cd0be 100644
@@ -232,11 +232,9 @@ static inline int audio_ring_dist (int dst, int src, int len)
 
 #if defined __GNUC__
 #define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
-#define INIT_FIELD(f) . f
 #define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
 #else
 #define GCC_ATTR /**/
-#define INIT_FIELD(f) /**/
 #define GCC_FMT_ATTR(n, m)
 #endif
 
audio/coreaudio.c +11 -12
index 9671429..8276636 100644
@@ -535,16 +535,15 @@ static struct audio_pcm_ops coreaudio_pcm_ops = {
 };
 
 struct audio_driver coreaudio_audio_driver = {
-    INIT_FIELD (name           = ) "coreaudio",
-    INIT_FIELD (descr          = )
-    "CoreAudio http://developer.apple.com/audio/coreaudio.html",
-    INIT_FIELD (options        = ) coreaudio_options,
-    INIT_FIELD (init           = ) coreaudio_audio_init,
-    INIT_FIELD (fini           = ) coreaudio_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &coreaudio_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) 1,
-    INIT_FIELD (max_voices_in  = ) 0,
-    INIT_FIELD (voice_size_out = ) sizeof (coreaudioVoiceOut),
-    INIT_FIELD (voice_size_in  = ) 0
+    .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,
+    .can_be_default = 1,
+    .max_voices_out = 1,
+    .max_voices_in = 0,
+    .voice_size_out = sizeof (coreaudioVoiceOut),
+    .voice_size_in = 0
 };
audio/dsoundaudio.c +11 -12
index a78c856..bbda03c 100644
@@ -1073,16 +1073,15 @@ static struct audio_pcm_ops dsound_pcm_ops = {
 };
 
 struct audio_driver dsound_audio_driver = {
-    INIT_FIELD (name           = ) "dsound",
-    INIT_FIELD (descr          = )
-    "DirectSound http://wikipedia.org/wiki/DirectSound",
-    INIT_FIELD (options        = ) dsound_options,
-    INIT_FIELD (init           = ) dsound_audio_init,
-    INIT_FIELD (fini           = ) dsound_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &dsound_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) 1,
-    INIT_FIELD (voice_size_out = ) sizeof (DSoundVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (DSoundVoiceIn)
+    .name = "dsound",
+    .descr = "DirectSound http://wikipedia.org/wiki/DirectSound",
+    .options = dsound_options,
+    .init = dsound_audio_init,
+    .fini = dsound_audio_fini,
+    .pcm_ops = &dsound_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = 1,
+    .voice_size_out = sizeof (DSoundVoiceOut),
+    .oice_size_in = sizeof (DSoundVoiceIn)
 };
audio/esdaudio.c +11 -12
index 0102c5a..105e94e 100644
@@ -581,16 +581,15 @@ static struct audio_pcm_ops qesd_pcm_ops = {
 };
 
 struct audio_driver esd_audio_driver = {
-    INIT_FIELD (name           = ) "esd",
-    INIT_FIELD (descr          = )
-    "http://en.wikipedia.org/wiki/Esound",
-    INIT_FIELD (options        = ) qesd_options,
-    INIT_FIELD (init           = ) qesd_audio_init,
-    INIT_FIELD (fini           = ) qesd_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &qesd_pcm_ops,
-    INIT_FIELD (can_be_default = ) 0,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (ESDVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (ESDVoiceIn)
+    .name = "esd",
+    .descr = "http://en.wikipedia.org/wiki/Esound",
+    .options = qesd_options,
+    .init = qesd_audio_init,
+    .fini = qesd_audio_fini,
+    .pcm_ops = &qesd_pcm_ops,
+    .can_be_default = 0,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (ESDVoiceOut),
+    .voice_size_in = sizeof (ESDVoiceIn)
 };
audio/fmodaudio.c +11 -11
index 0becd3b..534817e 100644
@@ -672,15 +672,15 @@ static struct audio_pcm_ops fmod_pcm_ops = {
 };
 
 struct audio_driver fmod_audio_driver = {
-    INIT_FIELD (name           = ) "fmod",
-    INIT_FIELD (descr          = ) "FMOD 3.xx http://www.fmod.org",
-    INIT_FIELD (options        = ) fmod_options,
-    INIT_FIELD (init           = ) fmod_audio_init,
-    INIT_FIELD (fini           = ) fmod_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &fmod_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (FMODVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (FMODVoiceIn)
+    .name = "fmod",
+    .descr = "FMOD 3.xx http://www.fmod.org",
+    .options = fmod_options,
+    .init = fmod_audio_init,
+    .fini = fmod_audio_fini,
+    .pcm_ops = &fmod_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (FMODVoiceOut),
+    .voice_size_in = sizeof (FMODVoiceIn)
 };
audio/noaudio.c +11 -11
index 9432413..e798be1 100644
@@ -160,15 +160,15 @@ static struct audio_pcm_ops no_pcm_ops = {
 };
 
 struct audio_driver no_audio_driver = {
-    INIT_FIELD (name           = ) "none",
-    INIT_FIELD (descr          = ) "Timer based audio emulation",
-    INIT_FIELD (options        = ) NULL,
-    INIT_FIELD (init           = ) no_audio_init,
-    INIT_FIELD (fini           = ) no_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &no_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (NoVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (NoVoiceIn)
+    .name = "none",
+    .descr = "Timer based audio emulation",
+    .options = NULL,
+    .init = no_audio_init,
+    .fini = no_audio_fini,
+    .pcm_ops = &no_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (NoVoiceOut),
+    .voice_size_in = sizeof (NoVoiceIn)
 };
audio/ossaudio.c +11 -11
index 0236c2e..9e339d6 100644
@@ -766,15 +766,15 @@ static struct audio_pcm_ops oss_pcm_ops = {
 };
 
 struct audio_driver oss_audio_driver = {
-    INIT_FIELD (name           = ) "oss",
-    INIT_FIELD (descr          = ) "OSS http://www.opensound.com",
-    INIT_FIELD (options        = ) oss_options,
-    INIT_FIELD (init           = ) oss_audio_init,
-    INIT_FIELD (fini           = ) oss_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &oss_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (OSSVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (OSSVoiceIn)
+    .name = "oss",
+    .descr = "OSS http://www.opensound.com",
+    .options = oss_options,
+    .init = oss_audio_init,
+    .fini = oss_audio_fini,
+    .pcm_ops = &oss_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (OSSVoiceOut),
+    .voice_size_in = sizeof (OSSVoiceIn)
 };
audio/paaudio.c +11 -11
index a50fccc..10dc68c 100644
@@ -501,15 +501,15 @@ static struct audio_pcm_ops qpa_pcm_ops = {
 };
 
 struct audio_driver pa_audio_driver = {
-    INIT_FIELD (name           = ) "pa",
-    INIT_FIELD (descr          = ) "http://www.pulseaudio.org/",
-    INIT_FIELD (options        = ) qpa_options,
-    INIT_FIELD (init           = ) qpa_audio_init,
-    INIT_FIELD (fini           = ) qpa_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &qpa_pcm_ops,
-    INIT_FIELD (can_be_default = ) 0,
-    INIT_FIELD (max_voices_out = ) INT_MAX,
-    INIT_FIELD (max_voices_in  = ) INT_MAX,
-    INIT_FIELD (voice_size_out = ) sizeof (PAVoiceOut),
-    INIT_FIELD (voice_size_in  = ) sizeof (PAVoiceIn)
+    .name = "pa",
+    .descr = "http://www.pulseaudio.org/",
+    .options = qpa_options,
+    .init = qpa_audio_init,
+    .fini = qpa_audio_fini,
+    .pcm_ops = &qpa_pcm_ops,
+    .can_be_default = 0,
+    .max_voices_out = INT_MAX,
+    .max_voices_in = INT_MAX,
+    .voice_size_out = sizeof (PAVoiceOut),
+    .voice_size_in = sizeof (PAVoiceIn)
 };
audio/sdlaudio.c +11 -11
index 5d6fc24..13bcf93 100644
@@ -440,15 +440,15 @@ static struct audio_pcm_ops sdl_pcm_ops = {
 };
 
 struct audio_driver sdl_audio_driver = {
-    INIT_FIELD (name           = ) "sdl",
-    INIT_FIELD (descr          = ) "SDL http://www.libsdl.org",
-    INIT_FIELD (options        = ) sdl_options,
-    INIT_FIELD (init           = ) sdl_audio_init,
-    INIT_FIELD (fini           = ) sdl_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &sdl_pcm_ops,
-    INIT_FIELD (can_be_default = ) 1,
-    INIT_FIELD (max_voices_out = ) 1,
-    INIT_FIELD (max_voices_in  = ) 0,
-    INIT_FIELD (voice_size_out = ) sizeof (SDLVoiceOut),
-    INIT_FIELD (voice_size_in  = ) 0
+    .name = "sdl",
+    .descr = "SDL http://www.libsdl.org",
+    .options = sdl_options,
+    .init = sdl_audio_init,
+    .fini = sdl_audio_fini,
+    .pcm_ops = &sdl_pcm_ops,
+    .can_be_default = 1,
+    .max_voices_out = 1,
+    .max_voices_in = 0,
+    .voice_size_out = sizeof (SDLVoiceOut),
+    .voice_size_in = 0
 };
audio/wavaudio.c +11 -12
index e50dac2..55b3440 100644
@@ -248,16 +248,15 @@ static struct audio_pcm_ops wav_pcm_ops = {
 };
 
 struct audio_driver wav_audio_driver = {
-    INIT_FIELD (name           = ) "wav",
-    INIT_FIELD (descr          = )
-    "WAV renderer http://wikipedia.org/wiki/WAV",
-    INIT_FIELD (options        = ) wav_options,
-    INIT_FIELD (init           = ) wav_audio_init,
-    INIT_FIELD (fini           = ) wav_audio_fini,
-    INIT_FIELD (pcm_ops        = ) &wav_pcm_ops,
-    INIT_FIELD (can_be_default = ) 0,
-    INIT_FIELD (max_voices_out = ) 1,
-    INIT_FIELD (max_voices_in  = ) 0,
-    INIT_FIELD (voice_size_out = ) sizeof (WAVVoiceOut),
-    INIT_FIELD (voice_size_in  = ) 0
+    .name = "wav",
+    .descr = "WAV renderer http://wikipedia.org/wiki/WAV",
+    .options = wav_options,
+    .init = wav_audio_init,
+    .fini = wav_audio_fini,
+    .pcm_ops = &wav_pcm_ops,
+    .can_be_default = 0,
+    .max_voices_out = 1,
+    .max_voices_in = 0,
+    .voice_size_out = sizeof (WAVVoiceOut),
+    .voice_size_in = 0
 };
Signature · 1 line
1.6.2.5
#9 lore raw

PATCH 2/4 use C99 initializers for audio_pcm_ops

In reply to Juan Quintela
---
 audio/alsaaudio.c   |   22 +++++++++++-----------
 audio/coreaudio.c   |   16 +++++-----------
 audio/dsoundaudio.c |   22 +++++++++++-----------
 audio/esdaudio.c    |   22 +++++++++++-----------
 audio/fmodaudio.c   |   22 +++++++++++-----------
 audio/noaudio.c     |   22 +++++++++++-----------
 audio/ossaudio.c    |   22 +++++++++++-----------
 audio/paaudio.c     |   21 +++++++++++----------
 audio/sdlaudio.c    |   16 +++++-----------
 audio/wavaudio.c    |   16 +++++-----------
 10 files changed, 92 insertions(+), 109 deletions(-)
audio/alsaaudio.c +11 -11
index c1f4dd4..4954683 100644
@@ -924,17 +924,17 @@ static struct audio_option alsa_options[] = {
 };
 
 static struct audio_pcm_ops alsa_pcm_ops = {
-    alsa_init_out,
-    alsa_fini_out,
-    alsa_run_out,
-    alsa_write,
-    alsa_ctl_out,
-
-    alsa_init_in,
-    alsa_fini_in,
-    alsa_run_in,
-    alsa_read,
-    alsa_ctl_in
+    .init_out = alsa_init_out,
+    .fini_out = alsa_fini_out,
+    .run_out = alsa_run_out,
+    .write = alsa_write,
+    .ctl_out = alsa_ctl_out,
+
+    .init_in = alsa_init_in,
+    .fini_in = alsa_fini_in,
+    .run_in = alsa_run_in,
+    .read = alsa_read,
+    .ctl_in = alsa_ctl_in
 };
 
 struct audio_driver alsa_audio_driver = {
audio/coreaudio.c +5 -11
index 8276636..12d3e2d 100644
@@ -521,17 +521,11 @@ static struct audio_option coreaudio_options[] = {
 };
 
 static struct audio_pcm_ops coreaudio_pcm_ops = {
-    coreaudio_init_out,
-    coreaudio_fini_out,
-    coreaudio_run_out,
-    coreaudio_write,
-    coreaudio_ctl_out,
-
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    .init_out = coreaudio_init_out,
+    .fini_out = coreaudio_fini_out,
+    .run_out = coreaudio_run_out,
+    .write = coreaudio_write,
+    .ctl_out = coreaudio_ctl_out
 };
 
 struct audio_driver coreaudio_audio_driver = {
audio/dsoundaudio.c +11 -11
index bbda03c..cc99368 100644
@@ -1059,17 +1059,17 @@ static struct audio_option dsound_options[] = {
 };
 
 static struct audio_pcm_ops dsound_pcm_ops = {
-    dsound_init_out,
-    dsound_fini_out,
-    dsound_run_out,
-    dsound_write,
-    dsound_ctl_out,
-
-    dsound_init_in,
-    dsound_fini_in,
-    dsound_run_in,
-    dsound_read,
-    dsound_ctl_in
+    .init_out = dsound_init_out,
+    .fini_out = dsound_fini_out,
+    .run_out = dsound_run_out,
+    .write = dsound_write,
+    .ctl_out = dsound_ctl_out,
+
+    .init_in = dsound_init_in,
+    .fini_in = dsound_fini_in,
+    .run_in = dsound_run_in,
+    .read = dsound_read,
+    .ctl_in = dsound_ctl_in
 };
 
 struct audio_driver dsound_audio_driver = {
audio/esdaudio.c +11 -11
index 105e94e..b538cb6 100644
@@ -567,17 +567,17 @@ struct audio_option qesd_options[] = {
 };
 
 static struct audio_pcm_ops qesd_pcm_ops = {
-    qesd_init_out,
-    qesd_fini_out,
-    qesd_run_out,
-    qesd_write,
-    qesd_ctl_out,
-
-    qesd_init_in,
-    qesd_fini_in,
-    qesd_run_in,
-    qesd_read,
-    qesd_ctl_in,
+    .init_out = qesd_init_out,
+    .fini_out = qesd_fini_out,
+    .run_out = qesd_run_out,
+    .write = qesd_write,
+    .ctl_out = qesd_ctl_out,
+
+    .init_in = qesd_init_in,
+    .fini_in = qesd_fini_in,
+    .run_in = qesd_run_in,
+    .read = qesd_read,
+    .ctl_in = qesd_ctl_in,
 };
 
 struct audio_driver esd_audio_driver = {
audio/fmodaudio.c +11 -11
index 534817e..aa7f7fb 100644
@@ -658,17 +658,17 @@ static struct audio_option fmod_options[] = {
 };
 
 static struct audio_pcm_ops fmod_pcm_ops = {
-    fmod_init_out,
-    fmod_fini_out,
-    fmod_run_out,
-    fmod_write,
-    fmod_ctl_out,
-
-    fmod_init_in,
-    fmod_fini_in,
-    fmod_run_in,
-    fmod_read,
-    fmod_ctl_in
+    .init_out = fmod_init_out,
+    .fini_out = fmod_fini_out,
+    .run_out = fmod_run_out,
+    .write = fmod_write,
+    .ctl_out = fmod_ctl_out,
+
+    .init_in = fmod_init_in,
+    .fini_in = fmod_fini_in,
+    .run_in = fmod_run_in,
+    .read = fmod_read,
+    .ctl_in = fmod_ctl_in
 };
 
 struct audio_driver fmod_audio_driver = {
audio/noaudio.c +11 -11
index e798be1..9ef5407 100644
@@ -146,17 +146,17 @@ static void no_audio_fini (void *opaque)
 }
 
 static struct audio_pcm_ops no_pcm_ops = {
-    no_init_out,
-    no_fini_out,
-    no_run_out,
-    no_write,
-    no_ctl_out,
-
-    no_init_in,
-    no_fini_in,
-    no_run_in,
-    no_read,
-    no_ctl_in
+    .init_out = no_init_out,
+    .fini_out = no_fini_out,
+    .run_out = no_run_out,
+    .write = no_write,
+    .ctl_out = no_ctl_out,
+
+    .init_in = no_init_in,
+    .fini_in = no_fini_in,
+    .run_in = no_run_in,
+    .read = no_read,
+    .ctl_in = no_ctl_in
 };
 
 struct audio_driver no_audio_driver = {
audio/ossaudio.c +11 -11
index 9e339d6..387852b 100644
@@ -752,17 +752,17 @@ static struct audio_option oss_options[] = {
 };
 
 static struct audio_pcm_ops oss_pcm_ops = {
-    oss_init_out,
-    oss_fini_out,
-    oss_run_out,
-    oss_write,
-    oss_ctl_out,
-
-    oss_init_in,
-    oss_fini_in,
-    oss_run_in,
-    oss_read,
-    oss_ctl_in
+    .init_out = oss_init_out,
+    .fini_out = oss_fini_out,
+    .run_out = oss_run_out,
+    .write = oss_write,
+    .ctl_out = oss_ctl_out,
+
+    .init_in = oss_init_in,
+    .fini_in = oss_fini_in,
+    .run_in = oss_run_in,
+    .read = oss_read,
+    .ctl_in = oss_ctl_in
 };
 
 struct audio_driver oss_audio_driver = {
audio/paaudio.c +11 -10
index 10dc68c..6a96e14 100644
@@ -488,16 +488,17 @@ struct audio_option qpa_options[] = {
 };
 
 static struct audio_pcm_ops qpa_pcm_ops = {
-    qpa_init_out,
-    qpa_fini_out,
-    qpa_run_out,
-    qpa_write,
-    qpa_ctl_out,
-    qpa_init_in,
-    qpa_fini_in,
-    qpa_run_in,
-    qpa_read,
-    qpa_ctl_in
+    .init_out = qpa_init_out,
+    .fini_out = qpa_fini_out,
+    .run_out = qpa_run_out,
+    .write = qpa_write,
+    .ctl_out = qpa_ctl_out,
+
+    .init_in = qpa_init_in,
+    .fini_in = qpa_fini_in,
+    .run_in = qpa_run_in,
+    .read = qpa_read,
+    .ctl_in = qpa_ctl_in
 };
 
 struct audio_driver pa_audio_driver = {
audio/sdlaudio.c +5 -11
index 13bcf93..3d3f726 100644
@@ -426,17 +426,11 @@ static struct audio_option sdl_options[] = {
 };
 
 static struct audio_pcm_ops sdl_pcm_ops = {
-    sdl_init_out,
-    sdl_fini_out,
-    sdl_run_out,
-    sdl_write_out,
-    sdl_ctl_out,
-
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    .init_out = sdl_init_out,
+    .fini_out = sdl_fini_out,
+    .run_out = sdl_run_out,
+    .write = sdl_write_out,
+    .ctl_out = sdl_ctl_out,
 };
 
 struct audio_driver sdl_audio_driver = {
audio/wavaudio.c +5 -11
index 55b3440..76873d9 100644
@@ -234,17 +234,11 @@ static struct audio_option wav_options[] = {
 };
 
 static struct audio_pcm_ops wav_pcm_ops = {
-    wav_init_out,
-    wav_fini_out,
-    wav_run_out,
-    wav_write_out,
-    wav_ctl_out,
-
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    .init_out = wav_init_out,
+    .fini_out = wav_fini_out,
+    .run_out = wav_run_out,
+    .write = wav_write_out,
+    .ctl_out = wav_ctl_out,
 };
 
 struct audio_driver wav_audio_driver = {
Signature · 1 line
1.6.2.5
#11 lore raw

PATCH 3/4 Use C99 initializers for audio_option

In reply to Juan Quintela
---
 audio/alsaaudio.c   |   88 ++++++++++++++++++++++++++--------------
 audio/audio.c       |  109 ++++++++++++++++++++++++++++++++-------------------
 audio/coreaudio.c   |   18 ++++++--
 audio/dsoundaudio.c |   74 +++++++++++++++++++++++++----------
 audio/esdaudio.c    |   36 +++++++++++------
 audio/fmodaudio.c   |   47 +++++++++++++++-------
 audio/ossaudio.c    |   46 +++++++++++++++------
 audio/paaudio.c     |   44 +++++++++++++-------
 audio/sdlaudio.c    |   11 ++++-
 audio/wavaudio.c    |   35 +++++++++++------
 10 files changed, 339 insertions(+), 169 deletions(-)
audio/alsaaudio.c +57 -31
index 4954683..fcaf84f 100644
@@ -890,37 +890,63 @@ static void alsa_audio_fini (void *opaque)
 }
 
 static struct audio_option alsa_options[] = {
-    {"DAC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_out,
-     "DAC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
-    {"DAC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_out,
-     "DAC period size (0 to go with system default)",
-     &conf.period_size_out_overridden, 0},
-    {"DAC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_out,
-     "DAC buffer size (0 to go with system default)",
-     &conf.buffer_size_out_overridden, 0},
-
-    {"ADC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_in,
-     "ADC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
-    {"ADC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_in,
-     "ADC period size (0 to go with system default)",
-     &conf.period_size_in_overridden, 0},
-    {"ADC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_in,
-     "ADC buffer size (0 to go with system default)",
-     &conf.buffer_size_in_overridden, 0},
-
-    {"THRESHOLD", AUD_OPT_INT, &conf.threshold,
-     "(undocumented)", NULL, 0},
-
-    {"DAC_DEV", AUD_OPT_STR, &conf.pcm_name_out,
-     "DAC device name (for instance dmix)", NULL, 0},
-
-    {"ADC_DEV", AUD_OPT_STR, &conf.pcm_name_in,
-     "ADC device name", NULL, 0},
-
-    {"VERBOSE", AUD_OPT_BOOL, &conf.verbose,
-     "Behave in a more verbose way", NULL, 0},
-
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "DAC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_out,
+        .descr = "DAC period/buffer size in microseconds (otherwise in frames)"
+    },{
+        .name = "DAC_PERIOD_SIZE",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.period_size_out,
+        .descr = "DAC period size (0 to go with system default)",
+        .overriddenp = &conf.period_size_out_overridden
+    },{
+        .name = "DAC_BUFFER_SIZE",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.buffer_size_out,
+        .descr = "DAC buffer size (0 to go with system default)",
+        .overriddenp = &conf.buffer_size_out_overridden
+    },{
+        .name = "ADC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_in,
+        .descr = "ADC period/buffer size in microseconds (otherwise in frames)"
+    },{
+        .name = "ADC_PERIOD_SIZE",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.period_size_in,
+        .descr = "ADC period size (0 to go with system default)",
+        .overriddenp = &conf.period_size_in_overridden
+    },{
+        .name = "ADC_BUFFER_SIZE",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.buffer_size_in,
+        .descr = "ADC buffer size (0 to go with system default)",
+        .overriddenp = &conf.buffer_size_in_overridden
+    },{
+        .name = "THRESHOLD",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.threshold,
+        .descr = "(undocumented)"
+    },{
+        .name = "DAC_DEV",
+        .tag = AUD_OPT_STR,
+        .valp = &conf.pcm_name_out,
+        .descr = "DAC device name (for instance dmix)"
+    },{
+        .name = "ADC_DEV",
+        .tag = AUD_OPT_STR,
+        .valp = &conf.pcm_name_in,
+        .descr = "ADC device name"
+    },{
+        .name = "VERBOSE",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.verbose,
+        .descr = "Behave in a more verbose way"
+    },{
+        /* End of list */
+    }
 };
 
 static struct audio_pcm_ops alsa_pcm_ops = {
audio/audio.c +68 -41

117 lines not on this page · raw message

audio/coreaudio.c +13 -5
index 12d3e2d..945754f 100644
@@ -513,11 +513,19 @@ static void coreaudio_audio_fini (void *opaque)
 }
 
 static struct audio_option coreaudio_options[] = {
-    {"BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_frames,
-     "Size of the buffer in frames", NULL, 0},
-    {"BUFFER_COUNT", AUD_OPT_INT, &conf.nbuffers,
-     "Number of buffers", NULL, 0},
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "BUFFER_SIZE",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.buffer_frames,
+        .descr = "Size of the buffer in frames"
+    },{
+        .name = "BUFFER_COUNT",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.nbuffers,
+        .descr = "Number of buffers"
+    },{
+        /* End of list */
+    }
 };
 
 static struct audio_pcm_ops coreaudio_pcm_ops = {
audio/dsoundaudio.c +53 -21

80 lines not on this page · raw message

audio/esdaudio.c +23 -13
index b538cb6..002e263 100644
@@ -551,19 +551,29 @@ static void qesd_audio_fini (void *opaque)
 }
 
 struct audio_option qesd_options[] = {
-    {"SAMPLES", AUD_OPT_INT, &conf.samples,
-     "buffer size in samples", NULL, 0},
-
-    {"DIVISOR", AUD_OPT_INT, &conf.divisor,
-     "threshold divisor", NULL, 0},
-
-    {"DAC_HOST", AUD_OPT_STR, &conf.dac_host,
-     "playback host", NULL, 0},
-
-    {"ADC_HOST", AUD_OPT_STR, &conf.adc_host,
-     "capture host", NULL, 0},
-
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "SAMPLES",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.samples,
+        .descr = "buffer size in samples"
+    },{
+        .name = "DIVISOR",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.divisor,
+        .descr = "threshold divisor"
+    },{
+        .name = "DAC_HOST",
+        .tag = AUD_OPT_STR,
+        .valp = &conf.dac_host,
+        .descr = "playback host"
+    },{
+        .name = "ADC_HOST",
+        .tag = AUD_OPT_STR,
+        .valp = &conf.adc_host,
+        .descr = "capture host"
+    },{
+        /* End of list */
+    }
 };
 
 static struct audio_pcm_ops qesd_pcm_ops = {
audio/fmodaudio.c +33 -14

55 lines not on this page · raw message

audio/ossaudio.c +33 -13

52 lines not on this page · raw message

audio/paaudio.c +28 -16

50 lines not on this page · raw message

audio/sdlaudio.c +8 -3
index 3d3f726..4e4544f 100644
@@ -420,9 +420,14 @@ static void sdl_audio_fini (void *opaque)
 }
 
 static struct audio_option sdl_options[] = {
-    {"SAMPLES", AUD_OPT_INT, &conf.nb_samples,
-     "Size of SDL buffer in samples", NULL, 0},
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "SAMPLES",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.nb_samples,
+        .descr = "Size of SDL buffer in samples"
+    },{
+        /* End of list */
+    }
 };
 
 static struct audio_pcm_ops sdl_pcm_ops = {
audio/wavaudio.c +23 -12
index 76873d9..6c11359 100644
@@ -219,18 +219,29 @@ static void wav_audio_fini (void *opaque)
 }
 
 static struct audio_option wav_options[] = {
-    {"FREQUENCY", AUD_OPT_INT, &conf.settings.freq,
-     "Frequency", NULL, 0},
-
-    {"FORMAT", AUD_OPT_FMT, &conf.settings.fmt,
-     "Format", NULL, 0},
-
-    {"DAC_FIXED_CHANNELS", AUD_OPT_INT, &conf.settings.nchannels,
-     "Number of channels (1 - mono, 2 - stereo)", NULL, 0},
-
-    {"PATH", AUD_OPT_STR, &conf.wav_path,
-     "Path to wave file", NULL, 0},
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "FREQUENCY",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.settings.freq,
+        .descr = "Frequency"
+    },{
+        .name = "FORMAT",
+        .tag = AUD_OPT_FMT,
+        .valp = &conf.settings.fmt,
+        .descr = "Format"
+    },{
+        .name = "DAC_FIXED_CHANNELS",
+        .tag = AUD_OPT_INT,
+        .valp = &conf.settings.nchannels,
+        .descr = "Number of channels (1 - mono, 2 - stereo)"
+    },{
+        .name = "PATH",
+        .tag = AUD_OPT_STR,
+        .valp = &conf.wav_path,
+        .descr = "Path to wave file"
+    },{
+        /* End of list */
+    }
 };
 
 static struct audio_pcm_ops wav_pcm_ops = {
Signature · 1 line
1.6.2.5
#19 lore raw

PATCH 4/4 use C99 initializers for all audio/*

In reply to Juan Quintela
---
 audio/alsaaudio.c   |    9 +++++-
 audio/dsoundaudio.c |   20 ++++++++--------
 audio/esdaudio.c    |    6 +---
 audio/fmodaudio.c   |   63 ++++++++++++++++++++++++++++++++++----------------
 audio/ossaudio.c    |    9 +++++-
 audio/paaudio.c     |    7 +----
 audio/sdlaudio.c    |    2 +-
 audio/wavaudio.c    |    9 +++----
 8 files changed, 76 insertions(+), 49 deletions(-)
audio/alsaaudio.c +7 -2
index fcaf84f..1e19d5b 100644
@@ -763,8 +763,13 @@ static int alsa_run_in (HWVoiceIn *hw)
         int add;
         int len;
     } bufs[2] = {
-        { hw->wpos, 0 },
-        { 0, 0 }
+        {
+            .add = hw->wpos,
+            .len = 0
+        },{
+            .add = 0,
+            .len = 0
+       }
     };
     snd_pcm_sframes_t avail;
     snd_pcm_uframes_t read_samples = 0;
audio/dsoundaudio.c +10 -10
index 55d42bb..b39bde8 100644
@@ -49,18 +49,18 @@ static struct {
     struct audsettings settings;
     int latency_millis;
 } conf = {
-    1,
-    1,
-    1,
-    0,
-    16384,
-    16384,
+    .lock_retries = 1,
+    .restore_retries = 1,
+    .getstatus_retries = 1,
+    .set_primary = 0,
+    .bufsize_in = 16384,
+    .bufsize_out = 16384,
     {
-        44100,
-        2,
-        AUD_FMT_S16
+        .freq = 44100,
+        .nchannels = 2,
+        .fmt = AUD_FMT_S16
     },
-    10
+    .latency_millis = 10
 };
 
 typedef struct {
audio/esdaudio.c +2 -4
index 002e263..c941abd 100644
@@ -58,10 +58,8 @@ static struct {
     char *dac_host;
     char *adc_host;
 } conf = {
-    1024,
-    2,
-    NULL,
-    NULL
+    .samples = 1024,
+    .divisor = 2,
 };
 
 static void GCC_FMT_ATTR (2, 3) qesd_logerr (int err, const char *fmt, ...)
audio/fmodaudio.c +43 -20

83 lines not on this page · raw message

audio/ossaudio.c +7 -2
index 6d27d58..bdcd86e 100644
@@ -654,8 +654,13 @@ static int oss_run_in (HWVoiceIn *hw)
         int add;
         int len;
     } bufs[2] = {
-        { hw->wpos, 0 },
-        { 0, 0 }
+        {
+            .add = hw->wpos,
+            .len = 0
+        },{
+            .add = 0,
+            .len = 0
+       }
     };
 
     if (!dead) {
audio/paaudio.c +2 -5
index 8492e1a..959b7d5 100644
@@ -38,11 +38,8 @@ static struct {
     char *sink;
     char *source;
 } conf = {
-    1024,
-    2,
-    NULL,
-    NULL,
-    NULL
+    .samples = 1024,
+    .divisor = 2,
 };
 
 static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...)
audio/sdlaudio.c +1 -1
index 4e4544f..1247871 100644
@@ -48,7 +48,7 @@ typedef struct SDLVoiceOut {
 static struct {
     int nb_samples;
 } conf = {
-    1024
+    .nb_samples = 1024
 };
 
 static struct SDLAudioState {
audio/wavaudio.c +4 -5
index 6c11359..3f143e0 100644
@@ -41,12 +41,11 @@ static struct {
     const char *wav_path;
 } conf = {
     {
-        44100,
-        2,
-        AUD_FMT_S16,
-        0
+        .freq = 44100,
+        .nchannels = 2,
+        .fmt = AUD_FMT_S16,
     },
-    "qemu.wav"
+    .wav_path = "qemu.wav"
 };
 
 static int wav_run_out (HWVoiceOut *hw)
Signature · 1 line
1.6.2.5
#21 lore raw
In reply to Juan Quintela
Quoted 6 lines · Juan Quintela

Hi

Cleanup all audio/* using C99 struct initializers, remove INIT_FIELD() once there.

Later, Juan.

malc,

Please Ack and/or apply.

Quoted 21 lines

Juan Quintela (4):
Use proper struct initializers and remove INIT_FIELD() macro use C99 initializers for audio_pcm_ops
Use C99 initializers for audio_option
use C99 initializers for all audio/*

 audio/alsaaudio.c   |  141 ++++++++++++++++++++++++++++------------------
 audio/audio.c       |  109 ++++++++++++++++++++++--------------
 audio/audio_int.h   |    2 -
 audio/coreaudio.c   |   57 ++++++++++---------
 audio/dsoundaudio.c |  139 ++++++++++++++++++++++++++++------------------
 audio/esdaudio.c    |   87 ++++++++++++++++-------------
 audio/fmodaudio.c   |  154 ++++++++++++++++++++++++++++++++------------------
 audio/noaudio.c     |   44 +++++++-------
 audio/ossaudio.c    |   99 ++++++++++++++++++++------------
 audio/paaudio.c     |   94 +++++++++++++++++--------------
 audio/sdlaudio.c    |   51 ++++++++---------
 audio/wavaudio.c    |   83 ++++++++++++++-------------
 12 files changed, 617 insertions(+), 443 deletions(-)
Signature · 3 lines
Regards,

Anthony Liguori
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

Quoted 4 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

Because...

Signature · 3 lines
Regards,

Anthony Liguori
#10 lore raw

Re: [Qemu-devel] [PATCH 2/4] use C99 initializers for audio_pcm_ops

In reply to Juan Quintela

On Mon, 27 Jul 2009, Juan Quintela wrote:

This one looses the vertical align, but otherwise looks fine.

[..snip..]

Signature · 1 line
mailto:[email protected]
#12 lore raw

Re: [Qemu-devel] [PATCH 3/4] Use C99 initializers for audio_option

In reply to Juan Quintela
Quoted 50 lines · Juan Quintela
---
 audio/alsaaudio.c   |   88 ++++++++++++++++++++++++++--------------
 audio/audio.c       |  109 ++++++++++++++++++++++++++++++++-------------------
 audio/coreaudio.c   |   18 ++++++--
 audio/dsoundaudio.c |   74 +++++++++++++++++++++++++----------
 audio/esdaudio.c    |   36 +++++++++++------
 audio/fmodaudio.c   |   47 +++++++++++++++-------
 audio/ossaudio.c    |   46 +++++++++++++++------
 audio/paaudio.c     |   44 +++++++++++++-------
 audio/sdlaudio.c    |   11 ++++-
 audio/wavaudio.c    |   35 +++++++++++------
 10 files changed, 339 insertions(+), 169 deletions(-)
audio/alsaaudio.c +0 -27
index 4954683..fcaf84f 100644
@@ -890,37 +890,63 @@ static void alsa_audio_fini (void *opaque)
 }
 
 static struct audio_option alsa_options[] = {
-    {"DAC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_out,
-     "DAC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
-    {"DAC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_out,
-     "DAC period size (0 to go with system default)",
-     &conf.period_size_out_overridden, 0},
-    {"DAC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_out,
-     "DAC buffer size (0 to go with system default)",
-     &conf.buffer_size_out_overridden, 0},
-
-    {"ADC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_in,
-     "ADC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
-    {"ADC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_in,
-     "ADC period size (0 to go with system default)",
-     &conf.period_size_in_overridden, 0},
-    {"ADC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_in,
-     "ADC buffer size (0 to go with system default)",
-     &conf.buffer_size_in_overridden, 0},
-
-    {"THRESHOLD", AUD_OPT_INT, &conf.threshold,
-     "(undocumented)", NULL, 0},
-
-    {"DAC_DEV", AUD_OPT_STR, &conf.pcm_name_out,
-     "DAC device name (for instance dmix)", NULL, 0},
-
-    {"ADC_DEV", AUD_OPT_STR, &conf.pcm_name_in,
-     "ADC device name", NULL, 0},
-

audio/alsaaudio.c static void alsa_audio_fini (void *opaque) · line 898

Quoted 10 lines
audio/alsaaudio.c +6 -4
-    {"VERBOSE", AUD_OPT_BOOL, &conf.verbose,
-     "Behave in a more verbose way", NULL, 0},
-
-    {NULL, 0, NULL, NULL, NULL, 0}
+    {
+        .name = "DAC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_out,
+        .descr = "DAC period/buffer size in microseconds (otherwise in frames)"
+    },{

I'd prefer:

       { .name  = "DAC_SIZE_IN_USEC",
         .tag   = AUD_OPT_BOOL,
         .valp  = &conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

And likewise elsewhere.

[..snip..]

Signature · 1 line
mailto:[email protected]
#13 lore raw

[Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

In reply to malc
Quoted 11 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

       { .name  = "DAC_SIZE_IN_USEC",
         .tag   = AUD_OPT_BOOL,
         .valp  = &conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

Later, Juan.

#4 lore raw

[Qemu-devel] Re: [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

In reply to malc
Quoted 3 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

I'd say it's pointless to conditionalize 1 usage of a feature out of 100.

Paolo

#5 lore raw

Re: [Qemu-devel] [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

In reply to malc
Quoted 4 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

The INIT_FIELD() stuff is goofy. struct initializers are C99 so using them conditionally on GNUC is incorrect. Also, if you can't rely on the initializier, what's the point of even doing it at all since you cannot change order.

Removing INIT_FIELD() is a big improvement IMHO.

Signature · 3 lines
Regards,

Anthony Liguori
#14 lore raw

Re: [Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

In reply to Juan Quintela
Quoted 11 lines · Juan Quintela
Quoted 10 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

        { .name  = "DAC_SIZE_IN_USEC",
          .tag   = AUD_OPT_BOOL,
          .valp  =&conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

Quoted 5 lines
Quoted 1 line

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

I think malc refers to the vertical alignment, i.e.

.foo = bar,
.longname = somethingelse,

instead of

.foo = bar,
.longname = somethingelse,

The version with the vertical aligned '=' is more readable IMO.

cheers,
Gerd

#15 lore raw

[Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

Quoted 23 lines · Gerd Hoffmann
Quoted 11 lines · Juan Quintela
Quoted 10 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

        { .name  = "DAC_SIZE_IN_USEC",
          .tag   = AUD_OPT_BOOL,
          .valp  =&conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

Quoted 5 lines
Quoted 1 line

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

I think malc refers to the vertical alignment, i.e.

.foo = bar,
.longname = somethingelse,

Quoted 6 lines

instead of

.foo = bar,
.longname = somethingelse,

The version with the vertical aligned '=' is more readable IMO.

Ah, ok.
Re-sending what that fixed

Quoted 2 lines

cheers,
Gerd

#16 lore raw

[Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

In reply to Juan Quintela
Quoted 11 lines · Juan Quintela
Quoted 10 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

       { .name  = "DAC_SIZE_IN_USEC",
         .tag   = AUD_OPT_BOOL,
         .valp  = &conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

Quoted 5 lines
Quoted 1 line

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

Let's look at original example:

+ {

+        .name = "DAC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_out,
+        .descr = "DAC period/buffer size in microseconds (otherwise in frames)"

+ },{

It's internally inconsistent (begins with a bsd style ends with k&r, and on top of that without space after comma). Should either be done the way i mentioned earlier or with:

{
...
},
{
}

And i much prefer the former.

Signature · 1 line
mailto:[email protected]
#6 lore raw

Re: [Qemu-devel] [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

In reply to Anthony Liguori
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

The INIT_FIELD() stuff is goofy. struct initializers are C99 so using them conditionally on GNUC is incorrect. Also, if you can't rely on the initializier, what's the point of even doing it at all since you cannot change order.

The reason for this goofyness is that the code was fed as is to MSVC (in VirtualBox), the patch looks like a change for the sake of a change.

[..snip..]

Signature · 1 line
mailto:[email protected]
#7 lore raw

[Qemu-devel] Re: [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

Quoted 8 lines · malc
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

Quoted 7 lines
Quoted 4 lines

The INIT_FIELD() stuff is goofy. struct initializers are C99 so using them conditionally on GNUC is incorrect. Also, if you can't rely on the initializier, what's the point of even doing it at all since you cannot change order.

The reason for this goofyness is that the code was fed as is to MSVC (in VirtualBox), the patch looks like a change for the sake of a change.

MSVC don't support C99 initializers in 2009? Wow :)

I was trying to get everything else consistent.

Later, Juan.

#8 lore raw

[Qemu-devel] Re: [PATCH 1/4] Use proper struct initializers and remove INIT_FIELD() macro

Quoted 14 lines · Juan Quintela
Quoted 13 lines · malc
Quoted 10 lines · Anthony Liguori
Quoted 4 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

This patch is pointless.

The INIT_FIELD() stuff is goofy. struct initializers are C99 so using them conditionally on GNUC is incorrect. Also, if you can't rely on the initializier, what's the point of even doing it at all since you cannot change order.

Quoted 4 lines
Quoted 2 lines

The reason for this goofyness is that the code was fed as is to MSVC (in VirtualBox), the patch looks like a change for the sake of a change.

MSVC don't support C99 initializers in 2009? Wow :)

Sadly i've no idea what the latest and greatest MSVC does or does not support.

Quoted 2 lines

I was trying to get everything else consistent.

Yes i understand the motivation.

Signature · 1 line
mailto:[email protected]
#17 lore raw

[Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

In reply to malc
Quoted 32 lines · malc
Quoted 11 lines · Juan Quintela
Quoted 10 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

       { .name  = "DAC_SIZE_IN_USEC",
         .tag   = AUD_OPT_BOOL,
         .valp  = &conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

Quoted 5 lines
Quoted 1 line

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

Let's look at original example:

audio/alsaaudio.c +6 -0
+    {
+        .name = "DAC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_out,
+        .descr = "DAC period/buffer size in microseconds (otherwise in frames)"
+    },{

It's internally inconsistent (begins with a bsd style ends with k&r, and on top of that without space after comma). Should either be done the way i mentioned earlier or with:

Quoted 7 lines

{
...
},
{
}

And i much prefer the former.

I was trying to be consistent with rest of qemu:

(simple-config-7*)$ find . -name "*.[ch]" | xargs grep " },{$" | wc -l 42
(simple-config-7*)$ find . -name "*.[ch]" | xargs grep " }, {$" | wc -l 18

I don't mean going one way or the other, but I would like that everbody decided what was the "right" position of the braces. If possible, not one style by directory.

Later, Juan.

#18 lore raw

[Qemu-devel] Re: [PATCH 3/4] Use C99 initializers for audio_option

Quoted 39 lines · Juan Quintela
Quoted 38 lines · malc
Quoted 11 lines · Juan Quintela
Quoted 10 lines · malc

On Mon, 27 Jul 2009, Juan Quintela wrote:

I'd prefer:

       { .name  = "DAC_SIZE_IN_USEC",
         .tag   = AUD_OPT_BOOL,
         .valp  = &conf.size_in_usec_out,

.descr = "DAC period/buffer size in microseconds (otherwise in frames)" },
{ ...

Quoted 5 lines
Quoted 1 line

And likewise elsewhere.

I tried to be consistent with the qdev patches, they add all its "arrays of structures" this way (it is one of the bigger users of the feature that I saw).

Let's look at original example:

audio/alsaaudio.c +6 -0
+    {
+        .name = "DAC_SIZE_IN_USEC",
+        .tag = AUD_OPT_BOOL,
+        .valp = &conf.size_in_usec_out,
+        .descr = "DAC period/buffer size in microseconds (otherwise in frames)"
+    },{

It's internally inconsistent (begins with a bsd style ends with k&r, and on top of that without space after comma). Should either be done the way i mentioned earlier or with:

{
...
},
{
}

Quoted 8 lines
Quoted 1 line

And i much prefer the former.

I was trying to be consistent with rest of qemu:

(simple-config-7*)$ find . -name "*.[ch]" | xargs grep " },{$" | wc -l 42
(simple-config-7*)$ find . -name "*.[ch]" | xargs grep " }, {$" | wc -l 18

Alrighty then:

qemu$ find . -name "*.[ch]" | xargs grep " },$" | wc -l 10294

Quoted 4 lines

I don't mean going one way or the other, but I would like that everbody decided what was the "right" position of the braces. If possible, not one style by directory.

Once again - i do understand the motivation, i just don't see much point. I just happen to like the code i maintain to look internally consistent.

Signature · 1 line
mailto:[email protected]