mirror of
https://github.com/love2d/love-android.git
synced 2026-08-21 13:09:40 +02:00
Updated SDL2 to changeset 69a5f3a540af (dev version of 2.0.4)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -13,6 +13,10 @@
|
||||
|
||||
#include <stdio.h> /* for fflush() and stdout */
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
static SDL_AudioSpec spec;
|
||||
static Uint8 *sound = NULL; /* Pointer to wave data */
|
||||
static Uint32 soundlen = 0; /* Length of wave data */
|
||||
@@ -24,6 +28,8 @@ typedef struct
|
||||
volatile int done;
|
||||
} callback_data;
|
||||
|
||||
callback_data cbd[64];
|
||||
|
||||
void SDLCALL
|
||||
play_through_once(void *arg, Uint8 * stream, int len)
|
||||
{
|
||||
@@ -44,16 +50,30 @@ play_through_once(void *arg, Uint8 * stream, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
loop()
|
||||
{
|
||||
if(cbd[0].done) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_cancel_main_loop();
|
||||
#endif
|
||||
SDL_PauseAudioDevice(cbd[0].dev, 1);
|
||||
SDL_CloseAudioDevice(cbd[0].dev);
|
||||
SDL_FreeWAV(sound);
|
||||
SDL_Quit();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_multi_audio(int devcount)
|
||||
{
|
||||
callback_data cbd[64];
|
||||
int keep_going = 1;
|
||||
int i;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
SDL_Event event;
|
||||
|
||||
/* Create a Window to get fully initialized event processing for testing pause on Android. */
|
||||
SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0);
|
||||
#endif
|
||||
|
||||
@@ -77,13 +97,19 @@ test_multi_audio(int devcount)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
|
||||
} else {
|
||||
SDL_PauseAudioDevice(cbd[0].dev, 0);
|
||||
while (!cbd[0].done) {
|
||||
#ifdef __ANDROID__
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
#else
|
||||
while (!cbd[0].done)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
/* Empty queue, some application events would prevent pause. */
|
||||
while (SDL_PollEvent(&event)){}
|
||||
#endif
|
||||
#endif
|
||||
SDL_Delay(100);
|
||||
}
|
||||
SDL_PauseAudioDevice(cbd[0].dev, 1);
|
||||
#endif
|
||||
SDL_Log("done.\n");
|
||||
SDL_CloseAudioDevice(cbd[0].dev);
|
||||
}
|
||||
@@ -114,12 +140,15 @@ test_multi_audio(int devcount)
|
||||
keep_going = 1;
|
||||
}
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
#ifdef __ANDROID__
|
||||
/* Empty queue, some application events would prevent pause. */
|
||||
while (SDL_PollEvent(&event)){}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SDL_Delay(100);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
for (i = 0; i < devcount; i++) {
|
||||
if (cbd[i].dev) {
|
||||
SDL_PauseAudioDevice(cbd[i].dev, 1);
|
||||
@@ -128,6 +157,7 @@ test_multi_audio(int devcount)
|
||||
}
|
||||
|
||||
SDL_Log("All done!\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +166,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int devcount = 0;
|
||||
|
||||
/* Enable standard application logging */
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Load the SDL library */
|
||||
|
||||
Reference in New Issue
Block a user