PcmMix: use negative value instead of NaN for addition
Avoid NaN to allow -ffast-math.
This commit is contained in:
@@ -36,8 +36,6 @@
|
|||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -783,7 +781,7 @@ Player::PlayNextChunk()
|
|||||||
chunk->mix_ratio = ((float)cross_fade_position)
|
chunk->mix_ratio = ((float)cross_fade_position)
|
||||||
/ cross_fade_chunks;
|
/ cross_fade_chunks;
|
||||||
} else {
|
} else {
|
||||||
chunk->mix_ratio = nan("");
|
chunk->mix_ratio = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other_chunk->IsEmpty()) {
|
if (other_chunk->IsEmpty()) {
|
||||||
|
@@ -194,9 +194,9 @@ pcm_mix(void *buffer1, const void *buffer2, size_t size,
|
|||||||
int vol1;
|
int vol1;
|
||||||
float s;
|
float s;
|
||||||
|
|
||||||
/* portion1 is between 0.0 and 1.0 for crossfading, MixRamp uses NaN
|
/* portion1 is between 0.0 and 1.0 for crossfading, MixRamp uses -1
|
||||||
* to signal mixing rather than fading */
|
* to signal mixing rather than fading */
|
||||||
if (isnan(portion1))
|
if (portion1 < 0)
|
||||||
return pcm_add(buffer1, buffer2, size, format);
|
return pcm_add(buffer1, buffer2, size, format);
|
||||||
|
|
||||||
s = sin(M_PI_2 * portion1);
|
s = sin(M_PI_2 * portion1);
|
||||||
|
@@ -36,8 +36,9 @@
|
|||||||
* @param size the size of both buffers in bytes
|
* @param size the size of both buffers in bytes
|
||||||
* @param format the sample format of both buffers
|
* @param format the sample format of both buffers
|
||||||
* @param portion1 a number between 0.0 and 1.0 specifying the portion
|
* @param portion1 a number between 0.0 and 1.0 specifying the portion
|
||||||
* of the first buffer in the mix; portion2 = (1.0 - portion1). The value
|
* of the first buffer in the mix; portion2 = (1.0 - portion1).
|
||||||
* NaN is used by the MixRamp code to specify that simple addition is required.
|
* Negative values are used by the MixRamp code to specify that simple
|
||||||
|
* addition is required.
|
||||||
*
|
*
|
||||||
* @return true on success, false if the format is not supported
|
* @return true on success, false if the format is not supported
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user