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.

Change-Id: Ibb302d512b2af4984459df7df2afa7987dceb9bd
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>
CRAS: audio_thread - More preparation for new timing.

This further pulls apart the stream parameters and the parameters of
the device it is attached to.  This is important in future commits
because a device can have many different streams attached to it, each
with different configurations.

Change-Id: I9726d83888e4ccce05026cceda56ac0a28ad31b0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - remove unused now arg

Change-Id: I0b76d105b05d3e0495cb3e94304977af2b126493
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Don't let draining streams block others from writing their samples

When playing back a draining stream, just copy what shm data is there,
don't limit the amount of data other streams can copy.

Change-Id: If41ca9801c06ca101619baf843ea84922d4c7694
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Fill stream with less data if hw already has some.

If adding a playback stream to a device that is already partially full
with sample, only pre-fill the stream with enough that one callback
threshold total is queued.  Padding more samples adds extra latency.

Change-Id: Ibd654e3e54303db06b06309cec359c5ba0a3973d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - remove unused max_frames

Change-Id: Id2ae350f092885a508b5897cc832129e50443a41
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: move wake time to rstream

The wakeup time is per stream, not per device/stream paring.

Change-Id: I7d255b9846306d788668325052ddf48910da859d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - allow stream fetch to be inexact.

Allow for a stream to be fetch 500 micro-seconds before it's timer
expires.  It is unlikely that the system can sleep and wake again
before the timer should expire anyways.

Change-Id: I5b12a5669c01ae8f8a106409dc6de58b830d5d39
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Prepare for input work.

This sets up some basic infrastructure that will be used by later
commits the get input streams working with the new timing scheme.

Change-Id: I526803379fec693641ff4ca754b007b742fc9102
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: rstream - Go back to one shm area.

Now that unified streams have been removed there is no need for
separate input and output shm areas.

Change-Id: I7eab5c4c0c3c9e48c5740390805d44fa93f94d47
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: iodev_list - use define for "no device"

A zero index means "no device", use a #define for this.

Change-Id: I3bc1e4eb657d6394aa0b62b617a0cbc0f2473151
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Add input mix helper.

This module helps track the write pointers of various input devices
that are writing to one stream.  This will help to decide how much of
a stream is finished being written and how much needs to wait for data
from one or more of the devices feeding the stream.

Change-Id: Idc587424ff7620e628f6238e76f711d21115fa91
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: shm - shm argument to "frames_written" can be const.

Make this const since it isn't modified.  This will allow this
function to be called with a const shm pointer in a later change.

Change-Id: Ia998d921a87f14c7ff59afd18dde922bbce33263
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Make input streams work with new timing.

This gets input streams working with the new timing scheme.  It also
lays the foundation for multiple input devices to feed one stream.

Change-Id: I39334dae100527366cf344b7b810b893bdbd866d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: Delete remove_all_streams

This function is no longer useful since the stream to device mapping
is now more flexible.

Change-Id: I9391b1cfba09f10c3ce841fbd69b29d1e5fbe299
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: iodev_list - Rename default dev to fallback.

Name the "default" device "fallback".  This is the device used when no
other devices are active.  Calling it fallback instead will allow for
the addition of a default device list which is the default set of
devices a stream attaches to.

Change-Id: If3a19fec26c5f1bbd008c5c734d09c6a2e6a745e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: iodev_list - Fix line > 80

Change-Id: I48f8939a2b9f1342f9310eb889c17ce14e6b7ba3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - remove devs_open()

It is no longer used.

Change-Id: I32b8626eb8ca134be2ab44606e8a62d199572d6e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
CRAS: audio_thread - Remove buffer_frames and cb_thresh members

They are no longer used.

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