| 134 | #endif |
| 135 | |
| 136 | int |
| 137 | main(int argc, char *argv[]) |
| 138 | { |
| 139 | int i; |
| 140 | char filename[4096]; |
| 141 | |
| 142 | /* Enable standard application logging */ |
| 143 | SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); |
| 144 | |
| 145 | /* Load the SDL library */ |
| 146 | if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { |
| 147 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); |
| 148 | return (1); |
| 149 | } |
| 150 | |
| 151 | /* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */ |
| 152 | SDL_MinimizeWindow(SDL_CreateWindow("testaudiohotplug", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0)); |
| 153 | |
| 154 | if (argc > 1) { |
| 155 | SDL_strlcpy(filename, argv[1], sizeof(filename)); |
| 156 | } else { |
| 157 | SDL_strlcpy(filename, "sample.wav", sizeof(filename)); |
| 158 | } |
| 159 | /* Load the wave file into memory */ |
| 160 | if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == NULL) { |
| 161 | SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); |
| 162 | quit(1); |
| 163 | } |
| 164 | |
| 165 | #if HAVE_SIGNAL_H |
| 166 | /* Set the signals */ |
| 167 | #ifdef SIGHUP |
| 168 | signal(SIGHUP, poked); |
| 169 | #endif |
| 170 | signal(SIGINT, poked); |
| 171 | #ifdef SIGQUIT |
| 172 | signal(SIGQUIT, poked); |
| 173 | #endif |
| 174 | signal(SIGTERM, poked); |
| 175 | #endif /* HAVE_SIGNAL_H */ |
| 176 | |
| 177 | /* Show the list of available drivers */ |
| 178 | SDL_Log("Available audio drivers:"); |
| 179 | for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) { |
| 180 | SDL_Log("%i: %s", i, SDL_GetAudioDriver(i)); |
| 181 | } |
| 182 | |
| 183 | SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n"); |
| 184 | SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); |
| 185 | |
| 186 | #ifdef __EMSCRIPTEN__ |
| 187 | emscripten_set_main_loop(loop, 0, 1); |
| 188 | #else |
| 189 | while (!done) { |
| 190 | SDL_Delay(100); |
| 191 | iteration(); |
| 192 | } |
| 193 | #endif |
nothing calls this directly
no test coverage detected