| 72 | } |
| 73 | |
| 74 | int |
| 75 | main(int argc, char *argv[]) |
| 76 | { |
| 77 | char filename[4096]; |
| 78 | |
| 79 | /* Enable standard application logging */ |
| 80 | SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |
| 81 | |
| 82 | /* Load the SDL library */ |
| 83 | if (SDL_Init(SDL_INIT_AUDIO) < 0) { |
| 84 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
| 85 | return (1); |
| 86 | } |
| 87 | |
| 88 | if (argc > 1) { |
| 89 | SDL_strlcpy(filename, argv[1], sizeof(filename)); |
| 90 | } else { |
| 91 | SDL_strlcpy(filename, "sample.wav", sizeof(filename)); |
| 92 | } |
| 93 | /* Load the wave file into memory */ |
| 94 | if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { |
| 95 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); |
| 96 | quit(1); |
| 97 | } |
| 98 | |
| 99 | wave.spec.callback = NULL; /* we'll push audio. */ |
| 100 | |
| 101 | #if HAVE_SIGNAL_H |
| 102 | /* Set the signals */ |
| 103 | #ifdef SIGHUP |
| 104 | signal(SIGHUP, poked); |
| 105 | #endif |
| 106 | signal(SIGINT, poked); |
| 107 | #ifdef SIGQUIT |
| 108 | signal(SIGQUIT, poked); |
| 109 | #endif |
| 110 | signal(SIGTERM, poked); |
| 111 | #endif /* HAVE_SIGNAL_H */ |
| 112 | |
| 113 | /* Initialize fillerup() variables */ |
| 114 | if (SDL_OpenAudio(&wave.spec, NULL) < 0) { |
| 115 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError()); |
| 116 | SDL_FreeWAV(wave.sound); |
| 117 | quit(2); |
| 118 | } |
| 119 | |
| 120 | /*static x[99999]; SDL_QueueAudio(1, x, sizeof (x));*/ |
| 121 | |
| 122 | /* Let the audio run */ |
| 123 | SDL_PauseAudio(0); |
| 124 | |
| 125 | done = 0; |
| 126 | |
| 127 | /* Note that we stuff the entire audio buffer into the queue in one |
| 128 | shot. Most apps would want to feed it a little at a time, as it |
| 129 | plays, but we're going for simplicity here. */ |
| 130 | |
| 131 | #ifdef __EMSCRIPTEN__ |
nothing calls this directly
no test coverage detected