MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / iteration

Function iteration

deps/SDL2/test/testaudiohotplug.c:83–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static void
84iteration()
85{
86 SDL_Event e;
87 SDL_AudioDeviceID dev;
88 while (SDL_PollEvent(&e)) {
89 if (e.type == SDL_QUIT) {
90 done = 1;
91 } else if (e.type == SDL_KEYUP) {
92 if (e.key.keysym.sym == SDLK_ESCAPE)
93 done = 1;
94 } else if (e.type == SDL_AUDIODEVICEADDED) {
95 int index = e.adevice.which;
96 int iscapture = e.adevice.iscapture;
97 const char *name = SDL_GetAudioDeviceName(index, iscapture);
98 if (name != NULL)
99 SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int) index, name);
100 else {
101 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n",
102 devtypestr(iscapture), (unsigned int) index, SDL_GetError());
103 continue;
104 }
105 if (!iscapture) {
106 positions[posindex] = 0;
107 spec.userdata = &positions[posindex++];
108 spec.callback = fillerup;
109 dev = SDL_OpenAudioDevice(name, 0, &spec, NULL, 0);
110 if (!dev) {
111 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError());
112 } else {
113 SDL_Log("Opened '%s' as %u\n", name, (unsigned int) dev);
114 SDL_PauseAudioDevice(dev, 0);
115 }
116 }
117 } else if (e.type == SDL_AUDIODEVICEREMOVED) {
118 dev = (SDL_AudioDeviceID) e.adevice.which;
119 SDL_Log("%s device %u removed.\n", devtypestr(e.adevice.iscapture), (unsigned int) dev);
120 SDL_CloseAudioDevice(dev);
121 }
122 }
123}
124
125#ifdef __EMSCRIPTEN__
126void

Callers 2

loopFunction · 0.85
mainFunction · 0.85

Calls 9

SDL_PollEventFunction · 0.85
SDL_GetAudioDeviceNameFunction · 0.85
SDL_LogFunction · 0.85
devtypestrFunction · 0.85
SDL_LogErrorFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_OpenAudioDeviceFunction · 0.85
SDL_PauseAudioDeviceFunction · 0.85
SDL_CloseAudioDeviceFunction · 0.85

Tested by

no test coverage detected