crossfade: don't use isCurrentAudioFormat()
The crossfading code shouldn't depend on the audio output code. Pass the current audio format to cross_fade_calc() and let it compare directly, instead of using isCurrentAudioFormat().
This commit is contained in:
parent
34244398d0
commit
2a388c2aa7
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "crossfade.h"
|
#include "crossfade.h"
|
||||||
#include "audio.h"
|
|
||||||
#include "pcm_mix.h"
|
#include "pcm_mix.h"
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
#include "audio_format.h"
|
#include "audio_format.h"
|
||||||
@ -29,12 +28,14 @@
|
|||||||
|
|
||||||
unsigned cross_fade_calc(float duration, float total_time,
|
unsigned cross_fade_calc(float duration, float total_time,
|
||||||
const struct audio_format *af,
|
const struct audio_format *af,
|
||||||
|
const struct audio_format *old_format,
|
||||||
unsigned max_chunks)
|
unsigned max_chunks)
|
||||||
{
|
{
|
||||||
unsigned int chunks;
|
unsigned int chunks;
|
||||||
|
|
||||||
if (duration <= 0 || duration >= total_time ||
|
if (duration <= 0 || duration >= total_time ||
|
||||||
!isCurrentAudioFormat(af))
|
/* we can't crossfade when the audio formats are different */
|
||||||
|
!audio_format_equals(af, old_format))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(duration > 0);
|
assert(duration > 0);
|
||||||
|
@ -25,6 +25,7 @@ struct music_chunk;
|
|||||||
|
|
||||||
unsigned cross_fade_calc(float duration, float total_time,
|
unsigned cross_fade_calc(float duration, float total_time,
|
||||||
const struct audio_format *af,
|
const struct audio_format *af,
|
||||||
|
const struct audio_format *old_format,
|
||||||
unsigned max_chunks);
|
unsigned max_chunks);
|
||||||
|
|
||||||
void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
|
void cross_fade_apply(struct music_chunk *a, const struct music_chunk *b,
|
||||||
|
@ -403,6 +403,7 @@ static void do_play(void)
|
|||||||
crossFadeChunks =
|
crossFadeChunks =
|
||||||
cross_fade_calc(pc.cross_fade_seconds, dc.total_time,
|
cross_fade_calc(pc.cross_fade_seconds, dc.total_time,
|
||||||
&dc.out_audio_format,
|
&dc.out_audio_format,
|
||||||
|
&play_audio_format,
|
||||||
music_pipe_size() -
|
music_pipe_size() -
|
||||||
pc.buffered_before_play);
|
pc.buffered_before_play);
|
||||||
if (crossFadeChunks > 0) {
|
if (crossFadeChunks > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user