Skip to content

Commit

Permalink
Reduce USB Audio popping
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Dec 15, 2024
1 parent c097cbb commit a26344f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/usb/usb_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ typedef struct usb_device_audio
int16_t vol;

int alt_iface_enabled;
int buffer_retented;
} usb_device_audio;

int
Expand Down Expand Up @@ -409,11 +410,14 @@ usb_audio_get_buffer(int32_t *buffer, int len, void *priv)

if (fifo8_num_used(&usb_audio->audio_buf) < (SOUNDBUFLEN * 2 * 2))
{
static int buffer_underrun = 0;
//pclog("USB Audio: Buffer underrun! (%d)\n", buffer_underrun++);
usb_audio->buffer_retented = 0;
return;
}

usb_audio->buffer_retented++;
if (usb_audio->buffer_retented < 2)
return;

fifo8_pop_buf(&usb_audio->audio_buf, (uint8_t*)usb_audio->buffer, sizeof (usb_audio->buffer));
if (usb_audio->vol == ((int16_t)0x8000))
return; // Utter silence.
Expand Down

0 comments on commit a26344f

Please sign in to comment.