mirror of https://github.com/odrling/Aegisub
* 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.
This commit is contained in:
parent
89fa60082e
commit
0d7af5f333
|
@ -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;i<avail;i++) output[i] = MID(-(1<<15),int(output[i] * player->GetVolume()),(1<<15)-1);
|
||||
|
||||
// Fill rest with blank
|
||||
for (unsigned int i=avail;i<framesPerBuffer;i++) output[i]=0;
|
||||
|
||||
// Set play position
|
||||
player->playPos += framesPerBuffer;
|
||||
|
||||
|
|
Loading…
Reference in New Issue