CRAS: a2dp_io - Set socket depth based on MTU size.

Setting this depth will allow the socket to be filled and writes to be
throttled at a reasonable level.  The default depth ends up being
almost four seconds of audio which caused unreasonable latency.
Account for the extra two MTUs of data in the delay calculation as
well.

BUG=chromium:244615
TEST=play A/V sync test on youtube.

Change-Id: Ie0d79743977340a5fb365432f67a857b32551a15
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dp_io - Log encode and write to audio thread log.

Use the audio thread log to track when samples are encoded and when
data is written to a2dp.

BUG=none
TEST=cras_test_client --dump_a

Change-Id: I0f298017c18c00bf2e37aa7278dad5a2ffce5620
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dp_io - Reset frames count when buffer fills up.

The bt buffer count tries to track how many frames are written to the
device vs how many have been consumed.  This number will inevitably
drift over time because the clock on the device is not known.  To
avoid this problem, reset the count whenever the end of the send
buffer fills up.  When the buffer is full we know that exactly the
buffer length of audio has been written but not consumed.

BUG=chromium:
TEST=play youtube and listen for dropouts overnight.

Change-Id: Id3f29a78650a5bf534480fb7886033e953fe0903
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dp_io - Log mtu size at startup.

Add the mtu size to the print when opening an A2DP iodev.

BUG=chromium:244615
TEST=none

Change-Id: Id5af344cc02f9d2bfeb19a10c1c3c9c29fff78dd
Signed-off-by: Dylan Reid <dgreid@chromium.org>
only send data near mtu sized chunks

Change-Id: Ia16b559d07d504fb34821aacdf0356f41c09c6d0
CRAS: test_client - Add parsing of output log.

Printing the parsed log directly will make it more useful than a bunch
of numbers that you need to find a decoder ring for.

BUG=none
TEST=cras_test_client --dump_a

Change-Id: I78ae9f81fc3ce2298569b9a0ac5e800125fcfc43
Signed-off-by: Dylan Reid <dgreid@chromium.org>
wip: find beginning of audio log

Change-Id: I844edad5cb18404e8fe6d293548864feae4a1844
Set frame count based on number of times encode is called

Change-Id: If90f446bf6011a6441db69ca802a4fcbb62aafbd
Increase a2cp pcm buffer size to 16k frames

Change-Id: I46aa2c8cdcb4f689acb6bee3369f8e4b51b965bc
squash with normal buffer

Change-Id: If17137ecd47a87041c46d2a132a12f65083333ba
CRAS: a2dp_io - Limit frames_queued.

Make sure not to report that fewer frames are queued than are actually
present.  Reporting less here will tell audio_thread to fill (size -
frames_queued) which is a problem if there isn't room.

BUG=chromium:244615
TEST=youtube and drum machine to jambox.

Change-Id: I922868eb30d67159b0cd3bce6c880d8d3f1fb70d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dp_io - set min_buffer_level for a2dp iodev

Set a minimum buffer level for a2dp devices.  This is needed because
of how bursty the devices are, often requesting audio in chunks of >
50ms.  The min_buffer level will guarantee there is audio ready when
the burst is needed.

BUG=chromium:244615
TEST=play youtube and drum machine to jambox overnight.

Change-Id: I949180fa96b41781fcb43636f0138065bc8c3657
CRAS: a2dp_io - Better pre-filling of a2dp socket.

Pre fill the a2dp socket until it returns EAGAIN.  Only then do we set
the start time for the frames_consumed estimation.

BUG=chromium:244615
TEST=play youttube and web audio drum machine on jambox

Change-Id: Iac68a194790d5fdc0ffe3473f053109b0d8e4470
Signed-off-by: Dylan Reid <dgreid@chromium.org>