History log of /external/adhd/cras/src/server/dev_stream.h
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.h
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.h
084f56d4c9257607a28e110627456a32b92a97dd 15-Apr-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: dev_stream - Clean up unused variable

The skip_mix was not used since we moved to the new
timing of audio thread.

BUG=None
TEST=None

Change-Id: Iecc15b0ce05efd94d534bcecb9347429226a0c19
Reviewed-on: https://chromium-review.googlesource.com/339113
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/server/dev_stream.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
5baa985581f4a97dfa843156e7aa2edf324523f9 11-Feb-2015 Chinyue Chen <chinyue@chromium.org> CRAS: audio_thread - Schedule is_draining stream which has playback frames.

If an is_draining stream has playback frames in buffer, schedule it to wake
so the frames could be output.

BUG=chromium:451506
TEST=1. Open several tabs playing local mp4 on winky
2. After playing for a while, close browser
3. Verify cras_test_client --dump_a output

Change-Id: I945cf1a184da19bae0f9bf6abb53c6a5b7204a0a
Reviewed-on: https://chromium-review.googlesource.com/248540
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.h
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.h
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.h
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.h
3c62a803f22a12d662064e30eb3f38ab1c854d22 03-Dec-2014 Dylan Reid <dgreid@chromium.org> CRAS: dev_stream - Filter callback time if draining

This removes another rstream dependency from audio_thread and will
allow for other conditions to be used in the future to filter out the
next_cb_ts.

Change-Id: Ie1d19c0398514596c22b79e52ab9ae3d46cd2bce
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233101
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/dev_stream.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h
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.h