mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-01-19 07:51:54 +00:00
Fix looping .wav sounds with leadin, fixes #291
If the main sound in a shader was a .wav (soundShader->entries[0]->hardwareBuffer == true), only that sound was played (and looped with AL_LOOPING), even if a leadin was configured. If the main sound was an .ogg it worked. Not it should always work.
This commit is contained in:
parent
e24b62d3e0
commit
5919717d05
1 changed files with 8 additions and 2 deletions
|
@ -1780,7 +1780,10 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
|
|||
alSource3f( chan->openalSource, AL_POSITION, -spatializedOriginInMeters.y, spatializedOriginInMeters.z, -spatializedOriginInMeters.x );
|
||||
alSourcef( chan->openalSource, AL_GAIN, ( volume ) < ( 1.0f ) ? ( volume ) : ( 1.0f ) );
|
||||
}
|
||||
alSourcei( chan->openalSource, AL_LOOPING, ( looping && chan->soundShader->entries[0]->hardwareBuffer ) ? AL_TRUE : AL_FALSE );
|
||||
// DG: looping sounds with a leadin can't just use a HW buffer and openal's AL_LOOPING
|
||||
// because we need to switch from leadin to the looped sound.. see https://github.com/dhewm/dhewm3/issues/291
|
||||
bool haveLeadin = chan->soundShader->numLeadins > 0;
|
||||
alSourcei( chan->openalSource, AL_LOOPING, ( looping && chan->soundShader->entries[0]->hardwareBuffer && !haveLeadin ) ? AL_TRUE : AL_FALSE );
|
||||
#if 1
|
||||
alSourcef( chan->openalSource, AL_REFERENCE_DISTANCE, mind );
|
||||
alSourcef( chan->openalSource, AL_MAX_DISTANCE, maxd );
|
||||
|
@ -1797,8 +1800,11 @@ void idSoundWorldLocal::AddChannelContribution( idSoundEmitterLocal *sound, idSo
|
|||
}
|
||||
|
||||
|
||||
if ( ( !looping && chan->leadinSample->hardwareBuffer ) || ( looping && chan->soundShader->entries[0]->hardwareBuffer ) ) {
|
||||
if ( ( !looping && chan->leadinSample->hardwareBuffer )
|
||||
|| ( looping && !haveLeadin && chan->soundShader->entries[0]->hardwareBuffer ) ) {
|
||||
// handle uncompressed (non streaming) single shot and looping sounds
|
||||
// DG: ... that have no leadin (with leadin we still need to switch to another sound,
|
||||
// just use streaming code for that) - see https://github.com/dhewm/dhewm3/issues/291
|
||||
if ( chan->triggered ) {
|
||||
alSourcei( chan->openalSource, AL_BUFFER, looping ? chan->soundShader->entries[0]->openalBuffer : chan->leadinSample->openalBuffer );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue