MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / startOutput

Function startOutput

TheForceEngine/TFE_Audio/audioDevice.cpp:83–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

initFunction · 0.85

Calls 2

logWriteFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected