* 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. */
| 137 | * @param len Length of audio to output. |
| 138 | */ |
| 139 | void 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 | } |
nothing calls this directly
no test coverage detected