| 570 |
|
|
| 571 |
hw->clip (dst, src, convert_samples); |
hw->clip (dst, src, convert_samples); |
| 572 |
|
|
| 573 |
again: |
while (convert_samples) { |
| 574 |
written = snd_pcm_writei (alsa->handle, dst, convert_samples); |
written = snd_pcm_writei (alsa->handle, dst, convert_samples); |
| 575 |
|
|
| 576 |
if (written < 0) { |
if (written < 0) { |
| 577 |
switch (written) { |
switch (written) { |
| 578 |
case -EPIPE: |
case -EPIPE: |
| 579 |
if (!alsa_recover (alsa->handle)) { |
if (!alsa_recover (alsa->handle)) { |
| 580 |
goto again; |
continue; |
| 581 |
|
} |
| 582 |
|
dolog ("Failed to write %d frames to %p, " |
| 583 |
|
"handle %p not prepared\n", |
| 584 |
|
convert_samples, |
| 585 |
|
dst, |
| 586 |
|
alsa->handle); |
| 587 |
|
goto exit; |
| 588 |
|
|
| 589 |
|
case -EAGAIN: |
| 590 |
|
continue; |
| 591 |
|
|
| 592 |
|
default: |
| 593 |
|
alsa_logerr (written, "Failed to write %d frames to %p\n", |
| 594 |
|
convert_samples, dst); |
| 595 |
|
goto exit; |
| 596 |
} |
} |
|
dolog ( |
|
|
"Failed to write %d frames to %p, handle %p not prepared\n", |
|
|
convert_samples, |
|
|
dst, |
|
|
alsa->handle |
|
|
); |
|
|
goto exit; |
|
|
|
|
|
case -EAGAIN: |
|
|
goto again; |
|
|
|
|
|
default: |
|
|
alsa_logerr (written, "Failed to write %d frames to %p\n", |
|
|
convert_samples, dst); |
|
|
goto exit; |
|
| 597 |
} |
} |
|
} |
|
| 598 |
|
|
| 599 |
mixeng_clear (src, written); |
mixeng_clear (src, written); |
| 600 |
rpos = (rpos + written) % hw->samples; |
rpos = (rpos + written) % hw->samples; |
| 601 |
samples -= written; |
samples -= written; |
| 602 |
|
convert_samples -= written; |
| 603 |
|
dst = advance (dst, written << hw->info.shift); |
| 604 |
|
src += written; |
| 605 |
|
} |
| 606 |
} |
} |
| 607 |
|
|
| 608 |
exit: |
exit: |
| 664 |
|
|
| 665 |
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift); |
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift); |
| 666 |
if (!alsa->pcm_buf) { |
if (!alsa->pcm_buf) { |
| 667 |
dolog ("Could not allocate DAC buffer (%d bytes)\n", |
dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n", |
| 668 |
hw->samples << hw->info.shift); |
hw->samples, 1 << hw->info.shift); |
| 669 |
alsa_anal_close (&handle); |
alsa_anal_close (&handle); |
| 670 |
return -1; |
return -1; |
| 671 |
} |
} |
| 754 |
|
|
| 755 |
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); |
alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); |
| 756 |
if (!alsa->pcm_buf) { |
if (!alsa->pcm_buf) { |
| 757 |
dolog ("Could not allocate ADC buffer (%d bytes)\n", |
dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n", |
| 758 |
hw->samples << hw->info.shift); |
hw->samples, 1 << hw->info.shift); |
| 759 |
alsa_anal_close (&handle); |
alsa_anal_close (&handle); |
| 760 |
return -1; |
return -1; |
| 761 |
} |
} |