History log of /external/adhd/cras/src/server/dev_stream.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9903383ab04a9154c6b73045906f84f8654dcf79 23-Feb-2017 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: dev_stream - Add method to get wake up time

Add dev_stream_wake_time to get the wake up time for an input stream.
This wake up time needs to satisfy both sample and time requirements:

- Sample requirement: At wake up time, there should be enough samples
from device to fill 1 cb_threshold in stream's shm.
- Time requirement: This wake up time should be later than next callback
time, which is one time interval later than last callback time.

BUG=chrome-os-partner:60786
TEST=make check

Change-Id: I40dd75170485abc68e25cba9638f22cd02f85b8d
Reviewed-on: https://chromium-review.googlesource.com/446621
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
797b23b697f1ec051ab68843f23e3dd14bf8c01a 28-Feb-2017 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: dev_stream - Avoid bursting captured data to stream

When there are enough captured samples, only send captured data to input
stream when time is late enough. Otherwise, client can not handle this
much data.
Note that stream with BULK_AUDIO_OK flag can still send data when there
is enough data.

BUG=chrome-os-partner:60786
TEST=make check
TEST=Play sine tone use sox command. At the same time, use
cras_test_client --loopback_f /tmp/lb.raw to record using loopback
device. Check num_overruns in audio thread log. Also, check CAPTURE_POST
in audio thread log and see the interval is roughly sleep interval.

Change-Id: I1a6e7056cd0bab40e2e597ca08ef524b7ff1207f
Reviewed-on: https://chromium-review.googlesource.com/447184
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
a898c1799cd5780996cf73fa3f8c1397ba06fef2 09-Dec-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_area - Remove unused argument

The purpose of the skip_zero argument has already been replaced
by the work in commit da9e4afc so remove them.

BUG=None
TEST=unittest still pass

Change-Id: I8fad0d1201943be413b7bc70ea965dc662e3040c
Reviewed-on: https://chromium-review.googlesource.com/418419
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/dev_stream.c
52aa233a3352c981d4f445edfbaea4e14425d965 13-Dec-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Remove unused variable

BUG=None
TEST=None

Change-Id: Ic9eab3da91c25709a0ccf9df5b8c9168529260ca
Reviewed-on: https://chromium-review.googlesource.com/418131
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/dev_stream.c
43c2e833e7a08cad8a776977226cad5d69c62146 12-Oct-2016 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: dev_stream - Remove redundant converter check

After the commit

4da40ff CRAS: fmt_conv - Always create a format converter,

There should always be converter in dev_stream.
Remove the redundant check in dev_stream_create to avoid the
misunderstanding that there might be no converter.

BUG=chromium:651171
TEST=on peach_pit, play youtube and vocaroo

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Change-Id: I8c3d16ba392509a625e2494a318bde4b1454a870
Reviewed-on: https://chromium-review.googlesource.com/397080
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
3089a1acfbc21b35a548ec5bb2a45ed1bf87923a 13-Jul-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_thread - Align stream fetch time

A usage pattern is found to make output buffer drift crazily high.
While output device running with stream A, the buffer level is
expected to stay in range [X, X + d1]. Suppose the new stream B is
connected when output buffer at level X + d' and stream A is
immediately removed, the output buffer will change to stay in
[X + d', x + d' + d2].
The root cause is that when a new stream is added when output device
is already running, its fetch time isn't aligned with any of the
existing stream, so the above scenario is very likely to happen.

BUG=chromium:623868
TEST=Use audio_CrasOutputStress test to verify the problem is fixed.

Change-Id: I071c76ea647a587fb7bd6e8361eedf1029474fc8
Reviewed-on: https://chromium-review.googlesource.com/360880
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/dev_stream.c
236cdf04f3b9544b0fa4b8b05e4313987574d483 15-Apr-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: rstream - record more accurate fetch time

