From patchwork Sun Jan 12 19:06:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1221855 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=lZD784Mr; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47wmXP1z9Qz9s4Y for ; Mon, 13 Jan 2020 06:11:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D44C81828; Sun, 12 Jan 2020 20:07:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lZD784Mr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3BF7F817FC; Sun, 12 Jan 2020 20:07:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3495C817ED for ; Sun, 12 Jan 2020 20:07:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id b10so7247039iof.11 for ; Sun, 12 Jan 2020 11:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wLwSh+IgeTI+1DUiNPkM21ETYj80w1DbxPnBkC7n7K4=; b=lZD784Mr+rZrWlFH0xeJNxB+wnQgrGqgBT2fP+WFS5ezoQfcpENydIFfwb7xDV6aTZ EWDJRjKPsAVNtmr4BguQL8UfA39IwO41umnY4s7tByPqbx7gPEYzpc4RIgpoJG0CpFPW nWEhUFu1WqTAOW21qM/oE2K7E7YPpM8PpuB1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wLwSh+IgeTI+1DUiNPkM21ETYj80w1DbxPnBkC7n7K4=; b=jiNZ2EkXqb/E7zy2ViQWriHJuyiAK5vD/qJdgade2nQP7vbNzIWyNEAzdeQYRvAhxZ 9yNj5U6NyBSiN50vHSIArSL1EGVH6K/Z6KIpZwxyJUcQMQPsizqNOw9iumH4okBRkeL+ ZbNB0WcZ9spM6cyeUghmOXDKBlsAyjQZBDA6dAxs12nXfOVMMpj/MEqaJcdce9KIYWZE 0yTSCBrIovxuUOIRdgke9PU3LS5AYAn4qjkcvsW57ujPDMw8xjvZDdzikhIRT8lcox2u risWv0+9QB9UomnElYllo2L0KYoqixTFkypM1U4VUMeH5+pa0ZjZTcrFC3G85lUTuS1K F/6g== X-Gm-Message-State: APjAAAVl5I4BQrmKRtVrMr43Y3SjQa7Y8qHI1yMPO2ku450BJbics7wD I9K1amKY0yHiqpD0d7sroPuYO6rtokc= X-Google-Smtp-Source: APXvYqxAypD6HDsUVWvk4R4yLEJNsaHjus9tQSWMf5Fyw/p8lChtxM5tcW73x5hjEgV7shT3hcDfmw== X-Received: by 2002:a02:a610:: with SMTP id c16mr11266755jam.13.1578856050024; Sun, 12 Jan 2020 11:07:30 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id r22sm3039219ilb.25.2020.01.12.11.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 11:07:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 23/33] sandbox: sdl: Improve error handling Date: Sun, 12 Jan 2020 12:06:14 -0700 Message-Id: <20200112120216.23.I3c2776b0a0575ed9a668029e1a5e1606804ef338@changeid> X-Mailer: git-send-email 2.25.0.rc1.283.g88dfdc4193-goog In-Reply-To: <20200112190624.79077-1-sjg@chromium.org> References: <20200112190624.79077-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean A few errors are not checked. Fix these and use my preferred spelling for init. Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index dad059f257..ee62da265b 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -77,7 +77,7 @@ static int sandbox_sdl_ensure_init(void) { if (!sdl.inited) { if (SDL_Init(0) < 0) { - printf("Unable to initialize SDL: %s\n", + printf("Unable to initialise SDL: %s\n", SDL_GetError()); return -EIO; } @@ -100,7 +100,7 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp) if (err) return err; if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { - printf("Unable to initialize SDL LCD: %s\n", SDL_GetError()); + printf("Unable to initialise SDL LCD: %s\n", SDL_GetError()); return -EPERM; } SDL_WM_SetCaption("U-Boot", "U-Boot"); @@ -298,7 +298,7 @@ void sandbox_sdl_fill_audio(void *udata, Uint8 *stream, int len) int sandbox_sdl_sound_init(int rate, int channels) { - SDL_AudioSpec wanted; + SDL_AudioSpec wanted, have; int i; if (sandbox_sdl_ensure_init()) @@ -331,15 +331,19 @@ int sandbox_sdl_sound_init(int rate, int channels) } if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { - printf("Unable to initialize SDL audio: %s\n", SDL_GetError()); + printf("Unable to initialise SDL audio: %s\n", SDL_GetError()); goto err; } /* Open the audio device, forcing the desired format */ - if (SDL_OpenAudio(&wanted, NULL) < 0) { + if (SDL_OpenAudio(&wanted, &have) < 0) { printf("Couldn't open audio: %s\n", SDL_GetError()); goto err; } + if (have.format != wanted.format) { + printf("Couldn't select required audio format\n"); + goto err; + } sdl.audio_active = true; sdl.sample_rate = wanted.freq; sdl.cur_buf = 0;