diff mbox series

[RFC] coreaudio: fix coreaudio_test.diff

Message ID f03b7ae9-344c-5a7f-414c-6250a9c5ec2f@t-online.de
State New
Headers show
Series [RFC] coreaudio: fix coreaudio_test.diff | expand

Commit Message

Volker Rümelin Jan. 29, 2020, 7:13 a.m. UTC
This is an untested patch that tries to fix the problems in the
patch found at
https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html. 

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 audio/audio_template.h | 16 ++++++++--------
 audio/coreaudio.c      |  5 +++++
 2 files changed, 13 insertions(+), 8 deletions(-)

Comments

Howard Spoelstra Jan. 30, 2020, 3:03 p.m. UTC | #1
On Wed, Jan 29, 2020 at 8:13 AM Volker Rümelin <vr_qemu@t-online.de> wrote:

> This is an untested patch that tries to fix the problems in the
> patch found at
> https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html.
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
>  audio/audio_template.h | 16 ++++++++--------
>  audio/coreaudio.c      |  5 +++++
>  2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/audio/audio_template.h b/audio/audio_template.h
> index a7b46b8363..e6724c5d68 100644
> --- a/audio/audio_template.h
> +++ b/audio/audio_template.h
> @@ -153,13 +153,6 @@ static int glue (audio_pcm_sw_init_, TYPE) (
>      sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
>  #endif
>
> -#ifdef FLOAT_MIXENG
> -#ifdef DAC
> -    sw->conv = mixeng_conv_float;
> -#else
> -    sw->clip = mixeng_clip_float;
> -#endif
> -#else
>  #ifdef DAC
>      sw->conv = mixeng_conv
>  #else
> @@ -169,7 +162,6 @@ static int glue (audio_pcm_sw_init_, TYPE) (
>          [sw->info.sign]
>          [sw->info.swap_endianness]
>          [audio_bits_to_index (sw->info.bits)];
> -#endif
>
>      sw->name = g_strdup (name);
>      err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
> @@ -284,6 +276,13 @@ static HW *glue(audio_pcm_hw_add_new_,
> TYPE)(AudioState *s,
>          goto err1;
>      }
>
> +#ifdef FLOAT_MIXENG
> +#ifdef DAC
> +    hw->clip = mixeng_clip_float;
> +#else
> +    hw->conv = mixeng_conv_float;
> +#endif
> +#else
>  #ifdef DAC
>      hw->clip = mixeng_clip
>  #else
> @@ -293,6 +292,7 @@ static HW *glue(audio_pcm_hw_add_new_,
> TYPE)(AudioState *s,
>          [hw->info.sign]
>          [hw->info.swap_endianness]
>          [audio_bits_to_index (hw->info.bits)];
> +#endif
>
>      glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);
>
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index 4e7e509ad0..ff0d23fd7d 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -482,6 +482,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct
> audsettings *as,
>      Audiodev *dev = drv_opaque;
>      AudiodevCoreaudioPerDirectionOptions *cpdo = dev->u.coreaudio.out;
>      int frames;
> +    struct audsettings fake_as;
>
>      /* create mutex */
>      err = pthread_mutex_init(&core->mutex, NULL);
> @@ -490,6 +491,10 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct
> audsettings *as,
>          return -1;
>      }
>
> +    memcpy(&fake_as, as, sizeof(struct audsettings));
> +    as = &fake_as;
> +    /* size of float is 32bits */
> +    as->fmt = AUDIO_FORMAT_S32;
>      audio_pcm_init_info (&hw->info, as);
>
>      status = coreaudio_get_voice(&core->outputDeviceID);
> --
> 2.16.4
>
> Hi all,

Thanks to the generous help from Mark, I can now report that it is good to
hear coreaudio has been restored into a working state with this patch! I
tested qemu-system-ppc running MacOS and OSX.

Best,
Howard
Volker Rümelin Jan. 31, 2020, 7:37 a.m. UTC | #2
>
> Hi all,
>
> Thanks to the generous help from Mark, I can now report that it is good to hear coreaudio has been restored into a working state with this patch! I tested qemu-system-ppc running MacOS and OSX.
>
> Best,
> Howard

Thank you for testing the two patches. I will wait a few days to see if Zoltán wants to write a cleaned up patch. Otherwise I'll try to write a patch that's acceptable for submission.

With best regards
Volker
Gerd Hoffmann Jan. 31, 2020, 8:03 a.m. UTC | #3
On Fri, Jan 31, 2020 at 08:37:50AM +0100, Volker Rümelin wrote:
> >
> > Hi all,
> >
> > Thanks to the generous help from Mark, I can now report that it is good to hear coreaudio has been restored into a working state with this patch! I tested qemu-system-ppc running MacOS and OSX.
> >
> > Best,
> > Howard
> 
> Thank you for testing the two patches. I will wait a few days to see if Zoltán wants to write a cleaned up patch. Otherwise I'll try to write a patch that's acceptable for submission.

I'm busy collecting pending audio fixes for the next pull req,
planned to send out early next week.  Would be cool if I can
include a coreaudio fix ;)