Originally we record the longest time interval between two
consecutive fetches, and use it as a signal to associate
with client stream delay and underrun. However this interval
could be affected by some factors (1) server wake delay and
(2) client response delay (3) stream buffer size, causing it
difficult to use for thread scheduling debug.
Change this fetch interval to record the time difference between
each stream fetch and response, so its value can tell if client
thread has ever blocked too long.

BUG=None
TEST=On squawks, play youtube, and use 'cras_test_client --dump_a'
to monitor the longest fetch time of the output stream.
In another shell, run 'stressapptest' and see this longest fetch
increases accordingly.

Change-Id: Ie3eef83395d0ca2c7f64e87da965206d20547cde
Reviewed-on: https://chromium-review.googlesource.com/339114
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/dev_stream.c
a7031f6452138ef6edd64f5ef75002299e2dd32a 16-Mar-2016 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: dev_stream - Scale captured samples when mixing to dev_stream if needed

Scale captured samples in dev_stream_capture when the samples are
copied from input buffer. Pass the software gain scaler to
cras_audio_area_copy and do scaling optionally in
cras_mix_add_scale_stride.
There are two reasons to scale when adding the samples.
1. Stream might read only part of the input buffer. If we scale in input buffer,
we may scale same sample multiple times.
2. There might be multiple input devices. If we scale in audio area of
dev stream after mixing samples from a device, we may scale same sample
multiple times.

Let audio_thread pass 1.0f scaler for now. In the future patch it will pass a
gain scaler when needed.

BUG=chrome-os-partner:50139
TEST=make check

Change-Id: I10368b1366a44f1f55dd00b52de0724029299aa4
Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/332917
Reviewed-by: Ben Zhang <benzh@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
6429e7efa91f2f4690d70777f4b23d3d4485969e 11-Mar-2016 Cheng-Yi Chiang <cychiang@chromium.org> CRAS: dev_stream - Remove unused argument dev_index of dev_stream_capture

Also remove the unused arguments related to dev_index in audio_thread.

BUG=chrome-os-partner:50139
TEST=make check

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Change-Id: If8c956755e12bc5e0c5153f46f86fa874b018654
Reviewed-on: https://chromium-review.googlesource.com/332911
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Ben Zhang <benzh@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
192f5007487e47d4b1e3ba9d2df95d11fcd01d4e 08-Sep-2015 Vadim Kharchenko <inhandstudio@gmail.com> CRAS: audio thread logging macro

ATLOG macro enables/disabled audio thread logging

BUG=None
TEST=None

Change-Id: Ia3ced86caade35625b4c4f25a31475b5460be8f1
Reviewed-on: https://chromium-review.googlesource.com/297851
Commit-Ready: Vadim Kharchenko <inhandstudio@gmail.com>
Tested-by: Vadim Kharchenko <inhandstudio@gmail.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
fa542141f9bae18e01b665fd09804de7a50989f1 17-Jun-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Update shm level for single output case

CRAS caches the shm level in all streams before actually writing
to multiple iodevs to avoid shm level offset between different
iodevs. This is uneccessary for single output, so in that case we
should update the shm level right before we get shm buffer. This
will help save some audio thread wakeup if client stream reply
immediately after fetch.

BUG=chromium:460515
TEST=Manual test multiple output and single output playback.

Change-Id: I72c486b1424446dd9ec6b98ceab27ed0591e35ce
Reviewed-on: https://chromium-review.googlesource.com/280343
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
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/dev_stream.c
d08e074704529f63cffed728e446fd0790a7aeff 24-Jul-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: rstream - Add fetch interval tracking

Add into cras_rstream the longest interval it has ever waited
for the fetch response. This wait time will be used in UMA in
later changes.

BUG=chromium:335774
TEST=Play YouTube. Use cras_test_client --dump_a to check the
longest fetch interval

Change-Id: Id9d32ed0d3e072e316f7892895047f07040487f9
Reviewed-on: https://chromium-review.googlesource.com/289426
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/server/dev_stream.c
3b41592086092f885544f23b225d01a7371a2c9a 17-Jul-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Add function to check if stream can fetch

Add function dev_stream_can_fetch() and use it to determine if it's
okay to request playback data for a stream. This new function is
used to make the code more readible in output fetch and sleep
scheduling.

BUG=None
TEST=Manual test normal playback and use cras_test_client using 'p'
key to pause/resume the client process and verify audio turn silent
and recover smoothly.

Change-Id: I83ac7e95d4a17698575ce93e0edead78439d7597
Reviewed-on: https://chromium-review.googlesource.com/289421
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/dev_stream.c
46f7653dc735ddd594ecc1b6e174b399443c0438 10-Jun-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: rstream - update queued frames in all streams before write

In multiple output case, a client stream could be filled with
audio data after performed write to one of the output dev but
before the other output dev. This introduces a large offset in
the stream's shm buffer level that transfers to iodev.
When more than one streams connected, and each stream has
different offset value, it will cause severe problem in audio
playback.
Fix this problem by adding a queued_frames variable to cache
the output buffer level of a stream, and let all streams update
this value at once. So that multiple devices writing to the same
stream won't see different buffer level because they perform
write at a different time.

BUG=chromium:460515
TEST=Apply whole patch set, open flash video(44.1KHz, 2048 fr)
and a web audio demo page(48KHz, 1024 fr) with two Jabra
speakerphones enabled. Verify audio does not stop when play
for an hour long.

Change-Id: I95d3427a0e5bb41373763999d1e8421c088e2d39
Reviewed-on: https://chromium-review.googlesource.com/276838
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/dev_stream.c
80518a53e91d5c7124a7cfe72b4451f14c96ff22 13-May-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Log capture stream better

For multiple inputs/ouputs case, it's more useful to
print the shm room and offset to the event log.

BUG=None
TEST=None

Change-Id: Ib4b49cd5f308b075478d0188a6c153f1aa3db3f2
Reviewed-on: https://chromium-review.googlesource.com/271190
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
4c3758b90d0fd20708e1465161b832eaf20442c1 19-May-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Clean up unused code

Originally we have every stream attach to fallback device for
better look up, which requires code to create a dev_stream to
an inactive iodev, and attach/detach stream to device later.
These codes are no longer used since now we have stream_list to
store all streams and that we manage dev_streams in audio_thread
only when iodev is enabled.

BUG=None
TEST=unittest

Change-Id: Ib7132aac610534db9bea6e76c08d0764cc8bda5c
Reviewed-on: https://chromium-review.googlesource.com/272021
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
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/dev_stream.c
e4de2a36cb42f9715b4cfa2133fac80e1efcb040 22-Apr-2015 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Only wait as long as needed for a skipped callback.

When a playback callback has to be skipped because there isn't an open
buffer, try again as soon as there is space. Before an entire period
would be skipped. Now, ignore wake ups from that device until there is
a buffer available, and make the callback as soon as there is space.

BUG=chrome-os-partner:38183
TEST=play google play music while screen sharing in a hangout, listen
for dropouts.

Change-Id: I0d8e064f57521b22da06a28585055673427c6f9f
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266768
/external/adhd/cras/src/server/dev_stream.c
cd23b811ccefce5cd01335c3a2c98a443bc14024 04-Mar-2015 Dylan Reid <dgreid@chromium.org> CRAS: Use CLOCK_MONOTONIC_RAW for time calculations

The raw variant of the monotonic clock isn't affected by adjustments
from NTP or adjtime.

BUG=chromium:463756
TEST=audio still works

Change-Id: I4f46c01b6887ae921f2191a9409fb3f8ae40cfd7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256150
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
e7d7869999ba37fcfa64de304214dc6fab0271e5 05-Feb-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_thread - Wake input stream earlier when there is data

1. Fix 'needed' frames calculation in dev_stream, subtract
the dev_offset would actually derive longer wake time, since
the value is always zero for one active device case and should
just use the available frames instead.
2. Determine the 'min_needed' frames after capture_to_streams
completed, at this point the remaining frames available is what
we need to wait until next callback.
3. Take into consideration the current buffer level of input
device, if after capture_to_streams the level is close to the
min_needed frames, we should wait shorter.

BUG=chrome-os-partner:35842,chromium:451911
TEST=Test recording on Squawks and Nyan, use online record
app and 'cras_test_client --capture_file /tmp/1', monitor the
buffer level by 'cras_test_client --dump_a | grep READ' to
verify it doesn't accumulate too large.

Change-Id: I5bc4914868e84e903dcd1a7d5aa058a8b0c64250
Reviewed-on: https://chromium-review.googlesource.com/247601
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/dev_stream.c
1613b64344d6f50533f6f456bc92dece59c2c69a 13-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: Let input devices drive the input wakeups

This change stops trying to base input stream wakeups on input stream
thresholds directly. Instead, determine the amount of data needed
from the device before the stream can be serviced and sleep until that
much data is ready. This is more similar to how it worked pre timing
changes. It handles accumulation of input samples much better.
Ultimately the client can't do anything until there is data in the
input buffer so waking up early serves no purpose.

BUG=chromium:437479
TEST=capture audio on glimmer, check that hw_level doesn't make out to
24k samples.

Change-Id: I19ac3c88c39c2f238fe539356a4afd7f74a04f7b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/235552
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
3401f772f9dcce31dd2bdb55defcbe35a19e173e 03-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: Add handling of hotword flags

Allow for BULK audio to be sent for device timing to be respected.
If a stream is timed by the device and not the clock, allow for
samples to be sent before they would be if the perfect sample rate was
used.

Change-Id: I18dc83afaf748a65391aa0965ecc558a9d57d0ba
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233106
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/dev_stream.c
d875bd16954fc2bf860bbf3b966ed99dc6f2c70a 24-Nov-2014 Chinyue Chen <chinyue@chromium.org> CRAS: audio_thread - Keep active streams on fallback device.

Have fallback device also keep active streams. This simplifies logic
when adding/removing devices and looking-up streams.

BUG=None
TEST=Remove/Add active device while playing Youtube videos on peppy.

Change-Id: I573057c646e96f9983c7ee1805ca0ae38eea3f57
Reviewed-on: https://chromium-review.googlesource.com/231644
Commit-Queue: Chinyue Chen <chinyue@chromium.org>
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
3232b43c0ea119c369c38bf697098248613f153f 28-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Log waking up too early for capture

Log when a capture stream doesn't have enough samples, but it's timer
has expired.

Change-Id: I050bf5680c1d240e32992f023e653885903a9658
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232233
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
8cd4a917e6cef477799245a4e81fe3709ceff6c9 26-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_area - take full destination format as an arg

More info than just the format bytes will be needed to support formats
other than s16_le in audio_area_copy.

BUG=chromium:219948
TEST=updated unittests

Change-Id: Ia29f9a38b083d8fc20d427ac1a48952f6dcd96c7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232041
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/dev_stream.c
249e72919eb928e107d251b262c305a8fe531641 26-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Mix proper format.

Mix the format that matches the device. This adds a format parameter
to dev_stream_mix so the correct format can be used when mixing.

BUG=chromium:219948
TEST=play through USB DAC that supports 32 bit samples only.

Change-Id: I21863395b5c07284a95fdb93dcfbb7045d223aa6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232085
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/dev_stream.c
1efd30f3854ac69a6916bdeaa82dae3f01d18aca 25-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: mix - reorder exported functions

This will make it clearer when the scale and mix_add functions expand
to support formats other than s16le.

Change-Id: I28c6403e2c35d93164b8c6ea6dc758994bac1e81
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232083
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/dev_stream.c
3ff87f021bc7572b60dd69d06a55dede194665e6 25-Nov-2014 Dylan Reid <dgreid@chromium.org> CRAS: Be more precise with frames_to_time.

This adds a variant of frames_to_time that accepts a double for the
sample rate. doing this will provide more accurate times for each
sleep interval.

BUG=chromium:436251
TEST=capture with show_latency for a really long time.

Change-Id: I77f9b411f2e4401a27e44d0c7fb0463078e96b97
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/231712
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
1aba4d9e480cb20cf82448e98a3eb68d81d1a337 18-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - use new rstream accessors from dev_mix

Not accessing the shm directly will make unittests easier to write.

Change-Id: I59a57a038ba2d228a982aba293fd8a5cdeafffcc
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224551
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Anatol Pomazau <anatol@google.com>
/external/adhd/cras/src/server/dev_stream.c
02150e3c82c11e2b28f1e1993b37316f59a6cc31 28-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - move fd poll decision to dev_stream

dev_stream has all the needed info to decide if the audio_thread
should wake up when audio is ready. Move the check for that to
dev_stream. Add a check that there is a callback pending, since there
is no reason to wait otherwise.

BUG=none
TEST=web audio visualizer on Blaze

Change-Id: I8fed428d65dbd711cac4324bb52b977648f70bad
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225974
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
084401521b297857987b2b3ece787c16cacdbbcc 03-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: linear_resampler - increase resample precision

When doing SRC, the actual rate is trimmed to the floor
integer before use and causing a precision lost. Multiply
the numerator and denominator of the rate factor by 100,
so it takes more than 1 day for the lost frames count to be
accumulated to 1024.

BUG=chromium:420589
TEST=Play youtube to two active devices

Change-Id: I6bcac51e01ea6deba16462b201c783ea1a85f96e
Reviewed-on: https://chromium-review.googlesource.com/221706
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/dev_stream.c
fbd2d15de5e0df9ba2d1144170f7b35cab4249f4 01-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_thread - Integrate rate_estimator and linear resampler

Actually use the data report from rate estimator and apply to the
linear resampler in fmt_conv for non-master active devices.
The stream's sleep interval is updated to base on the master dev's
estimated rate.

BUG=chromium:420589
TEST=Play youtube on internal speaker and USB headset. Test
record by cras_test_client.

Change-Id: Ie4265f793bb972d9880cbad244c796a9b03db2b4
Reviewed-on: https://chromium-review.googlesource.com/220157
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/dev_stream.c
9be8914ce3dfa203fa5132e26822ee68c625dc65 09-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: rstream - Add master device id

A rstream can attach to multiple devices, choose the first one
of the device list as the master, which will soon be used as
the reference to align sample rate to.

BUG=chromium:420589
TEST=None

Change-Id: Ifb2c7b4aaeb2c9440320950d1e907eac3f8f8de8
Reviewed-on: https://chromium-review.googlesource.com/220160
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/dev_stream.c
4da40ffba6ec3485b8e0a341c12dc2ee1d9cdeb6 20-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: fmt_conv - Always create a format converter

When config_fmt_converter() is called, always create a format
converter even the in/out format are identical. This allows the
linear_resampler check to determine if the format conversion is
needed depend on the estimated device rate.

BUG=chromium:420589
TEST=unittest. Play youtube and vocaroo.com

Change-Id: Ib3d1c7863917fb9fb583a9f283d729ac9ad2edb9
Reviewed-on: https://chromium-review.googlesource.com/224629
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/dev_stream.c
5d5525afc084e1d00faab2fdbce85ed458b2fc53 27-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: Don't limit frames by offset in capture.

The write point returned from cras_shm_get_writeable_frames needs to
have enough space for the offset and the number of remaining frames.
This many frames will be written starting at offset. For example: an
offset of 60 in to a 100 deep buffer, the pointer will be returned to
the first frame (frame zero), Then 50 frames could be written
beginning at the offset of 60, because the shm only limited based on
its write point which is still at the beginning, so there is room for
50 frames.

cras_audio_area_dopy already handles limiting the total number based
on the offset.

BUG=chromium:427675
TEST=record from two devices at once on Blaze. Jabra and built-in.

Change-Id: I416fc83d460fe1941c5ae08793fa59611d6e72a9
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225703
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
b1cf3e2dd53fee6121e7b953b9fd71fcc6616997 09-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Increase sleep time when captue count is missed.

If there haven't been enough samples captured when it is time to send
data to the stream, sleep for a while longer in hopes that they
arrive.

