mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
sandbox: sdl: Improve error handling
A few errors are not checked. Fix these and use my preferred spelling for init. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c127f191a8
commit
5f736f8eca
1 changed files with 9 additions and 5 deletions
|
@ -77,7 +77,7 @@ static int sandbox_sdl_ensure_init(void)
|
||||||
{
|
{
|
||||||
if (!sdl.inited) {
|
if (!sdl.inited) {
|
||||||
if (SDL_Init(0) < 0) {
|
if (SDL_Init(0) < 0) {
|
||||||
printf("Unable to initialize SDL: %s\n",
|
printf("Unable to initialise SDL: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
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;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
SDL_WM_SetCaption("U-Boot", "U-Boot");
|
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)
|
int sandbox_sdl_sound_init(int rate, int channels)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec wanted;
|
SDL_AudioSpec wanted, have;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sandbox_sdl_ensure_init())
|
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) {
|
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;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the audio device, forcing the desired format */
|
/* 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());
|
printf("Couldn't open audio: %s\n", SDL_GetError());
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if (have.format != wanted.format) {
|
||||||
|
printf("Couldn't select required audio format\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
sdl.audio_active = true;
|
sdl.audio_active = true;
|
||||||
sdl.sample_rate = wanted.freq;
|
sdl.sample_rate = wanted.freq;
|
||||||
sdl.cur_buf = 0;
|
sdl.cur_buf = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue