Skip to content

Commit 36adb51

Browse files
committed
ALSA: usb-audio: Optimize the copy of packet sizes for implicit fb handling
We did manual copies over loop for the packet data update of the implicit feedback, but this can be optimized with a simple memcpy(). Along with it, change the data type of snd_usb_packet_info struct to align with other (from uint32_t to int). No functional changes but only code optimizations. Link: https://patch.msgid.link/20260216141209.1849200-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent cf044e4 commit 36adb51

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

sound/usb/card.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct snd_usb_endpoint {
9090
struct snd_urb_ctx urb[MAX_URBS];
9191

9292
struct snd_usb_packet_info {
93-
uint32_t packet_size[MAX_PACKS_HS];
93+
int packet_size[MAX_PACKS_HS];
9494
int packets;
9595
} next_packet[MAX_URBS];
9696
unsigned int next_packet_head; /* ring buffer offset to read */

sound/usb/endpoint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ int snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,
462462
while (ep_state_running(ep)) {
463463
struct snd_usb_packet_info *packet;
464464
struct snd_urb_ctx *ctx = NULL;
465-
int err, i;
465+
int err;
466466

467467
scoped_guard(spinlock_irqsave, &ep->lock) {
468468
if ((!implicit_fb || ep->next_packet_queued > 0) &&
@@ -482,8 +482,8 @@ int snd_usb_queue_pending_output_urbs(struct snd_usb_endpoint *ep,
482482
/* copy over the length information */
483483
if (implicit_fb) {
484484
ctx->packets = packet->packets;
485-
for (i = 0; i < packet->packets; i++)
486-
ctx->packet_size[i] = packet->packet_size[i];
485+
memcpy(ctx->packet_size, packet->packet_size,
486+
packet->packets * sizeof(packet->packet_size[0]));
487487
}
488488

489489
/* call the data handler to fill in playback data */

0 commit comments

Comments
 (0)