The RFC patch looks sane to me but it clearly needs a better
commit message.

Current patch queue state:
  https://git.kraxel.org/cgit/qemu/log/?h=queue/audio

If I missed something please resend.

cheers,
  Gerd
Mark Cave-Ayland Jan. 31, 2020, 8:35 a.m. UTC | #4
On 31/01/2020 08:03, Gerd Hoffmann wrote:

>> Thank you for testing the two patches. I will wait a few days to see if Zoltán wants to write a cleaned up patch. Otherwise I'll try to write a patch that's acceptable for submission.
> 
> I'm busy collecting pending audio fixes for the next pull req,
> planned to send out early next week.  Would be cool if I can
> include a coreaudio fix ;)
> 
> The RFC patch looks sane to me but it clearly needs a better
> commit message.
> 
> Current patch queue state:
>   https://git.kraxel.org/cgit/qemu/log/?h=queue/audio
> 
> If I missed something please resend.

That would be great! One thing to note is that Volker's RFC patch applies on top of
Zoltan's original diff from
https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html rather than
being standalone.

If you take a look at my branch at https://github.com/mcayland/qemu/commits/for-cat7
then it's just a case of squashing the top 2 commits and coming up with a suitable
commit message.


ATB,

Mark.
Howard Spoelstra Jan. 31, 2020, 9:12 a.m. UTC | #5
On Fri, Jan 31, 2020 at 9:35 AM Mark Cave-Ayland <
mark.cave-ayland@ilande.co.uk> wrote:

> On 31/01/2020 08:03, Gerd Hoffmann wrote:
>
> >> Thank you for testing the two patches. I will wait a few days to see if
> Zoltán wants to write a cleaned up patch. Otherwise I'll try to write a
> patch that's acceptable for submission.
> >
> > I'm busy collecting pending audio fixes for the next pull req,
> > planned to send out early next week.  Would be cool if I can
> > include a coreaudio fix ;)
> >
> > The RFC patch looks sane to me but it clearly needs a better
> > commit message.
> >
> > Current patch queue state:
> >   https://git.kraxel.org/cgit/qemu/log/?h=queue/audio
> >
> > If I missed something please resend.
>
> That would be great! One thing to note is that Volker's RFC patch applies
> on top of
> Zoltan's original diff from
> https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html
> rather than
> being standalone.
>
> If you take a look at my branch at
> https://github.com/mcayland/qemu/commits/for-cat7
> then it's just a case of squashing the top 2 commits and coming up with a
> suitable
> commit message.
>
>
> ATB,
>
> Mark.
>

Yes, lovely!

I just applied the dsound patch from KJ Liew on top of the for-cat7 branch.

https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg03805.html

While it will not apply directly (not finding the file to patch in the
source tree), it nevertheless gets rid of the dsound errors too.

