forked from mia/Aegisub
Alsa player: avoid allocating an array of negative size and add some printfs for debugging.
Originally committed to SVN as r6797.
This commit is contained in:
parent
9f6d117875
commit
1afc3a816f
1 changed files with 18 additions and 4 deletions
|
@ -247,6 +247,9 @@ do_setup:
|
|||
|
||||
while (ps.signal_stop == false)
|
||||
{
|
||||
int64_t orig_position = position;
|
||||
int64_t orig_ps_end_position = ps.end_position;
|
||||
|
||||
ScopedAliveFlag playing_flag(ps.playing);
|
||||
|
||||
// Sleep a bit, or until an event
|
||||
|
@ -270,17 +273,28 @@ do_setup:
|
|||
}
|
||||
|
||||
// Fill buffer
|
||||
avail = snd_pcm_avail(pcm);
|
||||
if (avail == -EPIPE)
|
||||
long tmp_pcm_avail = snd_pcm_avail(pcm);
|
||||
if (tmp_pcm_avail == -EPIPE)
|
||||
{
|
||||
if (snd_pcm_recover(pcm, -EPIPE, 1) < 0)
|
||||
{
|
||||
LOG_D("audio/player/alsa") << "failed to recover from underrun";
|
||||
return (void*)"snd_pcm_avail";
|
||||
}
|
||||
avail = snd_pcm_avail(pcm);
|
||||
tmp_pcm_avail = snd_pcm_avail(pcm);
|
||||
}
|
||||
avail = std::min(tmp_pcm_avail, (snd_pcm_sframes_t)(ps.end_position-position));
|
||||
if (avail < 0)
|
||||
{
|
||||
printf("\n--------- avail was less than 0: %ld\n", avail);
|
||||
printf("snd_pcm_avail(pcm): %ld\n", tmp_pcm_avail);
|
||||
printf("original position: %ld\n", orig_position);
|
||||
printf("current position: %ld\n", position);
|
||||
printf("original ps.end_position: %ld\n", orig_ps_end_position);
|
||||
printf("current ps.end_position: %ld\n", ps.end_position);
|
||||
printf("---------\n\n");
|
||||
continue;
|
||||
}
|
||||
avail = std::min(avail, (snd_pcm_sframes_t)(ps.end_position-position));
|
||||
buf = new char[avail*framesize];
|
||||
ps.provider->GetAudioWithVolume(buf, position, avail, ps.volume);
|
||||
written = 0;
|
||||
|
|
Loading…
Reference in a new issue