From eb65009f6618a4fab407d95a1121f7ccae221d6f Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Thu, 16 Apr 2009 20:49:37 +0000 Subject: [PATCH] * Remove variable 'avail'. * Fold lenAvailable logic into a ternary operator. * Use GetAduioWithVolume instead of applying volume ourselves. * Remove code used to zero rest of the buffer. (not required) Originally committed to SVN as r2805. --- aegisub/src/audio_player_portaudio2.cpp | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/aegisub/src/audio_player_portaudio2.cpp b/aegisub/src/audio_player_portaudio2.cpp index 1622b91b5..432c1bcc4 100644 --- a/aegisub/src/audio_player_portaudio2.cpp +++ b/aegisub/src/audio_player_portaudio2.cpp @@ -95,32 +95,13 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, uns int end = 0; // Calculate how much left - int64_t lenAvailable = player->endPos - player->playPos; - uint64_t avail = 0; - if (lenAvailable > 0) { - avail = lenAvailable; - if (avail > framesPerBuffer) { - lenAvailable = framesPerBuffer; - avail = lenAvailable; - } - } - else { - lenAvailable = 0; - avail = 0; - } + int64_t lenAvailable = (player->endPos - player->playPos) > 0 ? framesPerBuffer : 0; // Play something if (lenAvailable > 0) { - provider->GetAudio(outputBuffer,player->playPos,lenAvailable); + provider->GetAudioWithVolume(outputBuffer, player->playPos, lenAvailable, player->GetVolume()); } - // Set volume - short *output = (short*) outputBuffer; - for (unsigned int i=0;iGetVolume()),(1<<15)-1); - - // Fill rest with blank - for (unsigned int i=avail;iplayPos += framesPerBuffer;