BUG=chromium:421941
TEST=record from two devices and listen for quality.

Change-Id: I38a10cad3255c8874e5057df17b8dfbe60f230b2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222643
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
993756a831a5d49efa71c578835802454a079763 09-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - offset in capture_avail

When calculates the available frames in stream for capture take into
account the previous capture offset of the active devices.

BUG=chromium:421941
TEST=Test on Pixel, activate keyboard mic and listen to the recorded
audio.

Change-Id: I09329a11cd2fc2675e511f07282f202d50f59968
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222498
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
bc0496defda90cdc6d4427d43bcbb04338400a0e 11-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - track read offset per device.

Similar to how output devices work, track each stream's read offset
into the device. This will allow streams that need SRC to read less
than the maximum amount of frames.

BUG=chromium:421941
TEST=play and record from multiple devices.

Change-Id: I1a5445bee41e17196557e9cce2795f97ed66f1b8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222948
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/dev_stream.c
d2fad8844c28b20f344479f341f9c80a3b8b9c27 08-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - limit write frames correctly.

If some frames have already been written, there is now less space to
write to. Make sure not to overrun the buffer.

BUG=chromium:420137
TEST=play grooveshark and visualizer

Change-Id: I414820e897c32363908b242c278233a2a0598bcb
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222381
/external/adhd/cras/src/server/dev_stream.c
fd73a24e3fcb3de2efdf8fd0091b104c69fd62f4 07-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: iodev - track written frames from different streams

Utilize buffer_share to keep track the offset of frames each
stream has written to hw buffer, the min level across all streams
will be committed and future write stream action will base
on the updated offsets.

BUG=chromium:420173
TEST=Play flash video on Squawks, here no static noise.

Change-Id: I22c34b0da4a7f8ec13ec403abed3b795d9dd1bf3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221893
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
f3fa0b8fbde0a221a774b0cdc0f1c0a3e4b34717 02-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Remove streams on error.

If a request to get frames from a stream returns an error, remove the
stream instead of ignoring it.

BUG=none, yet
TEST=add and remove a lot of audio streams.

Change-Id: I7c4d6d78099dda8b23393006d1f9bce5e5b30180
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221293
/external/adhd/cras/src/server/dev_stream.c
eb2c6a76a727a37340eca0830ad41fde97476856 02-Oct-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Fix mono record bug

In capture path, the conversion from dev format to stream format
doesn't handle channel convertion, the conv_buffer and conv_area
of dev_stream should be configured by the output format of format
converter instead of stream format.

BUG=chromium:419634,chromium:419037
TEST=cras_test_client --capture_file /tmp/1 --num_channels 1 \
--rate 44100
cras_test_client --capture_file /tmp/2 --num_channels 1 \
--rate 48000

Change-Id: Ib12090460df8858f2a4cb7c63ce650c6a64fdbfe
Reviewed-on: https://chromium-review.googlesource.com/221005
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
3520173d9d0583af76acab513a524b5e107d14be 30-Sep-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Correct the size of conv_buffer for capture

Fix a bug that when conv_buffer is created with size much larger
then the stream buffer size, dev_stream_capture_avail() could report
a write_limit which is too much than the conv_buffer can actually
hold, making audio thread stuck in the while loop of
capture_with_fmt_conv().

BUG=chromium:419037
TEST=Run chromium AudioVisualizer app, make sure CRAS don't
stuck in the while loop.

Change-Id: Ie81be668352ec98dba240fdd7262dfb2c8764294
Reviewed-on: https://chromium-review.googlesource.com/220515
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
e32902dfa32360f2ce099b8772e14d88113d61ea 30-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - fix setting min_fill level before playback.

If one of the devices has read more samples than the others during a
previous wake, its offset into the shm region needs to be accounted
for when finding the minimum amount of frames a stream can provide.
Fixing this removes the need to update the count while writing because
an accurate minimum will have already been determined and is
guaranteed to be available for writing.

BUG=chromium:418833
TEST=Play audio to multiple devices at once on Blaze.

Change-Id: I8588fff7c60f9c7e190db57c1c1b17b33939a4f6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220492
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
ee07b6a09fe8707721c02f4220af527c960b80e8 30-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Limit based on converted frames in mix.

The number of frames written should be limited based on the converted
number of frames.

Change-Id: I70f45a44316813a392f6721869b19d4ae076f746
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220447
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
13beeb14ea0e93132f1764a5f7f8104b7f32a22e 26-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Handle multiple active output devices.

Use the buffer_share object to manage the read pointers of various
output devices into the playback streams. This allows multiple
devices to play the same stream simultaneously.

Change-Id: Idee80c7430022257fd6edb7dcae035bbbc88e2e0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220111
/external/adhd/cras/src/server/dev_stream.c
92927371c0ef07eb1f1fb472debdd4081b1a8749 25-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - basic dev speed tracking.

This can be removed one the sample rate estimation is integrated.

For now, if the device has too many or too few samples queued, wake up
streams later or earlier to try to get back within range.

Change-Id: I029d06fc897d75f8474b9bc8cdc1790eda133650
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219981
/external/adhd/cras/src/server/dev_stream.c
534ddad0f8213b0da91bfbd3634a0322e27fa8e5 25-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - use wake time to drive capture callbacks.

This calls back the input with a regular rate, regardless of the
buffer level. Keeping the buffer level high enough will be handled by
the sample rate estimation.

Change-Id: I031295ff2de3cc1e68a679cf9ae64b38ebf55b3d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219979
/external/adhd/cras/src/server/dev_stream.c
da9e4afc6a56cbc2f14430f57c58327b156b8a06 25-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: input - Clear buffer when first writing to it.

Different active inputs can write different amounts of data to the shm
buffer per wake up. This ensures that the shm region is only cleared
once, and no data from other devices is erased. Before this, if
dev_index zero wrote less than the device at index one on the previous
wake up, device one's data would be erased by audio_area_copy.

Change-Id: I908c4dfe7aa11488205313530c2498319345a661
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219977
/external/adhd/cras/src/server/dev_stream.c
0b123a52b29a09c563535a576dcc6a6eb9497b2d 24-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - remove redundant mix_offset member.

This information is now kept in the input_mix state within rstream.

Change-Id: Ic12fc4e3f1e7dca61f555b76cb75b0386e095484
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219975
/external/adhd/cras/src/server/dev_stream.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/dev_stream.c
ed0e3ba0dc54a1ddd192ae571e15c0acebacbc81 23-Sep-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/219967
/external/adhd/cras/src/server/dev_stream.c
4760724dc983b4bde612b274c3ecc5daead4c260 21-Sep-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/219963
/external/adhd/cras/src/server/dev_stream.c
0e588cc20345371bfb43595fb09c5d288d7c08e8 20-Sep-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/219960
/external/adhd/cras/src/server/dev_stream.c
7270eb59cf3b2e77b8ab4ec450282d61e5a348be 18-Sep-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/219957
/external/adhd/cras/src/server/dev_stream.c
d181423fe627ea344c57d7dad22f02fb65330fcd 11-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Foundations of new timing.

This change removes a lot of cruft that will no longer be needed by
the new timing system. No longer does the audio thread wait for
playback streams to reply, it now wakes back up when they do. This
will free up the audio thread to handle other devices and streams
while waiting.

Change-Id: Icb7ab398463c45d853dce6efcaf99526f8ae3f49
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219952
/external/adhd/cras/src/server/dev_stream.c
1842d8de49b3d00442380c39756d7d09bd983471 10-Sep-2014 Dylan Reid <dgreid@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>
Reviewed-on: https://chromium-review.googlesource.com/217534
Reviewed-by: Owen Lin <owenlin@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
21e764cb9f052a0a193a4c9ec9759117be21cd79 10-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Move rstream request to dev_stream.

Move requesting playback samples to a function in dev_stream. This
removes one more dependency on rstream from audio_thread and will make
a good place to update stream-specific timers in a future change.

Change-Id: I3ccf49b17135ab44050be7cecc132021d2ead2c5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217533
/external/adhd/cras/src/server/dev_stream.c
9d2f9d298338b5fb4cf9768c03a218d3d544484b 08-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Account for SRC when reporting delay.

The delay reported by the device need to go through sample rate
conversion to the remote sample rate before being reported to the
client.

Change-Id: I2e9b9d5f8b0dfedf5a14a99bc946053fccecaaa6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217180
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
9111a0544944a9d367f5e19b15e5f03340b4a808 08-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: move timestamp setting to dev_stream

This ins't really related to iodev, move it to devstream.

Change-Id: I8683eeba2b765ca59b5a8370d5927138158ede0b
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217179
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
7180fbd487d1ed4ad398fbb5523ba46e129663ef 08-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: Implement format conversion for the capture path.

Add format conversion for capture samples on the server side.

Change-Id: I056b5ae4362ded6e2be1cebbc4cef8ab3ed80ac0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217178
/external/adhd/cras/src/server/dev_stream.c
8e45c089c7665d417441576b29f0f3b3947961db 29-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Use helper to check capture frames.

Add a new helper to dev_stream that returns how many frames are
writable in the stream for capture samples. This will be useful in
later commits as sample rate conversion can make determining this
non-trivial.

Change-Id: I060a349021e0fcde269133dd7c5e51569cafbd62
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217173
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
24930c33818a13027406bd80caa8cd12c89bfe06 28-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Handle dev_stream with a format converter.

If a dev_stream has a format converter, update the amount of frames
available and use the format converter when rendering samples.

BUG=none
TEST=none, not used yet.

Change-Id: Id1929b1cf8677a57852c4a873c19373bda3303a4
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217159
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
09635e9afff9e95e0287e775b2a7e5e9132f351a 14-Sep-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - don't convert channel/layout for input stream

For capture CRAS can copy the samples from device to stream
for each channel base on the channel layout specified. So when
creating a dev_stream, no need to create format converter if
the format difference is on channel count or layout.

BUG=None
TEST=cras_test_client --capture_file /tmp/1 --num_channels=3
--channel_layout=0,1,-1,-1,2,-1,-1,-1,-1,-1,-1

Change-Id: Id09a8647729f9f7cd9b6887b887a2a28f73436e8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/218096
/external/adhd/cras/src/server/dev_stream.c
f5678f0806610f1778f3d9f6d4e65a13e3f73c1e 28-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Add format rate converter.

Add a format rate converted to dev stream. This adds an argument to
the constructor indicating the format of the device the stream will
play on. If this format doesn't match the stream a sample rate
converter will be created.

A later change will modify audio_thread and rclient to use this
functionality. For now rclient ensures that the formats match.

BUG=none
TEST=new unittest, the code doesn't run yet.

Change-Id: Id71e593cbed05abc1771e5232c0e181f862053f4
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217158
/external/adhd/cras/src/server/dev_stream.c
20a680f75285775b47316921749985c6cc6e98fc 23-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: move stream mixing to dev_stream.

Move the shm interaction and some decision making to dev_stream as
this is a property of the stream. cras_mix no longer needs to know
about shm and its unit test is now much cleaner. This paves the way
to add sample rate conversion logic to dev_stream in a later commit.

BUG=none
TEST=make check, play a few simultaneous streams.

Change-Id: I5fbb3c670e86393a0c8d3454e29c4bf587a5015c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217157
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c
1ed6d87e10a810ace9dc07051fcc60c8d95bcee6 23-Aug-2014 Dylan Reid <dgreid@chromium.org> CRAS: audio_thread - Factor cras_io_stream to its own file.

Rename cras_io_stream to dev_stream and move it to its own source
file. In later commits this struct will take on additional
responsibilities keeping sample rate converters and tracking how much
of a stream has been written to each device.

BUG=none
TEST=make check

Change-Id: Ifa19e8f1bb3557ca7c7ff4546ad445729bc3ddfb
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217156
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/server/dev_stream.c