| 81 | } |
| 82 | |
| 83 | bool startOutput(SDL_AudioCallback callback, void* userData, u32 channels, u32 sampleRate) |
| 84 | { |
| 85 | SDL_AudioDeviceID adevid; |
| 86 | SDL_AudioSpec specin, specout; |
| 87 | const char *dn = s_outputDeviceList[s_outputDevice].name.c_str(); |
| 88 | |
| 89 | specin.freq = (int)sampleRate; |
| 90 | specin.format = AUDIO_F32LSB; |
| 91 | specin.channels = channels; |
| 92 | specin.callback = callback; |
| 93 | specin.userdata = userData; |
| 94 | specin.samples = s_audioFrameSize; |
| 95 | |
| 96 | TFE_System::logWrite(LOG_MSG, "Audio", "Starting up audio stream for device '%s'", dn); |
| 97 | if (s_outputDevice < 1) |
| 98 | dn = NULL; |
| 99 | |
| 100 | adevid = SDL_OpenAudioDevice(dn, 0, &specin, &specout, 0); |
| 101 | if (adevid == 0) |
| 102 | { |
| 103 | TFE_System::logWrite(LOG_ERROR, "Audio", "Open Audio Device '%s' failed with '%s'", |
| 104 | s_outputDeviceList[s_outputDevice].name.c_str(), SDL_GetError()); |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | s_adevid = adevid; |
| 109 | SDL_PauseAudioDevice(adevid, 0); // unpause |
| 110 | s_streamStarted = true; |
| 111 | |
| 112 | return true; |
| 113 | } |
| 114 | |
| 115 | void stopOutput() |
| 116 | { |