History log of /external/adhd/cras/src/server/cras_rclient.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ee4e108ef76b42691f22ab5821d848bc01599599 29-May-2016 John Muir <muirj@google.com> CRAS: Server-side for cras client notifications.

Add new messages for notifications and registration for
notification. Implement server-side registration with the common
observer.

BUG=None
TEST=Added unit tests for server-side notification
registration and notification message generation.

Change-Id: I7220a510e558b7785b2cb0e1ddaa3cfaa899f185
Reviewed-on: https://chromium-review.googlesource.com/348655
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/server/cras_rclient.c
8bc976545c90c84ae43429a6041caf950dcd2fee 27-Jan-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: client - Add functions to get/set hotword models

Add cras_client_get_hotword_models() and
cras_client_set_hotword_model() to cras client.
These new functions will be used by hotword stream to
query system supported models, and set hardware to one
of the models.

BUG=chrome-os-partner:39227
TEST=Apply full patch series and use test client to
set/get hotword model.

Change-Id: I37c2f5d14fa70d1e5694b2e9f25a5ad2e2764263
Reviewed-on: https://chromium-review.googlesource.com/324401
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/server/cras_rclient.c
f4d68a96948ce913348cc35ba34d9202014a9bdb 16-Mar-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: client - API to config global remix

BUG=chromium:593218
TEST=Play left/right speaker test on YouTube.
"cras_test_client --config_global_remix 2:0.5,0.5,0.5,0.5"
to verify that both channels are mixed.
"cras_test_client --config_global_remix 2:0.1,0.9,0.9,0.1"
to verify that both channels are switched.
"cras_test_client --config_global_remix 2:1,0,0,1"
to verify left/right channels are back to normal.

Change-Id: I4386cc3e14a9645dfee3649243cce23a051a0b04
Reviewed-on: https://chromium-review.googlesource.com/333251
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/server/cras_rclient.c
c32f7fdd0c91929a43bb854b02969d9840d639c1 13-Nov-2015 Dylan Reid <dgreid@chromium.org> CRAS: rstream - use posix shm for stream audio.

Change over to posix shm so an fd can be passed to a client in another
namespace and the client can play or record audio.

Change-Id: I72991117f0178b55a56980480f90a8e8257390fc
Reviewed-on: https://chromium-review.googlesource.com/312772
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
04596a2affd4624370bdc2d18a93f15132cf3e94 14-Nov-2015 Dylan Reid <dgreid@chromium.org> CRAS: system_state - use posix shm

Use posix shm instead of SysV shm. This is done so that the client can
be passed an open fd to the shm region. Passing the fd is more secure
since before anyone in the cras group could access the state. More
importantly this allows for the client to access the state even when it
is running in a differen IPC namespace than the server.

Change-Id: Iedb1fc753dc0fdc415862cb96ca97ceae3a8111d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312771
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
c516d3829b771383670149ee0f19b6404ced8f5c 13-Nov-2015 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Add fd sending interface

Expand the function used to send messages to the client to include an
optional array of file descriptors.

Change-Id: I95808f106edbf62ba904990fb105d7f5956465cf
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312770
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
1587fb0a36b053045f780d168bec1868ca98e65d 13-Nov-2015 Dylan Reid <dgreid@chromium.org> CRAS: send client messages with send/recv

This will allow for FDs to be passed to the client when necessary.

Change-Id: I3403404f2ba9851e58178b929994a3d1e6eabdf5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312548
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
2eac24b5c760e73a9fda04374d43a1000cb0a74a 26-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: move rstream create/destroy to stream_list

Create rstreams when adding them to the list. Destroy rstreams when
they are removed from the list. This will allow for delaying the
destruction while they drain. Keeping creation and destruction in one
file makes managing the memory easier too.

Change-Id: I7772337a4af715e83fb53e2d4e7f76034df74801
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262713
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
37972eb088d1f05664f0d6b5645e94cbbfdafeac 25-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Move some book keeping to rstream

rclient was managing setting the audio fd and notifying the system_state
when an rstream was added. Move that logic to rstream. This will allow
for easier passing of rstream to stream list to facilitate draining the
stream before removing it.

Change-Id: Id3570b715532d57d712902a0708d1db4435804f0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262513
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
b007fb330860d3e9b5a8b6a630a0196f2c3794b3 25-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Handle suspend/resume from main thread.

Stop all streams and devices when entering suspend.

Change-Id: I843312e39a4a31332b6b490ab31125a36c2429d9
Reviewed-on: https://chromium-review.googlesource.com/262511
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
4021be1c5d578d8f0d84dfc33fcfa1633964a970 24-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Open iodevs from the main thread.

This is the bulk of the changes needed to move open and close calls to
iodevs out of the audio thread. Having them in the audio thread is
causing glitching because they take an undetermined amount of time.
Commits following this one will address draining of streams and devices.
With this commit stream and device draining are broken.

iodev_list now manages which devices are opened. This is determined by
when a stream is added to the device. rclient adds streams to the
system, iodev_list registers a callback for when a stream is added or
removed. iodev_list then determines which devices should play the
stream, opens them if necessary and tells the audio thread the device is
open and which streams the device should service.

Change-Id: I8c462f6ef3075fc01d7fe3f65c53cd67fdcbc260
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262510
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
a7978895f3f660c5691887f83fda26169013247d 14-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Use stream_list instead of per client list

For now this doesn't change anything functionally. In future commits,
stream_list will become the canonical list of streams that are attached
to the system.

Change-Id: I18060b4cbd617da7362153eba1ff8828782130b4
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262506
/external/adhd/cras/src/server/cras_rclient.c
667f5817aa3033c437253a484f9b6844b62220a9 04-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Handle suspend/resume requests

Add the ability to tell the audio thread to suspend all iodev activity.
This can be used to make sure everything is in a stable state before
system suspend. Don't close hotword streams so they can work while the
system is in S3.

BUG=chromium:463756
TEST=suspend and resume audio with the test client:
cras_test_client --suspend 1

Change-Id: Ieb6c008abb4d0c7a8b638f6954cedb59c6893de0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256153
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
d2e9422bfcc4879e8f26b956173a8cd38b3057f0 26-Sep-2014 Chinyue Chen <chinyue@chromium.org> CRAS: audio_thread - Add pinned stream.

The change handles requests from clients to create a pinned stream.

BUG=chromium:407957
TEST=Tested on peppy with youtube playback.

Change-Id: Ia4695469770fd97ef830a31e748fa6e6a817ce22
Reviewed-on: https://chromium-review.googlesource.com/220096
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Trybot-Ready: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
a37abd9b84aefd5758d18579a930c9b38b5ad65e 03-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: add test hotword commands

This creates the ability to send a command to a test iodev. This will
be used to feed hotword data to the hotword test iodev.

Change-Id: I25822c661e6fdb9441352b4448c455873b53b573
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233105
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
cc13562bff05f6b254983c450a32a34090ee3a7f 02-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: Add interface to add a test_iodev

Plumb a message and argument from the test client to add a test iodev
to the server. This will be used to add a hotword test device and
fake wake up buffers.

Change-Id: I9fb244297a52faf55e4f1dda853e378e3c401860
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233103
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
71531caea43173e3d81e66415d2df6266fea82d4 03-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: rstream - save flags.

The flags will be used now, save them when creating an rstream.

Change-Id: I2d0b2dc59c1800340c49bd990f9f4d6e7a238de0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233058
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
7d14eca9008fda484e4e3e34be33915480c3d436 24-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Major changes to device switching.

iodev list no longer needs to set active devices.

System wide volume and mute don't make sense to call back in to the
active device. Volume is run through the devices now anyways. Mute
will be affected by zeroing samples.

Devices are now activated to deactivated by the audio thread. Any
number of devices can be active for input or output at a time.

Change-Id: I8928420fe3b22c8a1d5d226abade91378c9feae0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219974
/external/adhd/cras/src/server/cras_rclient.c
b9a58b6cf58ce1fde5e8b94577fc9faf476c0d56 03-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Only set dev format from the audio thread.

Since the format converter now lives in the audio thread, there is no
need to update the format of the rstream based on the device format.
Now set the device format when adding the first stream in the audio
thread.

BUG=none
TEST=unittest, plus play and record audio with multiple test clients.

Change-Id: I7288529e73a27b78a60c9076442577018e4aa47e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217174
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
0df9b2c9c0b87e30e8b958264a82c56c2cd964e8 28-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Accept the remote stream format.

Always accept the remote stream format when a stream is attached. The
format conversion is now done in the audio thread, allow the client to
send whatever it wants.

This change will cause the client never to do format conversion, and
instead rely on the audio thread to convert to the format of the
device.

BUG=none
TEST=unittest, play record audio on blaze.

Change-Id: Ib6261a640cc237f74e92ee37ce555914d047a43e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217170
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
c378b8b7289d9c18b221069f1644fcae765eb47c 09-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: rstream - Remove unused flags variable.

After three years we haven't found a use for flags, remove it.

BUG=none
TEST=make check

Change-Id: I4a3e7af0c23a27d5fedac8f3a21bd5d7aa6580da
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216542
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
93c9c7ce9f60b4ae16831a2b578b637e3df66792 09-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Rename remote format variable.

No functional change, just rename the variable from mfmt to
remote_format. This variable holds the unpacked format from the
remote client. Using this name will make the code more legible when
doing server-side format conversion.

BUG=none
TEST=none

Change-Id: I8c32311a19be126f1a3145c888e623a1bba3c40b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216541
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
cb99d2e634b6b8a848715df1ffd80a34125a9d0b 09-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: Fill stream_attached message with a pointer.

Pass a pointer to an audio format instead of copying the format.

BUG=none
TEST=make check

Change-Id: Ie1bcaa127b177566622b52aba9d2768e31a3e034
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216540
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
b52bb1c97e6420ce2e1c27a68c9d23576c6412f0 09-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: Remove min_cb_level.

min_db_level hasn't been used in a very long time, for input it is
totally ignored for output it was always set to cb_threshold anyways.

BUg=none
TEST=make check, and play audio on Blaze

Change-Id: I230c763d1db8e4816fe45e146c6afdc39438f132
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/216509
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ddab985b9d96e8a3b386079c620422c1aab557a9 25-Jun-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: dbus: Add more methods for Add/Remove active node

Add three more dbus methods: AddActiveOutputNode,
RemoveActiveInputNode, and RemoveActiveOutputNode. Chrome
will use these method to control additional active devices.

Note that the multiple active output support is not ready
in CRAS, so when more then one active output nodes area added,
it's expected audio only comes out from the first active dev.

BUG=chromium:388628
TEST="dbus-send --system --print-reply --dest=org.chromium.cras
/org/chromium/cras org.chromium.cras.Control.AddActiveOutputNode"
as well as other new dbus methods and cras_test_client --dump_s
to verify they all work.

Change-Id: I6758225564b904b810f80bd1b998d540943157a4
Reviewed-on: https://chromium-review.googlesource.com/205396
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
7fe6cf81920c6bc6631a932f238f9106bd0b1671 07-May-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: test client: add active node from cras_test_client

Add argument "--add_active_input" and "--add_active_output"
so that cras_test_client can be used to pull nodes to active
input/output list.

BUG=chromium:360338
TEST=cras_test_client --add_active_input 7:0 on Pixel.

Change-Id: Ia6b314d86342e3c829e4d2b0d2027e1beb2e53c0
Reviewed-on: https://chromium-review.googlesource.com/199046
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
20caa269b731aec507f88ad47288e08aace42c53 12-May-2014 Owen Lin <owenlin@chromium.org> CRAS - Move the ownership of rstream from rclient to the audio_thread.

The audio in the buffer of the rstream needs to be played even when the client
has been disconnected. Let the audio thread own the rstream since it knows best
when the audio data is not needed anymore.

BUG=chromium:304259
TEST=Run unittest and chrome on peach-pit

Change-Id: I6cc2667c21cc99f04366aeb7f118342fcea70544
Reviewed-on: https://chromium-review.googlesource.com/199459
Reviewed-by: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Commit-Queue: Owen Lin <owenlin@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
b00a478a7d594015045fb2db84232863cea5206e 08-May-2014 Hsin-Yu Chao <hychao@chromium.org> Revert "CRAS: rclient - Set output dev format better."

This reverts commit f1afea277e220d47096bdb3d2059d8eb1f166e73.

The revertred commit was added in the context that each active
input/output iodev has its own audio thread. So that when unified
stream connected while a output thread running, need to recreate
the thread to make client streams re-attached.

This change becomes confusing since now we only have one thread
running for input/output/unified, so revert it.

BUG=None
TEST=Play youtube, and then cras_test_client --unified_audio to
verify can hear both stream.

Change-Id: I0280d0a5aca3d261382834bd2a64d9a3d01669ff
Reviewed-on: https://chromium-review.googlesource.com/198835
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/server/cras_rclient.c
e1b00bcc04cef0f1b707a216ff4f08a5352da36b 17-Apr-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: client: Remove unused interface

Remove unused cras_client_switch_iodev interface and
CRAS_SERVER_SWITCH_STREAM_TYPE_IODEV message.

BUG=None
TEST=None

Change-Id: I4634085ad565da4c832a5a4043320fc453d8aafa
Reviewed-on: https://chromium-review.googlesource.com/195384
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/server/cras_rclient.c
673484dfdfd3ac922cb549e1b09b48b4e0d3bfdd 27-Mar-2014 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: Fix a bug in disconnect_client_stream

Stream direction should be recorded before the stream is freed.

BUG=chrome-os-partner:336459
TEST=Test on peppy. Make sure youtube can play normally.

Change-Id: I5635732f68e2e2380c083fed9d9a09b0f365ef0f
Reviewed-on: https://chromium-review.googlesource.com/191809
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
57852ea82d5f4c4491f4cfe9faafc5cbddfc4979 24-Mar-2014 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: Track number of active streams of each direction.

Currently we only track and provide number of total active streams
to dbus user. We want to expose a new API to provide number of active
streams of different directions. This CL changes num_active_streams
in cras_server_state struct from an uint32_t to an array.
The setter and getter method are provided in cras_system_state.
Also, the elements in the array is updated when a stream is connected
or removed.

BUG=chromium:336459
TEST=make check

Change-Id: I74328398a216c5fa277ef88935d341d31d18bb97
Reviewed-on: https://chromium-review.googlesource.com/191244
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
aed6ee2f614bcb3b6e325828abd9780784967b3c 03-Feb-2014 Nicolas Boichat <nicolas@boichat.ch> CRAS: Make shared structures architecture-independent.

This allows x86 clients to connect to x86-64 server: mainly useful
for crouton as users want to play sound from x86 binaries running
in their x86-64 chroots.

In all structures that are shared between the server and client
(via shm, or messages), we get rid of size_t, long, and timespec,
whose size depend on the architecture. We also pack all structures
to make sure alignment is the same across platforms.

We replace size_t by uint32_t, and long by int32_t: no change on
x86/arm, and 32-bit range is more than enough on x86-64.

We assume that sizeof(enum) = sizeof(int) = 4, which is true on
x86/x86-64/arm with GCC (using default compilation flags).

We replace timespec by a fixed-size cras_timespec, where both fields
are 64-bit signed integers (as on x86-64, x86/arm uses 32-bit ints).
This will cause problems when x86 client connects to x86-64 server,
after year 2038 (could be fixed by a simple bit masking).

Finally, the interface in cras_client.h is kept unchanged to maintain
binary compatible with chromium. Some structures are used both in
cras_client.h and shared structures, and therefore may cause problems
if they are converted to fixed-size.

The following are not used by chromium, and therefore can be safely
converted:
- struct cras_iodev_info/cras_ionode_info: Passed by pointer to
cras_client_get_{intput/output}_devices.
- struct cras_attached_client_info: cras_client_get_attached_clients

On the other hand, struct cras_audio_format, passed as parameter to
cras_client_stream_{stream/unified}_params_create and
cras_client_format_bytes_per_frame, are used by chromium, so its
size cannot be changed.
To work around that, a second structure, cras_audio_format_packed
is used in shared structures, and converted back and forth as
required.

BUG=chromium:309961
TEST=Audio input/output still works (e.g. try a Hangout session)
TEST=In crosh, developer mode: 'cd; arecord -f dat -d 5 > x; aplay x'
records 5 seconds of audio, then plays it back.

Change-Id: I12d851fbbdec5fbb222dc156b5e13316f6c91e30
Reviewed-on: https://chromium-review.googlesource.com/189204
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: <nicolas@boichat.ch>
Tested-by: <nicolas@boichat.ch>
/external/adhd/cras/src/server/cras_rclient.c
6d785f2e9175478aac2cdd4962b6175f8dee5b34 30-Jan-2014 Dylan Reid <dgreid@chromium.org> CRAS: dump audio debug info from client.

Instead of dumping audio thread debug info to syslog, pass it back to
the client through shared memory. The extra data in shared memory isn't
protected or synchronized, but only one client at a time should ever
access it.

Change-Id: Ie5864b1a3f82a079ed1182b119b05c86976aadda
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/187006
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
1616d8d99d44b29e8fbbad777a779bdad3fbd90a 18-Dec-2013 Dylan Reid <dgreid@chromium.org> CRAS: cras_rclient - Force an even buffer size.

Buffer size is halved to get callback threshold, make sure it is even so
we don't end up off by one for callback threshold. The callback
threshold is all the client cares about, and it is still allowed to be
odd. So far odd sizes only happen when sample rate converting.

BUG=chromium:327817
TEST=go to google play and check buffer sizes (it makes both a 48k and
a 44.1 stream).

