[bt][a2dp-source] Fix panic in encoding task

When the encoding AsyncWrite only had enough room for part of a buffer,
the encoding stream process would mark in the buffer where to resume,
push the buffer back on the queue, and then return to the top of the
loop to re-poll to register the waker.

The top of the loop would pop off the current buffer, and drop it on the
floor when it got a Poll::Pending.

This would also happen whenever the AsyncWrite for the encoder was
stalled, so we were also just occassionally dropping packets when the
encoder could take no packets.

Retain the buffer when we get Pending from the AsyncWrite.
Make the EncodedStream a bit more generic, and add a build_test which
doesn't require a StreamProcessor to operate the stream, making it
testable.

Fixed: fxbug.dev/62547
Test: added test_stalled_encoder_input in bt-a2dp-source-tests

Change-Id: I9214dc415ce533f30a9325ce6686bc2fd5eb25fd
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/442996
Commit-Queue: Marie Janssen 💖 <jamuraa@google.com>
Reviewed-by: Austin Foxley <afoxley@google.com>
Testability-Review: Austin Foxley <afoxley@google.com>
1 file changed
tree: f01260dabeb7e6c1892088474f625f36c51996db
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. garnet/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .gitattributes
  17. .gitignore
  18. .gn
  19. .style.yapf
  20. AUTHORS
  21. BUILD.gn
  22. CODE_OF_CONDUCT.md
  23. CONTRIBUTING.md
  24. LICENSE
  25. OWNERS
  26. PATENTS
  27. README.md
  28. rustfmt.toml
README.md

Fuchsia

Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.