|
@@ -37,7 +37,7 @@ int SDL_AppInit(void **appstate, int argc, char **argv)
|
|
|
/* Initialize test framework */
|
|
|
state = SDLTest_CommonCreateState(argv, 0);
|
|
|
if (!state) {
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_SUCCESS;
|
|
|
+ return SDL_APP_SUCCESS;
|
|
|
}
|
|
|
|
|
|
/* Enable standard application logging */
|
|
@@ -57,7 +57,7 @@ int SDL_AppInit(void **appstate, int argc, char **argv)
|
|
|
if (consumed <= 0) {
|
|
|
static const char *options[] = { "[device_name]", NULL };
|
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
|
|
|
i += consumed;
|
|
@@ -66,12 +66,12 @@ int SDL_AppInit(void **appstate, int argc, char **argv)
|
|
|
/* Load the SDL library */
|
|
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_SUCCESS;
|
|
|
+ return SDL_APP_SUCCESS;
|
|
|
}
|
|
|
|
|
|
if (SDL_CreateWindowAndRenderer("testaudiocapture", 320, 240, 0, &window, &renderer) < 0) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window and renderer: %s\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_SUCCESS;
|
|
|
+ return SDL_APP_SUCCESS;
|
|
|
}
|
|
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
|
SDL_RenderClear(renderer);
|
|
@@ -104,17 +104,17 @@ int SDL_AppInit(void **appstate, int argc, char **argv)
|
|
|
device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, NULL);
|
|
|
if (!device) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for playback: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
SDL_PauseAudioDevice(device);
|
|
|
SDL_GetAudioDeviceFormat(device, &outspec, NULL);
|
|
|
stream_out = SDL_CreateAudioStream(&outspec, &outspec);
|
|
|
if (!stream_out) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
} else if (SDL_BindAudioStream(device, stream_out) == -1) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
|
|
|
SDL_Log("Opening capture device %s%s%s...\n",
|
|
@@ -125,33 +125,33 @@ int SDL_AppInit(void **appstate, int argc, char **argv)
|
|
|
device = SDL_OpenAudioDevice(want_device, NULL);
|
|
|
if (!device) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
SDL_PauseAudioDevice(device);
|
|
|
SDL_GetAudioDeviceFormat(device, &inspec, NULL);
|
|
|
stream_in = SDL_CreateAudioStream(&inspec, &inspec);
|
|
|
if (!stream_in) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for capture: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
} else if (SDL_BindAudioStream(device, stream_in) == -1) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for capture: %s!\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
|
|
|
SDL_SetAudioStreamFormat(stream_in, NULL, &outspec); /* make sure we output at the playback format. */
|
|
|
|
|
|
SDL_Log("Ready! Hold down mouse or finger to record!\n");
|
|
|
|
|
|
- return SDL_MAIN_CALLBACK_CONTINUE;
|
|
|
+ return SDL_APP_CONTINUE;
|
|
|
}
|
|
|
|
|
|
int SDL_AppEvent(void *appstate, const SDL_Event *event)
|
|
|
{
|
|
|
if (event->type == SDL_EVENT_QUIT) {
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_SUCCESS;
|
|
|
+ return SDL_APP_SUCCESS;
|
|
|
} else if (event->type == SDL_EVENT_KEY_DOWN) {
|
|
|
if (event->key.keysym.sym == SDLK_ESCAPE) {
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_SUCCESS;
|
|
|
+ return SDL_APP_SUCCESS;
|
|
|
}
|
|
|
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
|
|
if (event->button.button == 1) {
|
|
@@ -166,7 +166,7 @@ int SDL_AppEvent(void *appstate, const SDL_Event *event)
|
|
|
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream_out));
|
|
|
}
|
|
|
}
|
|
|
- return SDL_MAIN_CALLBACK_CONTINUE;
|
|
|
+ return SDL_APP_CONTINUE;
|
|
|
}
|
|
|
|
|
|
int SDL_AppIterate(void *appstate)
|
|
@@ -185,14 +185,14 @@ int SDL_AppIterate(void *appstate)
|
|
|
const int br = SDL_GetAudioStreamData(stream_in, buf, sizeof(buf));
|
|
|
if (br < 0) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
} else if (SDL_PutAudioStreamData(stream_out, buf, br) < 0) {
|
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write to output audio stream: %s\n", SDL_GetError());
|
|
|
- return SDL_MAIN_CALLBACK_EXIT_FAILURE;
|
|
|
+ return SDL_APP_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return SDL_MAIN_CALLBACK_CONTINUE;
|
|
|
+ return SDL_APP_CONTINUE;
|
|
|
}
|
|
|
|
|
|
void SDL_AppQuit(void *appstate)
|