History log of /external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2e14c232763ac89fd9d2fa5e9b3fdcf6581b2db8 23-May-2017 Chinyue Chen <chinyue@chromium.org> Revert "CRAS: Deduplicate snd_pcm_open calls when opening a device."

This reverts commit 70182dd089ce9646f371ce0188ce4423d7f64f6a.

Reason for revert: broke the external mic on cyan and celes

Original change's description:
> CRAS: Deduplicate snd_pcm_open calls when opening a device.
>
> The current open device flow includes several functions like
> cras_alsa_fill_properties and update_channel_layout. They are used only
> once in the flow but each calls snd_pcm_open and then snd_pcm_close the
> device. Since snd_pcm_open is one of the most time-consuming hardware
> operations, the CL extracts the snd_pcm_open calls to the beginning of
> the device open flow to save time.
>
> 1. Update cras_alsa_fill_properties and update_channel_layout to take a
> handle as argument and do not invoke snd_pcm_open.
> 2. Rename existing open_dev functions to configure_dev. open_dev is now
> called at the beginning of the device open flow and invokes the
> snd_pcm_open call.
> 3. Put open_dev, cras_iodev_set_format, and configure_dev inside the
> cras_iodev_open function.
>
> BUG=b:719812
> TEST=make check and tested on reef
> Cuts time to open speakers from 78ms to 42ms
>
> Change-Id: I9b161217def5e87bf892f4ca8148f07bed5e71a5
> Reviewed-on: https://chromium-review.googlesource.com/505974
> Commit-Ready: Chinyue Chen <chinyue@chromium.org>
> Tested-by: Chinyue Chen <chinyue@chromium.org>
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
>

BUG=b:719812

Change-Id: I22eb2fc70b4a5003a861be62d31bc2337b9918c3
Reviewed-on: https://chromium-review.googlesource.com/511982
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
70182dd089ce9646f371ce0188ce4423d7f64f6a 12-May-2017 Chinyue Chen <chinyue@google.com> CRAS: Deduplicate snd_pcm_open calls when opening a device.

The current open device flow includes several functions like
cras_alsa_fill_properties and update_channel_layout. They are used only
once in the flow but each calls snd_pcm_open and then snd_pcm_close the
device. Since snd_pcm_open is one of the most time-consuming hardware
operations, the CL extracts the snd_pcm_open calls to the beginning of
the device open flow to save time.

1. Update cras_alsa_fill_properties and update_channel_layout to take a
handle as argument and do not invoke snd_pcm_open.
2. Rename existing open_dev functions to configure_dev. open_dev is now
called at the beginning of the device open flow and invokes the
snd_pcm_open call.
3. Put open_dev, cras_iodev_set_format, and configure_dev inside the
cras_iodev_open function.

BUG=b:719812
TEST=make check and tested on reef
Cuts time to open speakers from 78ms to 42ms

Change-Id: I9b161217def5e87bf892f4ca8148f07bed5e71a5
Reviewed-on: https://chromium-review.googlesource.com/505974
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
5528e7442cd3b86037fa84e45ca42cf10b126bdf 23-Feb-2017 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_thread - Synchronize audio thread callback removal

Both A2DP and HFP iodev register an audio thread callback to
read/write data from/to a file descriptor. When device is closed
to remove this callback on main thread, audio thread could still
accessing it and cause problem. The symptom on A2DP iodev is that
BT transport has closed and set its fd to -1, but audio thread
accidentally writes data to it so an error is thrown and results
BT disconnection.
Fix this issue by creating a separate function for main thread to
remove audio thread callback in a synchronized way.

TEST=Connect Powerbeats3 headset and repeatedly open and then close
YouTube to verify there is no unexpected disconnection.
BUG=chrome-os-partner:62623

Change-Id: If8171afc5b2462616492551b5e6c586c1c2c1342
Reviewed-on: https://chromium-review.googlesource.com/445844
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Commit-Ready: Miao-chen Chou <mcchou@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
40ec4b17c945adab7667121f50eedc57448c4eff 17-Nov-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Don't flush too much when buffer level is low

The original strategy of flush_data() function is to encode PCM
buffer to SBC format blocks whenever there's data and try writing the
encoded data to A2DP socket. This could consume too much PCM buffer
in one callback to cause buffer level drops below min_buffer_level so
audio thread thinks it underruns.

BUG=chromium:635426
TEST=unittest

Change-Id: I2f294a397868132b8810edb4a91a98f269376212
Reviewed-on: https://chromium-review.googlesource.com/411647
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
fa4cd9766aec6eae544b1078ed835687c4e74617 31-Jul-2016 John Muir <muirj@google.com> CRAS: Use the hardware timestamp with available/used frames.

The ALSA device drivers can provide a timestamp associated with
the buffer read-pointer. This can be use to more accurately guage
the time that the next buffer is required.

Enable this functionality only when supported ALSA in the running
kernel.

BUG=None
TEST=Unit tests pass.
Verified on Samus (on kernel v3.14).
Verified on new device (kernel v3.18 - htimestamp enabled).
Verified a bluetooth device.
Verified a USB device.

Change-Id: I5bca36f7ad9a236e80b2e277ccc62ccc8c39905b
Reviewed-on: https://chromium-review.googlesource.com/366961
Commit-Ready: John Muir <muirj@google.com>
Tested-by: John Muir <muirj@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
2232117de7c9542713986c95235bb088d0fa6c40 15-Aug-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: bt_device - Migrate a2dp suspend timer to bt_device

This is a refactor change to move a2dp suspend timer to
bt_device so it can be managed with all other timer objects.

BUG=chromium:543444
TEST=Manual test A2DP audio

Change-Id: If83e8ebd31de2dfe709d8663ba86e6ba0d14eb22
Reviewed-on: https://chromium-review.googlesource.com/375621
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
d6ba8e31ac15c1e5c5403aa790597857e3380da8 22-Jan-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp_iodev - Implement set volume callback

When AVRCP is supported, CRAS will be able to adjust device's
hardware volume for A2DP output through the media transport
API provided by BlueZ, instead of using software volume.
Implement the set_volume of a2dp_iodev, and a later commit
will use this set volume path under certain condition.

BUG=chromium:605035
TEST=Apply full patch set, and test with Plantronics Edge
headset. Press volume up/down key on keyboard, verify the
volume changes accordingly.

Change-Id: I4c567a951c4e4b5f24ccf3b20f32e9b646feb747
Reviewed-on: https://chromium-review.googlesource.com/340862
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
1037abe53d0bb703539faa80268bcbe0a06f7278 02-Mar-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: bt_transport - Allow transport be released in blocking mode

BT transport can be released in either blocking or non-blocking mode.
A case is found that when bt transport got released non-blocking,
the immediate following acquire call would fail with error message
'Operation not authorized', due to that the transport state hasn't
been fully released on bluetoothd side.
However when fatal error of BT audio is detected, bluetoothd could
take up to 6 seconds to return the release blocking call. This
causes bad user experience so we have to choose non-blocking mode
for this kind of scenario.
In order to support all cases, add a flag to a2dp_io and set this
flag in destructor, where the fatal error handling goes to, and
then the close_dev callback can use this flag to decide release
transport in blocking or non-blocking mode.

BUG=chrome-os-partner:50540
TEST=Play audio and repeatedly pair & connect bluetooth speaker,
verify that A2DP doesn't break.
Use 'Classic Jam' speaker to stream audio, power it off, and
verify audio shouldn't freeze more than 5 seconds.

Change-Id: I79c87cfcb4459555d25b373104baab3feec73561
Reviewed-on: https://chromium-review.googlesource.com/330292
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
5c890457a82d673cd0ab619d6b506a1fbea630eb 09-Dec-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Suspend a2dp if receive -EAGAIN for 5 seconds

Some BT devices don't send correct disconnect event when powers
off, which causes audio/video to freeze 20 seconds unable to
send out any data. In order to provide better user experience
in this situation, schedule a timer in 5 seconds if writing data
receives -EAGAIN error continuously.
This change reuses and extends the force suspend function to
schedule a suspend timer at given time.

BUG=chrome-os-partner:45103
TEST=a2dp playback with 'Jam classic' BT speaker, power off speaker
and verify audio transfer to internal speaker in 5 seconds.

Change-Id: I8b5549cc7402b007923032f7e7db7df90e95b368
Reviewed-on: https://chromium-review.googlesource.com/317072
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
538e024653d4052dbadddcde55da44c0395c3a42 01-Sep-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Use object_path for stable id

The address property of bt_device could be NULL at the moment
when a2dp iodev is created, and cause crash when calculating
the SuperFastHash for stable id. Change to use object_path
instead since it's assured non-NULL.

BUG=chromium:527003
TEST=emerge-daisy adhd. Connect a2dp headset and play audio.

Change-Id: I6f92183e21f6caa11ce61844c45c4fa421f2e6b0
Reviewed-on: https://chromium-review.googlesource.com/296204
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
70c72e44ad8a2a7d8fb51cd668f36d6d8021e422 20-Aug-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Make frames_queued more precise

Take into account of the encoded samples in a2dp buffer when
reporting the total queued frames. This change has two benefits:
(1) More accurate frames_queued value, CRAS will fill less data
to achieve the same buffer level so the effective output latency
can be decreased.
(2) Make it less possible to run into the case that CRAS thinks
a2dp iodev is about to underrun but a2dp socket is full, causing
audio thread to wake up repeatedly.

BUG=chromium:514418
TEST=Connect a2dp device, test with YouTube and drum machine app.

Change-Id: Icaf132ab15e3fa03ab6127a1b64b0405058b0071
Reviewed-on: https://chromium-review.googlesource.com/294415
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hy.chao@gmail.com>
Tested-by: Hsinyu Chao <hy.chao@gmail.com>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
56e4dce193b9e6de95acd59cc715d9d8aaa79761 19-Aug-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Remove uneccessary zero frames

For a2dp iodev we fill zeros until socket write returns -EAGAIN
during the first put_buffer call to make sure there's full of data
before we actually start to send samples. The zero frames pre-filled
are sufficient to prevent glitch sound, so there's no need to pad
additional zero frames in PCM buffer.
Removes the code incrementing PCM buffer wirte pointer so we can
reduce the output latency some more.

BUG=chrome-os-partner:36757
TEST=Connect A2DP headset, test with YouTube.

Change-Id: I2b83d94f0f56611fb08a8de851e947b231f9c292
Reviewed-on: https://chromium-review.googlesource.com/294450
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
85137d0c83307ebbfa890e8a64446de5957fbbbc 11-Aug-2015 Chinyue Chen <chinyue@chromium.org> CRAS: iodev - Add stable device ID.

The stable device ID is an additional info for devices and does not
change due to plug/unplug. The stable device ID is constructed from
the device name plus

* card index and device index for internal devices
* VID and PID for USB devices
* MAC address for Bluetooth devices

BUG=chromium:466768
TEST=Verified on peppy with "cras_test_client --dump_s"

Change-Id: Ib615dd4bf5db3cc9383c758b8bf435fe947f3a18
Reviewed-on: https://chromium-review.googlesource.com/292326
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
c1cd9fc1dfc9e00240ad28571fbae2adea36c628 06-Aug-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp - Use socket depth in frames

We configure a2dp socket depth to twice of write mtu, in bytes.
For a2dp iodev, its min_buffer_level should be of the same level
in frames.

BUG=chrome-os-partner:36757
TEST=Connect a2dp headset, open YouTube. Use
'cras_test_client --dump_a' to check nim_buffer_level.

Change-Id: I002e94ad3f67ef1895fb3d5f71d0a187f518b412
Reviewed-on: https://chromium-review.googlesource.com/291561
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
08a60dcbe8a2c2f20146bab0b281c1de85bc68cc 26-Feb-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: bt_device - Create bt_device when transport/profile connected

Now that we store pointers in bt_device for associated a2dp and
hfp iodevs, it's required to have the bt_device object exists
before a2dp/hfp iodevs are enumerated. Originally CRAS creates
bt_devices only when receiving notifications from bluez, but in
some rare cases CRAS could receive a2dp/hfp connection earlier
than that and cause problem. One guess to the scenario is a
headset auto-conencts right at when device booted.

This change fixes this issue by creating the bt_device if it doesn't
yet exist when a2dp/hfp iodev are about to be enumerated, plus
adding some error message to log these cases.
Note that some of the device properties still relies on notification
from bluez to be populated, for example device readable name and
adapter info, a few checks are added for that.

BUG=chromium:462143
TEST=unittest. It's difficult to replicate the crash, so just
manually verify a2dp and hfp can work.

Change-Id: I14c01fb73c3e86700c0e97faaf920cade205d16e
Reviewed-on: https://chromium-review.googlesource.com/254040
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
ddecc26b70fc359d2100c2e3e742c464b6c38226 24-Nov-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: a2dp hfp - use API to append iodev to cras_bt_device

After this change, A2DP and HFP iodev will be added to a
common virtual bt iodev so the profile switching will take
effect.

BUG=chromium:432434
TEST=Enable HFP, connect to headset which supports A2DP and HFP.
1. Play YouTube, verify it's on A2DP
2. Open AudioVisualizer(using audio input and output), verify it
switches to HFP.
3. Close AudioVisualizer, verify it switches back to A2DP

Change-Id: I803497942242c43f2fa2af547e906a36dcb9a2fa
Reviewed-on: https://chromium-review.googlesource.com/231873
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
910a04978e6e21d7d542cdc26e92dfe23c5ad8af 04-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: a2dp_iodev UT - Up max number of write calls.

A2DP write can be called up to four times, make sure the array is big
enough.

BUG=none
TEST=none

Change-Id: I7317331c89ebd4b3c412744f881fafb848c34b1e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227214
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
a854651b825010352a05f55e720e29bdca6fb1ba 01-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: iodev - Change free_dsp into free_resources

Change the name of cras_iodev_free_dsp to cras_iodev_free_resources.
This will allow for freeing of another object that will be added in
later changes.

BUG=chromium:420589
TEST=None

Change-Id: Ie69179dbd951b62efa498c340daf5ef2ddaf308a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221702
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
95bb35a0c39e45ff54983eedd61eb4c07d4ffad7 06-Jul-2014 Dylan Reid <dgreid@chromium.org> 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>
Reviewed-on: https://chromium-review.googlesource.com/206619
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
c9452136e619b69333dc3bd5fb87e5168793c9c0 01-Jul-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/206262
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
77fb304248eb69a39c0d087b2a6ab91d49d5d498 01-Jul-2014 Dylan Reid <dgreid@chromium.org> CRAS: a2dp_io - drive socket writes from fd poll

Instead of writing to the A2DP socket based on a timer, write until it
is full. Add the stream file descriptor to the select list in the
audio thread. This will call back to write when the fd is writeable.

BUG=chromium:244615
TEST=play audio to the jambox.

Change-Id: I50e9e995a4f035d32a6934d6b23af2425c9dba19
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206260
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
27089cd9e476fff3c1d82622f17a23a80da0fd51 30-Jun-2014 Dylan Reid <dgreid@chromium.org> CRAS: a2dp_io - Break up encode and write.

Breaking up encode and write will make managing the amount of data
that is queued easier.

BUG=chromium:244615
TEST=play audio to jambox.

Change-Id: Iaa0105a2a55520f92d477b7fca823947db6a8f19
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206258
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
01d37ad909523378f12ecf939419829134aec32f 21-Jun-2014 Dylan Reid <dgreid@chromium.org> CRAS: a2dp_io - 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>
Reviewed-on: https://chromium-review.googlesource.com/206255
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
3d316d343d4e80012d2c7d6c5e7e183533e8d7d5 21-Jun-2014 Dylan Reid <dgreid@chromium.org> CRAS: a2dp_io - Use the new byte buffer for the pcm buffer.

The pcm buffer will work as a circular buffer, use the new one.

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

BUG=chromium:244615
TEST=play audio to jambox

Change-Id: Ibdae989b6f3cb10c8803e423bf31618ca1eef2f0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206254
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
cc32f2cfb655c1c2a39a1db448415583f8ecc2d0 09-Jun-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: iodev: Use cras_audio_area for get/put buffer

Use cras_audio_area in get/put buffer interface to replace
current uint8_t pointer.
This will make copying channels from different source easier in a
later change.

BUG=chromium:370368
TEST=emerge adhd. Capture audio and play youtube to verify
nothing breaks.

Change-Id: I9d532da180bbfe464fc2a174788fef7ddca357b4
Reviewed-on: https://chromium-review.googlesource.com/203053
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
9690a3281b7167e5a38368fd8db39375bea8a1f8 12-Jun-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: iodev: add cras_audio_area pointer to iodev

Add a pointer to cras_audio_area in cras_iodev, and alloc/free
it at open/close callback. The audio area will be used to
replace uint8_t pointer in get/put buffer in later changes.

BUG=chromium:370368
TEST=emerge adhd. Capture and playback youtube to verify
nothing breaks.

Change-Id: I8b7d7e577c15eeea6a07cfc522666b7e08563f80
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203611
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
97d900eef92b8c5db6e98072bb7bfe7899edc79b 21-Apr-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: A2DP: Handle ENOTCONN error when writing audio

We're seeing an error that ENOTCONN returned at writing
audio indicating that the transport endpoint is not connected
anymore, but bluez didn't notify CRAS to suspend or reconnect
in this case to recover from this error state. Moving headset
far away from Chrome OS device is a way to reproduce it on
some platform.

Currently when this issue happens, user will get no audio
from BT headset, and system will be spammed by error log
from unified_io(). To handle this error, add the mechanism
to tell main thread to force suspend the a2dp iodev, user will
see their headset gets 'unplugged' and then reconenct by themself.

BUG=chrome-os-partner:27450
TEST=Add code to fake the ENOTCONN error in cras_a2dp_iodev.
Verify when the fake err happens, a2dp device is removed from
UI and audio gets transfers to internal speaker.

Change-Id: I4c01619fe7f6dd4fb2cfa187a3f4a32a58b62f20
Reviewed-on: https://chromium-review.googlesource.com/195815
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
15e137c3cc39fafffc303b5612de7a4de7a27982 12-Sep-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS a2dp: Don't get more then requested buffer

In some cases, we got EAGAIN when write audio to
a2dp socket, and that could happen due to sending
samples too fast.

Before this change, a2dp iodev could tell audio_thread
to put more buffer then what was requested. Which
will cause more samples written then what was expected
to be written in one 2dp socket, and that could happen due to sending
samples too fast.
regular period.

BUG=chromium:244615
TEST=None

Change-Id: Id15ecec3cddfc544f8d30587752025331ef4c254
Reviewed-on: https://chromium-review.googlesource.com/169088
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
76d8edeed8b883d910965587549c59a766d251e6 11-Sep-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS a2dp: Tweak a2dp iodev buf number

In some cases, we got EAGAIN when write audio to
a2dp socket, and that could happen due to sending
too many frames then the buffer limit at BT headset
side.

We cannot query how many frames could queued at BT
headset side. To prevent sending too much then it
could accepts, set buffer size to just one MTU size
before encode.

BUG=chromium:244615
TEST=None

Change-Id: I88a909a9a3b026a3d9040bb056564c25f8011e29
Reviewed-on: https://chromium-review.googlesource.com/169087
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
9f02b64519595d12ec2346ea699c9507b01437c9 03-Sep-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS a2dp: Fix audio dropout for some headset

There is missing precision when estimating the virtual
buffer of remote device. When incrementally calculate
the queued buffer between callbacks, the missing small
amout of frames summed up and altered the frame rate a
bit and cause audio dropout.
The fix is to record the start time when device opened,
maintain the number of all written frames since then,
and calculate the queued frames from these info in each callback.

BUG=chromium:265940
TEST=Manual test with Sennheiser 500-X, hear no glitch at all.

Change-Id: I92e6a22e56556f31b0f9fc27011f24b9212dade3
Reviewed-on: https://chromium-review.googlesource.com/167850
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
dd2f666a53a1090744819bf38cd672b4548aca22 25-Jul-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS A2DP: Use a2dp device's human readable name

Whenever it's available use device readable name
instead of address as cras iodev's name.
Fixed a bug when update transport property, that
the 'Device' field should be parsed as object path.

