diff mbox series

[01/12] audio: refactor code in audio_run_out()

Message ID 20220923183640.8314-1-vr_qemu@t-online.de
State New
Headers show
Series audio: misc. improvements and bug fixes | expand

Commit Message

Volker Rümelin Sept. 23, 2022, 6:36 p.m. UTC
Refactoring the code in audio_run_out() avoids code duplication
in the next patch. There's no functional change.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 audio/audio.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Marc-André Lureau Sept. 27, 2022, 11:54 a.m. UTC | #1
On Fri, Sep 23, 2022 at 10:43 PM Volker Rümelin <vr_qemu@t-online.de> wrote:

> Refactoring the code in audio_run_out() avoids code duplication
> in the next patch. There's no functional change.
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>



> ---
>  audio/audio.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/audio/audio.c b/audio/audio.c
> index cfa4119c05..04f685fe24 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1121,8 +1121,12 @@ static void audio_run_out (AudioState *s)
>      HWVoiceOut *hw = NULL;
>      SWVoiceOut *sw;
>
> -    if (!audio_get_pdo_out(s->dev)->mixing_engine) {
> -        while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
> +    while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
> +        size_t played, live, prev_rpos;
> +        size_t hw_free = audio_pcm_hw_get_free(hw);
> +        int nb_live;
> +
> +        if (!audio_get_pdo_out(s->dev)->mixing_engine) {
>              /* there is exactly 1 sw for each hw with no mixeng */
>              sw = hw->sw_head.lh_first;
>
> @@ -1137,14 +1141,9 @@ static void audio_run_out (AudioState *s)
>              if (sw->active) {
>                  sw->callback.fn(sw->callback.opaque, INT_MAX);
>              }
> -        }
> -        return;
> -    }
>
> -    while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
> -        size_t played, live, prev_rpos;
> -        size_t hw_free = audio_pcm_hw_get_free(hw);
> -        int nb_live;
> +            continue;
> +        }
>
>          for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
>              if (sw->active) {
> --
> 2.35.3
>
>
>
diff mbox series

Patch

diff --git a/audio/audio.c b/audio/audio.c
index cfa4119c05..04f685fe24 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1121,8 +1121,12 @@  static void audio_run_out (AudioState *s)
     HWVoiceOut *hw = NULL;
     SWVoiceOut *sw;
 
-    if (!audio_get_pdo_out(s->dev)->mixing_engine) {
-        while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
+    while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
+        size_t played, live, prev_rpos;
+        size_t hw_free = audio_pcm_hw_get_free(hw);
+        int nb_live;
+
+        if (!audio_get_pdo_out(s->dev)->mixing_engine) {
             /* there is exactly 1 sw for each hw with no mixeng */
             sw = hw->sw_head.lh_first;
 
@@ -1137,14 +1141,9 @@  static void audio_run_out (AudioState *s)
             if (sw->active) {
                 sw->callback.fn(sw->callback.opaque, INT_MAX);
             }
-        }
-        return;
-    }
 
-    while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
-        size_t played, live, prev_rpos;
-        size_t hw_free = audio_pcm_hw_get_free(hw);
-        int nb_live;
+            continue;
+        }
 
         for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
             if (sw->active) {