Best,
Howard
Programmingkid Jan. 31, 2020, 3:55 p.m. UTC | #6
> On Jan 29, 2020, at 2:13 AM, Volker Rümelin <vr_qemu@t-online.de> wrote:
> 
> This is an untested patch that tries to fix the problems in the
> patch found at
> https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html. 
> 
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
> ---
> audio/audio_template.h | 16 ++++++++--------
> audio/coreaudio.c      |  5 +++++
> 2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/audio/audio_template.h b/audio/audio_template.h
> index a7b46b8363..e6724c5d68 100644
> --- a/audio/audio_template.h
> +++ b/audio/audio_template.h
> @@ -153,13 +153,6 @@ static int glue (audio_pcm_sw_init_, TYPE) (
>     sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
> #endif
> 
> -#ifdef FLOAT_MIXENG
> -#ifdef DAC
> -    sw->conv = mixeng_conv_float;
> -#else
> -    sw->clip = mixeng_clip_float;
> -#endif
> -#else
> #ifdef DAC
>     sw->conv = mixeng_conv
> #else
> @@ -169,7 +162,6 @@ static int glue (audio_pcm_sw_init_, TYPE) (
>         [sw->info.sign]
>         [sw->info.swap_endianness]
>         [audio_bits_to_index (sw->info.bits)];
> -#endif
> 
>     sw->name = g_strdup (name);
>     err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
> @@ -284,6 +276,13 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
>         goto err1;
>     }
> 
> +#ifdef FLOAT_MIXENG
> +#ifdef DAC
> +    hw->clip = mixeng_clip_float;
> +#else
> +    hw->conv = mixeng_conv_float;
> +#endif
> +#else
> #ifdef DAC
>     hw->clip = mixeng_clip
> #else
> @@ -293,6 +292,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
>         [hw->info.sign]
>         [hw->info.swap_endianness]
>         [audio_bits_to_index (hw->info.bits)];
> +#endif
> 
>     glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);
> 
> diff --git a/audio/coreaudio.c b/audio/coreaudio.c
> index 4e7e509ad0..ff0d23fd7d 100644
> --- a/audio/coreaudio.c
> +++ b/audio/coreaudio.c
> @@ -482,6 +482,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
>     Audiodev *dev = drv_opaque;
>     AudiodevCoreaudioPerDirectionOptions *cpdo = dev->u.coreaudio.out;
>     int frames;
> +    struct audsettings fake_as;
> 
>     /* create mutex */
>     err = pthread_mutex_init(&core->mutex, NULL);
> @@ -490,6 +491,10 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
>         return -1;
>     }
> 
> +    memcpy(&fake_as, as, sizeof(struct audsettings));
> +    as = &fake_as;
> +    /* size of float is 32bits */
> +    as->fmt = AUDIO_FORMAT_S32;
>     audio_pcm_init_info (&hw->info, as);
> 
>     status = coreaudio_get_voice(&core->outputDeviceID);
> -- 
> 2.16.4
> 

I could not apply this patch using 'patch -p1 < <patch file>'. I kept seeing the error malformed patch. 

When I applied the patch by hand QEMU was able to play sound normally again. Thank you :)

I used qemu-system-i386 at git commit adcd6e93b9519f7fe421d543e3aa646895b32e1a to test this patch. 

Both the AC97 and SB16 sound cards with Windows XP and Windows NT 4.0 respectively. Only the ES1370 sound card used with Windows 2000 failed to play anything. This is probably a problem with it and not your patch.

Reviewed-by: John Arbuckle <programmingkidx@gmail.com>
diff mbox series

Patch

diff --git a/audio/audio_template.h b/audio/audio_template.h
index a7b46b8363..e6724c5d68 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -153,13 +153,6 @@  static int glue (audio_pcm_sw_init_, TYPE) (
     sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
 #endif
 
-#ifdef FLOAT_MIXENG
-#ifdef DAC
-    sw->conv = mixeng_conv_float;
-#else
-    sw->clip = mixeng_clip_float;
-#endif
-#else
 #ifdef DAC
     sw->conv = mixeng_conv
 #else
@@ -169,7 +162,6 @@  static int glue (audio_pcm_sw_init_, TYPE) (
         [sw->info.sign]
         [sw->info.swap_endianness]
         [audio_bits_to_index (sw->info.bits)];
-#endif
 
     sw->name = g_strdup (name);
     err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
@@ -284,6 +276,13 @@  static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
         goto err1;
     }
 
+#ifdef FLOAT_MIXENG
+#ifdef DAC
+    hw->clip = mixeng_clip_float;
+#else
+    hw->conv = mixeng_conv_float;
+#endif
+#else
 #ifdef DAC
     hw->clip = mixeng_clip
 #else
@@ -293,6 +292,7 @@  static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
         [hw->info.sign]
         [hw->info.swap_endianness]
         [audio_bits_to_index (hw->info.bits)];
+#endif
 
     glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);
 
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index 4e7e509ad0..ff0d23fd7d 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -482,6 +482,7 @@  static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
     Audiodev *dev = drv_opaque;
     AudiodevCoreaudioPerDirectionOptions *cpdo = dev->u.coreaudio.out;
     int frames;
+    struct audsettings fake_as;
 
     /* create mutex */
     err = pthread_mutex_init(&core->mutex, NULL);
@@ -490,6 +491,10 @@  static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as,
         return -1;
     }
 
+    memcpy(&fake_as, as, sizeof(struct audsettings));
+    as = &fake_as;
+    /* size of float is 32bits */
+    as->fmt = AUDIO_FORMAT_S32;
     audio_pcm_init_info (&hw->info, as);
 
     status = coreaudio_get_voice(&core->outputDeviceID);