BUG=chromium:264336
TEST=Connect bluetooth device. Chrome UI should display
readable name in device list now.

Change-Id: Ic885d5f8b57543b3a602fc871ae6b261f75368a6
Reviewed-on: https://gerrit.chromium.org/gerrit/63451
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
0b48706599ecf6372671a544ab6e3e85f5c81657 09-May-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS a2dp: Fix a2dp iodev switching

Use cras_iodev_add_node and cras_iodev_rm_node to
add and remove nodes to a2dp iodev, so it hooks
to dbus API and can be auto switched to.

BUG=chromium:239458, chromium:175798
TEST=emerge adhd, use Chrome UI to connect and disconnect
to bluetooth speaker, verify auto-swithing works good.

Change-Id: I5c1dceda01a720e6f9e9cf49ecbf9791427ef083
Reviewed-on: https://gerrit.chromium.org/gerrit/50758
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
71aa1de70c395c3648ede3eec5838ac7c64646d5 02-Apr-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Only free dsp context when then iodev is destroyed.

We had a problem that the audio thread closes the iodev and frees the
dsp context while the main thread is still using it. Now we avoid the
problem by only freeing the dsp context when the iodev is destroyed.

BUG=chromium:189214
TEST=make check

Change-Id: Ia16ece72523866d77f78e47cf26ff1308bd75b22
Reviewed-on: https://gerrit.chromium.org/gerrit/47108
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
f3df2ca6f9d8180969c00ec48f37b717069c8811 04-Feb-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS BT: Bluetooth queued frames calculation

The total queued frames can break down to three types:
- Queued frames in bluetotoh transmission
- Queued frames in a2dp buffer
- Queued frames in pcm buffer
Since there no way to query queued frames from bluez, we
maintain a virtual queued frames value as frames written
and time passed.

BUG=chromium-os:38228
TEST=Unittest. make check;

Change-Id: I769f6bece0b1020ed9dce5473e94d5aa3c40c09f
Reviewed-on: https://gerrit.chromium.org/gerrit/45111
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
38cc0db5a86cfc6145df903e87e866d6221407ff 30-Jan-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS BT: Create avdtp_write and a2dp_write

Implement get_buf and put_buf callbacks for cras_a2dp_iodev.
cras_sbc_codec does the transcode job from pcm buffer to
a2dp buffer before write to the stream fd acquired from bluez

BUG=chromium-os:38228
TEST=Unittest. make check;

Change-Id: I9ec495d3af1d016bf415bd75d89edc36649b31ee
Reviewed-on: https://gerrit.chromium.org/gerrit/45109
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
6f71f72193bbda4d9468b579a9a3a156fe61ecdb 23-Feb-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS BT: Add a2dp_info structure

Create a2dp_info structure to hold codec and encoded buffer
as well as the info we need in rtp header and payload, which
will be used later for transmitting encoded frames.

BUG=chromium-os:38228
TEST=Unittest. make check;

Change-Id: I0eebb5dc12c03c561dd85b5bcbef781759ae996f
Reviewed-on: https://gerrit.chromium.org/gerrit/45108
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
1cbde1fb3f2aad5494f33d49dacaeafebc753ac2 08-Jan-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS BT: Add cras_sbc_codec to bt_iodev

Create a cras_audio_codec for each bt_iodev and
config cras_sbc_codec by requested capability

BUG=chromium-os:38228
TEST=make check;

Change-Id: Id93fd7dd621a7505fdd35a5b4c353b94e11faf00
Reviewed-on: https://gerrit.chromium.org/gerrit/45107
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc
31635aee19f32c75657411865c4d3a4abec9dc56 08-Jan-2013 Hsin-Yu Chao <hychao@chromium.org> CRAS BT: Add cras_a2dp_iodev

Basic implementation of cras_a2dp_iodev.

BUG=chromium-os:38228
TEST=Unittest. make check;

Change-Id: Ida8f93deee4dab94e03ba8de888c112131e817ae
Reviewed-on: https://gerrit.chromium.org/gerrit/45106
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/tests/a2dp_iodev_unittest.cc