CRAS: a2dpio - Use a more "normal" pcm buffer.

The pcm buffer will work as a circular buffer, there isn't a helper
for this pattern even though it is used everywhere, that can be fixed
later, just open-code another one for now.

This change will make separating the timing of bt socket and the
stream's client easier in a later change.

Change-Id: Ibdae989b6f3cb10c8803e423bf31618ca1eef2f0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dpio - Write as much of the buffer as possible.

Loop in flush_data to write as much of the pcm buffer as possible.
This will make de-coupling the pcm and a2dp buffer levels easier.

Change-Id: I3a546a343d390e5defa1988e0b2cff55d94be575
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: a2dp_info - make avdtp_write static.

It isn't used outside the c file.

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

Change-Id: I2600be31f037337e844f572a4f6319d38d6fbcaf
TODO - fix uts CRAS: a2dp - Split encode and write operations.

Splitting the two operations will make it possible to drive the writes
based on the state of the output socket instead of the level of the
client stream in a future commit.

Change-Id: I6204a45c8c021356b71f9e3699de1cd3c6b16349
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - log delay when filling output

Add the delay to the audio thread log.

BUG=none
TEST=cras_test_client --udmp_a

Signed-off-by: Dylan Reid <dgreid@chromium.org>
wip: drive a2dp output from socket writable

Change-Id: I69fdd26b5359df1437a05d88914dfed086ab9b21
only send data near mtu sized chunks

Change-Id: Ia16b559d07d504fb34821aacdf0356f41c09c6d0
sqme

Change-Id: Id4cb0a1856d2be40a019e3cd53198edfd825d1ce
CRAS: a2dpio - 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

Signed-off-by: Dylan Reid <dgreid@chromium.org>
squash me with something in a2dp

Change-Id: I2d35abc500ef2084a5b8687a97fc6e92a65449a0
CRAS: a2dp_iodev - 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.

BUG=none
TEST=play A/V sync test on youtube.

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

Change-Id: Ife542699bca8b78cd57cd21ae97d7bfcd7323599
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>
squash with something

Change-Id: I9baa089cfa74feb0a451f6652a4cff4acec87177
squash with setsockopt

Change-Id: Ic4832279c63967d8886f63d5738f173aed91b5cd
wip: find beginning of audio log