MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / player

Method player

src/Engine/AdlibMusic.cpp:139–171  ·  view source on GitHub ↗

* Custom audio player. * @param udata User data to send to the player. * @param stream Raw audio to output. * @param len Length of audio to output. */

Source from the content-addressed store, hash-verified

137 * @param len Length of audio to output.
138 */
139void AdlibMusic::player(void *udata, Uint8 *stream, int len)
140{
141#ifndef __NO_MUSIC
142 if (Options::musicVolume == 0)
143 return;
144 if (Options::musicAlwaysLoop && !func_is_music_playing())
145 {
146 AdlibMusic *music = (AdlibMusic*)udata;
147 music->play();
148 return;
149 }
150 while (len != 0)
151 {
152 if (!opl[0] || !opl[1])
153 return;
154 int i = std::min(delay, len);
155 if (i)
156 {
157 float volume = Game::volumeExponent(Options::musicVolume);
158 YM3812UpdateOne(opl[0], (INT16*)stream, i / 2, 2, volume);
159 YM3812UpdateOne(opl[1], ((INT16*)stream) + 1, i / 2, 2, volume);
160 stream += i;
161 delay -= i;
162 len -= i;
163 }
164 if (!len)
165 return;
166 func_play_tick();
167
168 delay = delayRates[rate];
169 }
170#endif
171}
172
173}

Callers

nothing calls this directly

Calls 4

func_is_music_playingFunction · 0.85
YM3812UpdateOneFunction · 0.85
func_play_tickFunction · 0.85
playMethod · 0.45

Tested by

no test coverage detected