CRAS: ALSA plugin: change node volume instead of system volume

Also, change user mute instead of system mute for output nodes.

This aligns ALSA plugin behaviour with Chromium UI.

BUG=chromium:415661
TEST=Play some random video with audio output, and test that both
     `alsamixer -V all` and Chromium OS change the volume of the
     current device (speaker or headphones).
TEST=Also check that changing capture volume in `alsamixer -V all`
     changes the input gain on the active device, provided the
     device supports it.
     (check with `cras_test_client --dump_server_info`).

Change-Id: Ia3d190db75eed9056164ffd76a59a4b5a0137c3f
Reviewed-on: https://chromium-review.googlesource.com/218941
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
CRAS: Keep next callback time per dev_stream.

For each stream, save the time it should next be serviced.  This time
is start + n * callback_number.  Add one callback threshold of sleep
time after every callback.

This time will later be used to better calculate when to make
callbacks to a stream.

Change-Id: I210329b320bdd0b9b885ad1d3ce0d50b166083f0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Prefill with more zeros for min_buffer_level > 0

If a device has min_buffer_level set, start with cb_threshold +
min_buffer_level samples.  Without this the device will need to make
more than one consecutive callbacks to get filled to the appropriate
level.

BUG=none
TEST=play audio to BT and USB

Change-Id: Idc5ca851433bbd217a46ca40d5acc3e465f6690d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Prefill shm for output streams.

Instead of dumping zeros into the output device, mark a buffer as
ready in the shared memory region.  This way it works for streams that
aren't the first ones added to a device.

Change-Id: I103858a54f588e62cff1116087df09fcfa74e7ac
Signed-off-by: Dylan Reid <dgreid@chromium.org>
wip wake up based on a timer not on frames. unit tests break here

Change-Id: Ibb94ec43cc709d6f2a97a7dd16e21accf63b2608
add logging for new wake ups

Change-Id: I7fef15e31cba6af795414b7a5381a5b063138701
add dev_sleep but don't use it yet

Change-Id: Idbdd1e63af6153c5305840b7a25a8ebcae3385cb
wip: don't wait for streams

Change-Id: I646f453cd9ec0efb9e06271c1294f2c3afb7feb7
wake up for draining streams

Change-Id: Ibb63657de0587f465b67ef5fa95304d9fac3baaa
sleep extra time for capture

Change-Id: I17db4a8d21d2ea3871a5d4a48b7d3fff4c5bcb1c
squash with something about capture

Change-Id: Ia8def5200a8e5ee1d12d2a36a7f19fee4ce492d3
don't poll draining streams

Change-Id: Id7f037c1d9d51b97e4db84551fe6371a01af6f13
set dev times for all odevs

Change-Id: I65349e42fd351d444b9da6020bbd049524f93947
CRAS: audio_thread - Remove level arg to write_streams

write_streams now only logs the level, it doesn't actually use it.
Remove the argument and the supporting functions to generate it.

BUG=none
TEST=play/record audio to USB on Big.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - pre-fill device when openning.

When a device is opened it should be filled to the min level.  Filling
it at this point means that it will be filled on stream switch as well
as on stream addition.

BUG=none
TEST=none

Change-Id: I24e6818e42e8f25e21d96063ff4b042a104c04d4
Signed-off-by: Dylan Reid <dgreid@chromium.org>
remove extra setting of device format

Change-Id: If5f4dcf77721ec5ab0cc32143a86e7c5930739cd
hack to reset wakeup time when fetching samples

in case the callback falls way behind, just pretend and catch up.

This is needed for now because the call to opem_dev sometimes ties up
the audio task for tens of milliseconds.  This will be fixed later by
moving the opening of devices out of the audio thread.

Change-Id: Icb7ab398463c45d853dce6efcaf99526f8ae3f49
remove extra write_limit setting, should be squashed

Change-Id: Id3cdcf5838e71d2c2a00aa500ef6d5bab6a18c66
intrement callback timer when skipping a callback.

If for some reason, shm is still full and a callback is skipped, make sure to still increment the next callback time.

Change-Id: I0092ff6cf3fd729e01c50d660aae994015a84673
wip: crazy hacks for new timing