| 1754 | |
| 1755 | #elif PICO_BUILD |
| 1756 | static void picoAudioCallback(modTimer timer, void *refcon, int refconSize) |
| 1757 | { |
| 1758 | modAudioOut out = *(modAudioOut*)refcon; |
| 1759 | |
| 1760 | static int i2s_enabled = 0; |
| 1761 | |
| 1762 | if (!i2s_enabled) { |
| 1763 | modLog(" - enable i2s "); |
| 1764 | audio_i2s_set_enabled(true); |
| 1765 | i2s_enabled = 1; |
| 1766 | } |
| 1767 | |
| 1768 | if (out->state == kStatePlaying) { |
| 1769 | int j; |
| 1770 | for (j=0; j<3; j++) { |
| 1771 | struct audio_buffer *buffer = take_audio_buffer(out->ap, false); |
| 1772 | if (!buffer) { |
| 1773 | // modLog("no buffer"); |
| 1774 | break; |
| 1775 | } |
| 1776 | int16_t *samples = (int16_t*)buffer->buffer->bytes; |
| 1777 | audioMix(out, buffer->max_sample_count, samples); |
| 1778 | buffer->sample_count = buffer->max_sample_count; |
| 1779 | give_audio_buffer(out->ap, buffer); |
| 1780 | } |
| 1781 | } |
| 1782 | else if (out->state == kStateIdle) { |
| 1783 | } |
| 1784 | else if (out->state == kStateClosing) { |
| 1785 | modLog("audio closing"); |
| 1786 | |
| 1787 | audio_i2s_set_enabled(false); |
| 1788 | i2s_enabled = 0; |
| 1789 | modTimerRemove(out->timer); |
| 1790 | out->timer = NULL; |
| 1791 | out->state = kStateTerminated; |
| 1792 | } |
| 1793 | |
| 1794 | } |
| 1795 | #endif |
| 1796 | |
| 1797 | #if PICO_BUILD || defined(__ets__) || ESP32 || defined(_WIN32) |
nothing calls this directly
no test coverage detected