diff options
-rw-r--r-- | sound/usb/usbaudio.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index d5013383fad7..f5aadb001986 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -475,6 +475,18 @@ static int retire_playback_sync_urb_hs(struct snd_usb_substream *subs, | |||
475 | return 0; | 475 | return 0; |
476 | } | 476 | } |
477 | 477 | ||
478 | /* determine the number of frames in the next packet */ | ||
479 | static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs) | ||
480 | { | ||
481 | if (subs->fill_max) | ||
482 | return subs->maxframesize; | ||
483 | else { | ||
484 | subs->phase = (subs->phase & 0xffff) | ||
485 | + (subs->freqm << subs->datainterval); | ||
486 | return min(subs->phase >> 16, subs->maxframesize); | ||
487 | } | ||
488 | } | ||
489 | |||
478 | /* | 490 | /* |
479 | * Prepare urb for streaming before playback starts. | 491 | * Prepare urb for streaming before playback starts. |
480 | * | 492 | * |
@@ -492,16 +504,7 @@ static int prepare_startup_playback_urb(struct snd_usb_substream *subs, | |||
492 | urb->dev = ctx->subs->dev; | 504 | urb->dev = ctx->subs->dev; |
493 | urb->number_of_packets = subs->packs_per_ms; | 505 | urb->number_of_packets = subs->packs_per_ms; |
494 | for (i = 0; i < subs->packs_per_ms; ++i) { | 506 | for (i = 0; i < subs->packs_per_ms; ++i) { |
495 | /* calculate the size of a packet */ | 507 | counts = snd_usb_audio_next_packet_size(subs); |
496 | if (subs->fill_max) | ||
497 | counts = subs->maxframesize; /* fixed */ | ||
498 | else { | ||
499 | subs->phase = (subs->phase & 0xffff) | ||
500 | + (subs->freqm << subs->datainterval); | ||
501 | counts = subs->phase >> 16; | ||
502 | if (counts > subs->maxframesize) | ||
503 | counts = subs->maxframesize; | ||
504 | } | ||
505 | urb->iso_frame_desc[i].offset = offs * stride; | 508 | urb->iso_frame_desc[i].offset = offs * stride; |
506 | urb->iso_frame_desc[i].length = counts * stride; | 509 | urb->iso_frame_desc[i].length = counts * stride; |
507 | offs += counts; | 510 | offs += counts; |
@@ -538,16 +541,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
538 | urb->number_of_packets = 0; | 541 | urb->number_of_packets = 0; |
539 | spin_lock_irqsave(&subs->lock, flags); | 542 | spin_lock_irqsave(&subs->lock, flags); |
540 | for (i = 0; i < ctx->packets; i++) { | 543 | for (i = 0; i < ctx->packets; i++) { |
541 | /* calculate the size of a packet */ | 544 | counts = snd_usb_audio_next_packet_size(subs); |
542 | if (subs->fill_max) | ||
543 | counts = subs->maxframesize; /* fixed */ | ||
544 | else { | ||
545 | subs->phase = (subs->phase & 0xffff) | ||
546 | + (subs->freqm << subs->datainterval); | ||
547 | counts = subs->phase >> 16; | ||
548 | if (counts > subs->maxframesize) | ||
549 | counts = subs->maxframesize; | ||
550 | } | ||
551 | /* set up descriptor */ | 545 | /* set up descriptor */ |
552 | urb->iso_frame_desc[i].offset = offs * stride; | 546 | urb->iso_frame_desc[i].offset = offs * stride; |
553 | urb->iso_frame_desc[i].length = counts * stride; | 547 | urb->iso_frame_desc[i].length = counts * stride; |