]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: sound: Handle errors better in sound_beep()
authorSimon Glass <sjg@chromium.org>
Mon, 3 Feb 2020 14:36:07 +0000 (07:36 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 6 Feb 2020 02:33:46 +0000 (19:33 -0700)
At present an error does not stop the sound-output loop. This is incorrect
since nothing can be gained by trying to continue. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/sound/sound-uclass.c

index c213472d60666c27214101f120038f63f8ef6d70..bada0c2ba5a92bfdb0d2889fb3a66c8e05937142 100644 (file)
@@ -97,11 +97,14 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz)
        sound_create_square_wave(i2s_uc_priv->samplingrate, data, data_size,
                                 frequency_hz, i2s_uc_priv->channels);
 
+       ret = 0;
        while (msecs >= 1000) {
                ret = sound_play(dev, data, data_size);
+               if (ret)
+                       break;
                msecs -= 1000;
        }
-       if (msecs) {
+       if (!ret && msecs) {
                unsigned long size =
                        (data_size * msecs) / (sizeof(int) * 1000);