Change-Id: I6af50bd1d8445e25bdc6ec8904e9f8dc74808692
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180674
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ea5981fe207266990ec8a119ed13c139b36c1f1d 02-Oct-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Remove DL_FOREACH_SAFE because DL_FOREACH is also safe now.

BUG=none
TEST=make check

Change-Id: Iab32c7afb9c7a97fbc2f246b6c3e6130afd628f7
Reviewed-on: https://chromium-review.googlesource.com/171704
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
8906982340dde76df621f568f52c267b62ea76c1 20-Sep-2013 Dylan Reid <dgreid@chromium.org> CRAS: Add ability to dump active streams to log.

Add a test_client command to dump the currently active streams to
syslog. This is just for debugging.

BUG=none
TEST=run cras_test_client --dump_streams

Change-Id: I903fa039533660ee7a662ac2f7e45953cfaef676
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171560
/external/adhd/cras/src/server/cras_rclient.c
1a5a01f06adb1f7197b504d9b6296287bd5a8f09 20-Sep-2013 Dylan Reid <dgreid@chromium.org> CRAS: rstream - Don't track thread.

There is now only one audio thread in the server, no need for each
stream to keep track of which thread it is attached to.

BUG=none
TEST=play/record audio on Link.

Change-Id: I7c84a81d9a5778464ecaf7b27a5e59cc4151a728
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170111
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ea65061a32701000f411db5e9beb00d9f0dea0ff 19-Sep-2013 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Clean up fd and rstream in add_stream.

If the reply to acknowledge that a stream has been added fails, make
sure to clean up all the bits that have already been allocated. This
will also try to send an error response which won't likely succeed,
but won't hurt either.

BUG=none
TEST=play several streams on link.

Change-Id: I1509eb88dd3db4baa275d14ae6485bd0cb56b231
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169929
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
948be308fcd7c04bfdb7c154dd6ef90e5fc61070 10-Sep-2013 Dylan Reid <dgreid@chromium.org> Revert "CRAS: audio_thread - Remove volume/capture gain init from open_dev."

This reverts commit d4805ffad9c2182d4ee715a969548a3c265f97e1.

This won't be needed since we aren't pursuing the no-server audio
path. It also introduced a bug when un-muting without an active
stream.

BUG=chromium:285334
TEST=unmute at login screen, log in make sure it is unmuted.

Conflicts:
cras/src/tests/rclient_unittest.cc

Change-Id: Iea99bbd56a2bcf798d1d1d35ebe19945042046ea
Reviewed-on: https://chromium-review.googlesource.com/168801
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
47618524acd185f8d4cb788fc3d603ff81a9499c 10-Sep-2013 Dylan Reid <dgreid@chromium.org> Revert "CRAS: cras_rclient - Init vol/cap gain by node instead of directly."

This reverts commit 88590fe2d603f341a685bb6a6d758db1e717182a.

This won't be needed and makes the following revert cleaner.

BUG=chromium:28534
TEST=manual, make sure volume is set correctly when starting a stream.

Change-Id: I8f0ac4ad42862c54622c0c24a48eab19f74716e5
Reviewed-on: https://chromium-review.googlesource.com/168800
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
88590fe2d603f341a685bb6a6d758db1e717182a 07-Aug-2013 Adrian Li <alhli@chromium.org> CRAS: cras_rclient - Init vol/cap gain by node instead of directly.

The volume/capture gain needs to be initialized explicitly when a
stream is first added to the audio thread. Previously this was done by
a direct call to iodev->set_volume/set_capture_gain. Here we instead
set the volume/capture gain of the active node, which in addition to
calling iodev->set_volume/set_capture_gain, also runs the
volume/capture gain notifications and callbacks (which in particular
also now sets the software volume).

BUG=chromium:264890
TEST=Ran gmerge adhd, verified that speaker/headphones still
initialize volume correctly. Ran unit tests, all pass.

Change-Id: Ibb40962c29222ce9c3ca8e9a7fb2805b55954464
Reviewed-on: https://gerrit.chromium.org/gerrit/65029
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Adrian Li <alhli@chromium.org>
Reviewed-by: Adrian Li <alhli@chromium.org>
Tested-by: Adrian Li <alhli@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
d4805ffad9c2182d4ee715a969548a3c265f97e1 05-Aug-2013 Adrian Li <alhli@chromium.org> CRAS: audio_thread - Remove volume/capture gain init from open_dev.

The ALSA open_dev calls init_device_settings which either sets volume
and volume limits (for output devices), or capture gain and capture
gain limits (for input devices).

Because the volume and capture gain are controls specific to each
device node, we wish to separate them from any audio processing that
occurs on the audio thread (including open_dev). This is necessary if
we wish to later on decouple the audio thread from the device
list/server.

First we remove init_device_settings from open_dev. This will mean
that the volume/capture gain is not reset correctly if a stream is
opened on a previously closed device (this is when open_dev is
normally called).

However, by moving the volume/capture gain calls to cras_rclient
whenever the client connects to a new stream, the volume/capture gain
will still be reset correctly in the above scenario.

Therefore in practice, the user experience should be consistent with
before.

The ALSA unit test has been updated to reflect this change. The
rclient unit test has been updated because of segmentation faults
(bogus calls to set_volume and set_capture_gain).

BUG=chromium:264890
TEST=Ran gmerge adhd and tested opening streams, plugging in
headphones and changing volume. Top-level behaviour is still
consistent.

Change-Id: I9f22b1f55c8fb59bfa516af3d6b8bfb6fa4b8177
Reviewed-on: https://gerrit.chromium.org/gerrit/64675
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Adrian Li <alhli@chromium.org>
Reviewed-by: Adrian Li <alhli@chromium.org>
Tested-by: Adrian Li <alhli@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
0e5fc2e0264e7adf3ab4f39d6be156fc53114544 18-Jun-2013 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - one audio thread per system.

Instead of having an n:m relationship of streams to threads, make it
n:1. The system now has one, always present audio thread. This will
allow for the only audio thread to handle loopback streams as well as
input and output.

BUG=chromium:247160
TEST=play and record audio with test_client.

Change-Id: Ifce29f6e1395c8474337b498b265ddf5d004f549
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60232
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
59d127ae6daef05f03dbd336a66dfbfa2f208c81 22-May-2013 Dylan Reid <dgreid@chromium.org> CRAS: Add separate mute for user vs system.

Mutes currently come from two places, powerd and Chrome. The powerd
mutes shouldn't result in a mute notification to the user.
Differentiating between the two will prevent confusing Chrome and the
user.

Leaves the old mute path in place. Chrome can switch to the new user
mute api when it is ready.

BUG=240814
TEST=Set user mute manually with:
dbus-send --system --type=method_call --print-reply --dest=org.chromium.cras /org/chromium/cras org.chromium.cras.Control.SetOutputUserMute boolean:true

Change-Id: Ia6eac4e611eca2a3d816ed5718ab31e4be491115
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56110
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ea1b78a018d72fd22f5ce5650121f5e4b8325a1d 06-Mar-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Make a standalone select_node API.

Node selection was done using set_node_attr API, but now selection is
not a per-node property. Move it to a standalone API.

BUG=chromium-os:33666
TEST=cras_test_client --select_output and --select_input

Change-Id: Ic2b82242d3270dfa3713156c56831bf59b0e05b1
Reviewed-on: https://gerrit.chromium.org/gerrit/44838
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
770ea30175b730e5b771eeae808bbf959e132c3e 05-Mar-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: In the set_node_attr API, use cras_node_id_t.

Instead of passing two indices, pass one node id. This makes things
easier to understand for the clients.

CQ-DEPEND=CL:44915
BUG=none
TEST=make check
Change-Id: If693e8c0368fdf3565ff63a43eef91f860b218e5
Reviewed-on: https://gerrit.chromium.org/gerrit/44835
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
54831a4bfe525d5e19bacdc4ccffcc3f229efde8 05-Mar-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Make device and node index use 32 bit integer type.

Make it clear that the index is 32 bit, not platform-dependent size_t.

Also add a cras_node_id_t typedef and utility functions to create node
id and extract index from node id.

BUG=chromium-os:33666
TEST=make check

Change-Id: I7b8e0a9be7bb907669a4710f4483db407d89888a
Reviewed-on: https://gerrit.chromium.org/gerrit/44833
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
d59b94ce647077ea9a4bb1c3593d32ac5ed02e22 23-Feb-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Rename and generalize the set_plug API.

Rename the "set_plug" API to "set_node_attr", so we can reuse this path
to handle node selection in the future.

BUG=chromium:160311
TEST=make check

Change-Id: I8a58c7701680753334265260defd1f436d4367db
Reviewed-on: https://gerrit.chromium.org/gerrit/43961
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
741ad2848629417c45ce2064b77cde0e26538f04 17-Jan-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: Add API to set plug state of an ionode.

BUG=chromium-os:35238
TEST=make check
Change-Id: I31456e513801c494a964c2d5474aa39e2506b441
Reviewed-on: https://gerrit.chromium.org/gerrit/41528
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
15f94512221baa64e1ed7fd0a7b7c1c6f0c7a54f 29-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: Fix divide by zero when attempting to SRC from 0

When a client asks to play a stream at 0Hz, return an error regardless
of what rate the iodev is running at. There is no way to sample rate
convert nothing.

BUG=chromium-os:38332
TEST=updated rclient_unittest

Change-Id: I2872d48d1d683689177ba6e7da42bf2a8fac25c7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42205
/external/adhd/cras/src/server/cras_rclient.c
0dc69e07cfddacdc3ddbc70a0666d6fbd016520c 12-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: audio thread - handle dev open errors better.

If a device fails to open, remove it from the device list and try
again. Make sure that the audio thread doesn't run unless both
devices are open, check before starting the unified_io function.
add_thread can now return errors to the main thread so that it can
remove the iodev if there is an error.

BUG=chromium-os:37798
TEST=updated rclient unittest

Change-Id: I056155989e2c6152d8226ab84d0dae678ab6dcae
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41170
/external/adhd/cras/src/server/cras_rclient.c
313c038f73cce45ceb343badb509cdf0ff916e1e 11-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Check aud_fd arg first.

The check for aud_fd being valid can be done at the beginning of the
add stream function. Doing this here will fail earlier and make it
easier to add retries for bad iodevs.

BUG=chromium-os:37798
TEST=make check

Change-Id: Ia06eacb9242f7f112d3d75d6acab3f66995b97e6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41169
/external/adhd/cras/src/server/cras_rclient.c
19204f9d707f294cbe76cd65e541ab0732086012 03-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: audio thread - only free if not current.

Check if the output device is using the current thread. If it is
there is no need to free it and re-add to the device.

BUG=chromium-os:35272
TEST=updated rclient unit test.

Change-Id: I2496740f016f80e2bcd38f901be8ec1dcde47c81
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41048
/external/adhd/cras/src/server/cras_rclient.c
f1afea277e220d47096bdb3d2059d8eb1f166e73 03-Dec-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Set output dev format better.

The output device format shouldn't be set until after the thread is
created for unified streams. If the output device already contains
streams, its format will be reset when the streams are removed, set
the format of the iodev later in this case. It will be set in the same
place for output-only streams.

BUG=chromium-os:35272
TEST=play output then add unified stream, hear output continue.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Iff30a4818831066e367dbf6d97e9948307378ca8
Reviewed-on: https://gerrit.chromium.org/gerrit/41134
/external/adhd/cras/src/server/cras_rclient.c
ce41d7d5b4b71cc1f4865bb65ccaa94db058887a 03-Dec-2012 Dylan Reid <dgreid@chromium.org> CRAS: audio thread - Make destory remove all streams.

Instead of relying on the caller to call both remove_all_streams and
destroy, have destroy first remove all streams, there is no need to
keep an audio thread around without any streams attached.

Now handles adding a unified stream when already playing an output
stream.

BUG=chromium-os:35272
TEST=none

Change-Id: I5a99a19bc887056a612cc557241e1d0b816ab59e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41046
/external/adhd/cras/src/server/cras_rclient.c
3c698f3975096b7a92c6df2c0c69ea59e1942e81 30-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: Allow input and output device for each thread.

For unified audio there is a need to have one thread service both an
input and an output device synchronously. In this case the thread
will be initialized with the input device, then the output device will
be added. This doesn't yet handle moving streams already attached to
the output device.

BUG=chromium-os:35272
TEST=unit tests pass, and test unified audio with test_client.

Change-Id: Id98e248e9c0643dd37e00fb652c6bbf144546f5f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40968
/external/adhd/cras/src/server/cras_rclient.c
9edf52fea7a0fc8fa45b42b9efca38ed9e3ba96a 28-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: rstream - Store input and output shm pointer.

Allow a stream to have both input and output shm areas. Only one of
the two is used until a following commit enables unified input/output
streams.

BUG=chromium-os:35272
TEST=updated unittests and play audio tiwh test client.

Change-Id: I00f4b3090767f4f0c0d286a6b649b2719ea28ce1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40958
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
8e0d4c5910a5ccd329a14515abd52275c20a7802 24-Dec-2012 Chih-Chung Chang <chihchung@chromium.org> Add a command to dump dsp information.

BUG=chromium-os:36300
TEST=run cras_test_client --dump_dsp while playing audio
Change-Id: Id1933b243ede113bb1f9ce1e322dd0878bfc5337
Reviewed-on: https://gerrit.chromium.org/gerrit/40196
Commit-Queue: Chih-Chung Chang <chihchung@google.com>
Reviewed-by: Chih-Chung Chang <chihchung@google.com>
Tested-by: Chih-Chung Chang <chihchung@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ad410d2a09b511de286a90df4f764a0a94ec7ff2 21-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: audio thread - Set iodev from thread.

Instead of setting it from rclient. It was too difficult to determine
when to clear it from rclient, do that from the thread as well.

BUG=chromium-os:35272
TEST=make check

Change-Id: Ib21ce3517ee30f9899fd314d2449f13e4d38939d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40563
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
7fc1e5c45dcc48152bf77e32531789ed44c2d840 27-Dec-2012 Chih-Chung Chang <chihchung@chromium.org> Pass audio socket directly to the server.

Originally the server makes a connection back to the client for each
stream. Now the client just passes a socket to the server in the stream
connection message.

TEST=make check, play audio from browser
Change-Id: I88ec8e968f552056bd50a34d26340e8ce35f9434
Reviewed-on: https://gerrit.chromium.org/gerrit/40236
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
b3d3be29575bcc65ad8e7f888fab011c301c0633 07-Jan-2013 Chih-Chung Chang <chihchung@chromium.org> Allow server to receive a file descriptor with a message.

Change-Id: I0665f9e1a78d388779edd654ae954487ba911c40
Reviewed-on: https://gerrit.chromium.org/gerrit/40520
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
1504d20d0fde2e3850a56e4117a08f37ee388d60 05-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: thread UT - Don't rely on thread creation.

The audio thread unit test was relying on the running thread. This
isn't what needs to be tested and can lead to flakiness, instead, call
the thread functions directly from the test to check their output.

BUG=none
TEST=update unit tests.

Change-Id: I2d5be42fdcad7bfc6279659f2ba06cdf15e8988d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40277
/external/adhd/cras/src/server/cras_rclient.c
569a3a9f8c92d2a71db555109740470081b21ded 05-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: rstream: Track thread instead of iodev.

Continuing to prepare to have an input and output device for each
stream, don't track which device is attached to the stream, just track
the thread. If the device is needed, it is contained in the thread.

BUG=chromium-os:35272
TEST=make check; record and playback audio with the test client.

Change-Id: I5377e93a8ddb787277f6b51b59ea7f52ab3762c5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40276
/external/adhd/cras/src/server/cras_rclient.c
2c78ba503e3c97f90d4e8b0171c8e3ac50eada42 02-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: iodev - Create thread outside of iodev.

Instead of having the iodev create its own thread, create the thread and
pass it to the iodev. This will allow for iodevs to share the same
thread, enabling pairing input and output thread for unified IO.

This moves a bunch of code from alsa_io/iodev into audio thread as the
functionality will be common to all iodevs, not just alsa.

BUG=chromium-os:35272
TEST=updated unittest, plus, GTalk and YouTube on device.
Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: I90bcd53243c8564922d0e716ed5f3e176aff566e
Reviewed-on: https://gerrit.chromium.org/gerrit/40275
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
38ebf479872e48f8ed80605203f80d8cd39e3dae 02-Nov-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Add helper to close client fd.

The unit test was calling close(0). Instead add a helper that can be
stubbed to close the fd. This new helper mirrors the helper used to
open the device.

Change-Id: I52f656b173423e0dc5c65ed7aeb12f8e84537961
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/40274
/external/adhd/cras/src/server/cras_rclient.c
21c39b508b446f5f9af3b0f5196d9388f6cd72b1 18-Dec-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Check for frame rate of zero.

In case an iodev doesn't have any supported formats, or that a client
sends a bogus request, the frame rate could be set to zero. Bail
early if that happens.

BUG=none
TEST=updated rclient unittest.

Change-Id: Ia84e5a6cef444e65394b0ceda642487e1d78e15e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39837
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
9e26707b7ca729ea50eea2d2b69411f6ad036a04 13-Nov-2012 Chih-Chung Chang <chihchung@chromium.org> CRAS: DSP - Add a command parameter to reload dsp configuration.

BUG=chromium-os:36300
TEST=modify dsp.ini and use cras_test_client --reload_dsp to reload it
Change-Id: I43a5286dae159aa8d3ea3b6bba0186393aee8750
Reviewed-on: https://gerrit.chromium.org/gerrit/38386
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
045156126f648a9f0910152a66572a13447bfdc6 04-Dec-2012 Chih-Chung Chang <chihchung@chromium.org> CRAS: Move cras_iodev_set_format() from cras_iodev_list.c to cras_iodev.c

We will allocate a dsp context in cras_iodev_set_format() in a later
change, and this change makes iodev_list have less dependency to test.

BUG=chromium-os:36300
TEST=make check
Change-Id: I1a45a3ea16a87bbb50006c10ddd1431ef4aa2276
Reviewed-on: https://gerrit.chromium.org/gerrit/39237
Commit-Ready: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
60b39c162aee28998b79874c07dbaf2a40ea119f 05-Oct-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - remove extra print.

Connection failures are already logged in the connect function, don't
need to log them twice.

BUG=none
TEST=none

Change-Id: Ib66c185eb57be85aaa8be8639ac1e188476783dc
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34698
/external/adhd/cras/src/server/cras_rclient.c
b5b3f1b8c94478bbe1362659fef1a59e549ddf50 06-Sep-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - remove dead code.

Nothing checks if any streams have been played anymore, remove the
function that checked, and increment the counter with the active stream
count instead.

BUG=none.
TEST=updated unit-tests

Change-Id: I652a94dfb162448eac50af6a03900efbdd4787a2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32451
/external/adhd/cras/src/server/cras_rclient.c
8b8ecd1836a11584eb6779272289607d4d368803 31-Aug-2012 Julian Pastarmov <pastarmovj@chromium.org> Add the possibility to lock the mute state.

This feature is needed to implement a device policy for muting the sound
input or output on ChromeOS devices.

BUG=chromium-os:11263
TEST=unittest: SystemStateSuite.MuteLocked

Change-Id: Ie9c13d04a9e0a37cfe70aba426064a790f8a0bb7
Reviewed-on: https://gerrit.chromium.org/gerrit/29169
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Julian Pastarmov <pastarmovj@chromium.org>
Tested-by: Julian Pastarmov <pastarmovj@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
7c389cc81cfa38c8ce63acbbaa90ba07567a0b08 10-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: Remove now-unused messages.

Since these messages have been replaced by information in shared memory
remove them and the code supporting them. The client doesn't listen for
these messages and the server no longer needs to send them.

BUG=chromium-os:32347
TEST=aplay <file>, youtube and voice call on parrot.

Change-Id: I71f03aa0d13779b81bf8b132203224a4fc344b62
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29865
Reviewed-by: Olof Johansson <olofj@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
57aa92e2c31a516c7f3a9c9cfa90b207d75d3395 10-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Pass server_state shm key to client.

Add the shm key for the new server_state shared memory region to the
client connected message. The client needs this to access the state.

BUG=chromium-os:32347
TEST=make check, 'cras_test_client --dump_server_info'

Change-Id: I176535db315e0ebac3969255e4109cd66af0bbd3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29863
Reviewed-by: Olof Johansson <olofj@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
19b14f1bbc18b05185898408d227bc4c176dc7c6 19-Jul-2012 Dylan Reid <dgreid@chromium.org> CRAS: Route only based on card type plugged state.

This patch does several things to normalize the choosing of a default
device. This decision is made whenever a device is added or removed or
when a jack event arrives.

Remove the sorting of device lists at startup, the priorities of the
device are sufficient to determine the correct place to route audio.

Use this same logic to pick the default device when a device is
attached/detached, and when jack events happen.

BUG=chromium-os:32730
TEST=updated unit tests, Boot lumpy with HP, USB, and DP connected, plug
and unplug the devices and listen to audio routing to the most recently
plugged of HP/USB or HDMI if neither of those two are attached.

Change-Id: I3388f336003823bd89e4a3c704bde05fde46d041
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27946
/external/adhd/cras/src/server/cras_rclient.c
9d172a2dea4b0f81db9469f2b5706480a776804a 05-Jun-2012 Taylor Hutt <thutt@chromium.org> ADHD: Remove unused udev code from gavd / cras

As udev device insertion & removal is now handled by cras, it's now
possible to remove a bunch of unused code.

TEST=On kaen, verified that sound multiplexes through USB headphones and internal speakers.
BUG=none
Change-Id: I5abfd83854516947799ed92cfe138f70f9ce704e
Signed-off-by: Taylor Hutt <thutt@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
1f36300e583874324167fd5ebdab2bbdaf28fe36 29-May-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Sort iodevs before adding first stream.

Before the first stream is added, sort the iodevs. This achieves a
reliable initial priority of devices. After boot, there is no way to
know which devices were attached when. Instead we give priority to
external devices. After the first stream is added, any new devices
attached will go to the head of the list and remain there until they are
unplugged or another device is attached.

BUG=chromium-os:533
TEST=updated rclient_unittest

Change-Id: Ie46ac02920e5b9864dd8af2e7433a379ff95f0e8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
e5a0e71d5a3a30e47b658dda68e629fe66a5057b 29-May-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - Increment stream count on add.

When a new stream is added, increment the system-wide counted of
streams. This counter will be used to determine when the first stream
is added so that case can be handled specially.

BUG=chromium-os:533
TEST=rclient_unittest

Change-Id: I5eb0d74123a5aee53c560b96e47456796f2af9a3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
a43ba2db62e6b425cc9c47cf52c08bef2227e998 28-May-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add priority to iodevs.

Give each device a priority. This priority will be used to decide which device
to make the default at startup. For the initial decision there is no ordering
information to indicate where the user wants audio. We will default to external
devices, assuming they have been attached for a reason. A follow up CL will use
this to sort the devices at startup.

BUG=chromium-os:533
TEST=updated unit tests.

Change-Id: I9012f10d8de29c18c955b0bdce22948c5735359f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
b1783009dbc116799cf21615ed1356c55d4484f3 18-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Send capture gain limits with volume status.

Include the capture gain in the volume status message. This will be
used by the alsa control plugin to export a dB range for the capture
control.

BUG=chromium-os:25410
TEST=updated unit tests + cras_test_client changed to print capture gain.
Change-Id: Ib35091771a51d53179460eaeb45115636ba38a6a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
49453aa031a21a1793cfae948197ab934e17c6ba 18-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Send volume limits to clients.

When volume limits change, send a volume status update to all clients informing
them of the change.

Change-Id: I4596dbca91deecbbc174f38fd93dc33622aeb017
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
f1d0419ac73e60de69d5cf14e3c216fa50958fe2 15-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: rclient - add capture gain/mute to volume message.

When sending a volume status message, also include the settings for
the capture path.

Change-Id: I815d485716c8c0eda43e5d7667c94a6bde1b1814
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
2ef89302ffe07989aabc16edb2b865f5b12958fb 13-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add set capture gain message.

Add a message to set the capture gain on the server.

BUG=chromium-os:25410
TEST=rclient_unittest

Change-Id: I5a72051c05dca813b6ad82e287ccf9642dc4a25f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
16b9f01fe27560e67697ce25913850e3c123fd33 13-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Make server side socket writes non-blocking.

This will avoid problems where a client stops reading from a socket,
causing writes on the server to block. This is a preventative fix due
to Chrome having a similar problem in SyncSocket.

BUG=none
TEST=updated unit test, plus manually build a run CRAS.

Change-Id: I25bab9b17e40fc642d08c8d9e6e34afb3bdc380e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
961c42a4b7785f3979c478c853f3afe3ca0d9624 11-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Enhance logging for rstream creation failures.

Change-Id: I70efd8d166c16d5fbade23c9a6942ae517b6f3fa
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
1a14df6d6db60442b3b31d96d06320493ecff52b 11-Apr-2012 Dylan Reid <dgreid@chromium.org> CRAS: Send clients a message when volume changes.

When the system volume or mute state changes, send it to clients.
Send the message when the clients attach as well.

BUG=chromium-os:25409
TEST=updated rclient unittest.

Change-Id: Ie951396fc27c93676a46c88ec58e3b4f8553604a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
6c1a2a313100f043b710a6718359757b1d78e326 28-Mar-2012 Dylan Reid <dgreid@chromium.org> CRAS: Remove hack to supply system with cards.

Add and remove cards based on the device info message from GAVD
instead. For now just handle add and remove messages, later changes
will handle "change" messages and the indication that a device is
primary.

Change-Id: If710f377851b4f5a39f93ab4e69681732cc9577f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
58fe4e9053c78a9a5c2ea2027f4cc994fab4b3e3 27-Mar-2012 Dylan Reid <dgreid@chromium.org> CRAS: Rename system_settings to system_state.

This module is being used for more than settings now. It will soon
have the list of available cards added to it.

BUG=none
TEST=unittests and build and run cras.

Change-Id: Ia87c1a0cb40f9ebe1db7424784d858d1942c393a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
a38a8986f29ad72f3fb8f37bfa6b283fd9585003 13-Mar-2012 Taylor Hutt <thutt@chromium.org> cras: Add preliminary message for notifying of hardware changes

Details

gavd needs to be able to communicate device information to cras.
This will be accomplished through the cras command socket.

This change adds a 'device information' notification to the set of
commands that cras can receive.

At present, this API is not used, and it does nothing internally
other than logging the information provided by gavd. It is also not
yet used.

Testing

Using an upcoming change to gavd which publishes the device info to
cras, this change has been shown to function as expected.

BUG=NONE
TEST=See above

Change-Id: I3f8ece5571f2ddca48a4aae884a7b2f9e287605d
Signed-off-by: Taylor Hutt <thutt@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
cf18e0bf9b43a64a2fc9d1199f29f8d0b11da16f 17-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Giver server messages a better name.

They shouldn't be named CRAS_CLIENT_*. Now all start with
CRAS_SERVER_. Add comments to messages.h that give readers a hint as
to the direction of messages.

BUG=none
TEST=none

Change-Id: Idc2e550b344d4dc1e39036aaf1e03b218ea4485b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
cc4c32c33cfee712e251ff900dd7f16c77cc68f4 16-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add a message to set the system mute state.

Rclient now handles a message to mute or unmute the system.

BUG=chromium-os:25413
TEST=updated unittest

Change-Id: I130229ca880448cecadf018474d119d3872de1b3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ce098cb14b06b76b03a969e64885f9b09d20a642 10-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Split server and client message types.

Allows addition of server messages without messing up client message IDs.

BUG=none
TEST=make check and build and run on z600.

Change-Id: I2e5355fdcaf355a9f9223dcebe6645b7d272ee04
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
231684a12c97ec9e00cd2ad3e22edbfbf247b9e1 10-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Rename messages to CRAS_*.

These were named before CRAS had a name, get them up to date.

Change-Id: Ie54da2776e20d8eacd074ea32e2299200d383617
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
3db9734ae8737f0479d0f7e7d8d1749b13964998 10-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add a message to set the system volume.

Handle the new message in rclient by calling system_settings to set
the volume.

BUG=chromium-os:25411
TEST=added rclient_unittest case to cover passing message through.

Change-Id: I6be63493e95cc6db72ee076851819baf037e27f1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
59852aa44ff6f8394831ff7903d64127ea60ffbf 26-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add stream/client being removed to log message.

BUG=none
TEST=make check and run cras on Mario.

Change-Id: I587efa0745008bd8d6941c67a9076f5b12feb6e5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
ce895e7bb75a63c593bec7a5a36bfed3241ab829 26-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Name enums, and favor size_t instead of uint32_t.

Give commonly used enums names, and use the names where the enum
values were previous passed as basic types.
Favor using size_t to uint32_t where we just want an unsigned
type.

BUG=none
TEST=make check and run cras on Mario.

Change-Id: I3b81b5963025e4a522030bd736e5fd009fc3e8f8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c
d607546e16496ee8f0f8147d24d43bc993e5ed0b 19-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add rclient.

rclient is the server-side representation of an attached client. It
manages connecting to the clients audio socket, incoming control
messages, and send replies back to the client.

BUG=chrome-os-partner:6382
TEST=rclient_unittest and build and run for x86-mario and lumpy64.

Change-Id: Ibdb7c7aadfd0a8686a808df6be57bc82d167bb0d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/cras_rclient.c