music_pipe: continuously check the sample format of all chunks
Provide a debug function which asserts on the sample format of all chunks. Call this function in each iteration of the player main loop.
This commit is contained in:
parent
998d9a8225
commit
66ce1495f0
18
src/pipe.c
18
src/pipe.c
@ -300,3 +300,21 @@ void music_pipe_skip(unsigned num)
|
|||||||
while (music_pipe.begin != (unsigned)i)
|
while (music_pipe.begin != (unsigned)i)
|
||||||
music_pipe_shift();
|
music_pipe_shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void music_pipe_check_format(const struct audio_format *current,
|
||||||
|
int next_index, const struct audio_format *next)
|
||||||
|
{
|
||||||
|
const struct audio_format *audio_format = current;
|
||||||
|
|
||||||
|
for (unsigned i = music_pipe.begin; i != music_pipe.end;
|
||||||
|
i = successor(i)) {
|
||||||
|
const struct music_chunk *chunk = music_pipe_get_chunk(i);
|
||||||
|
|
||||||
|
if (next_index > 0 && i == (unsigned)next_index)
|
||||||
|
audio_format = next;
|
||||||
|
|
||||||
|
assert(chunk->length % audio_format_frame_size(audio_format) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -164,4 +164,9 @@ bool music_pipe_tag(const struct tag *tag);
|
|||||||
|
|
||||||
void music_pipe_skip(unsigned num);
|
void music_pipe_skip(unsigned num);
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void music_pipe_check_format(const struct audio_format *current,
|
||||||
|
int next_index, const struct audio_format *next);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -344,6 +344,12 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
music_pipe_check_format(&play_audio_format,
|
||||||
|
player.next_song_chunk,
|
||||||
|
&dc.out_audio_format);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (decoder_is_idle() && !player.queued &&
|
if (decoder_is_idle() && !player.queued &&
|
||||||
pc.next_song != NULL &&
|
pc.next_song != NULL &&
|
||||||
pc.command == PLAYER_COMMAND_NONE) {
|
pc.command == PLAYER_COMMAND_NONE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user