History log of /external/adhd/cras/src/common/cras_shm.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8d235723607ecfe4aa53d511ddba43147a36ada6 13-Dec-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: client - Fix Chrome crash when input buffer overrun

When an input client hangs at processing the captured buffer, server
side could encounter buffer overrun. When that happens and client
later recovers from busy state, the read buffer would no longer be a
whole captured chunk. Assuming Chrome processes the read buffer while
it's in the middle of overrun, only partial of the buffer is consumed
and that causes non-zero read offset. This makes Chrome crash at the
next time it handles capture data because buffer pointer won't start
from the beginning.

BUG=chromium:673454
TEST=Run apprtc app on Kevin.

Change-Id: I7ef61140081ec2e466fc8eace854ec02c065c6da
Reviewed-on: https://chromium-review.googlesource.com/418130
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/common/cras_shm.h
fe3b32adb850b6637934195ec2a0055fb9199ce5 18-Nov-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: audio_thread - Log when input stream overruns

Fix cras_shm_check_write_overrun() function in detecting when
unread data is overwritten, and return the result so audio
thread can ATLOG this problem.

BUG=chromium:662886
TEST=Use 'cras_test_client --capture_file /tmp/1' and hit
'p','enter' a few times to emulate a bad client. Check audio
dump to veriy there's AUDIO_OVERRUN logged.

Change-Id: Ib5b90ce05d957487b29639dffbbe3067ab5f6915
Reviewed-on: https://chromium-review.googlesource.com/412428
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
443a8d0eb551cc101e6354c668765b2e3d2371d9 17-Nov-2016 Hsin-Yu Chao <hychao@chromium.org> CRAS: client - Don't read repeated data

CRAS client could handles multiple messages from server about
capture data ready. We should check if the read offset of stream
shm reaches write offset, to avoid reading repeated data.

BUG=chromium:662886
TEST=Execute 'cras_test_client --capture_file /tmp/1' and then
hit 'p', 'enter', 'p', 'enter'... repeat 10 times while making
some sound to internal mic.
Inspect the recorded /tmp/1 file using Audacity to verify there
are no repeated samples, but with several short discontinuity
instead.

Change-Id: I40bf34cbae31f76bd013ec855a4d5ef4055399f2
Reviewed-on: https://chromium-review.googlesource.com/411668
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
5648132484a751e574df7572e3b9fa0003e3caa2 26-Apr-2016 John Muir <muirj@google.com> CRAS: Use Android shared memory on Android.

The POSIX shared memory functions don't exist on Android.
This change implements the alternative.

BUG=None
TEST=CRAS starts and successfully creates the shared memory.
Clients are able to access the shared memory areas.

Change-Id: I93f08bc562047edb08c9a1304dfa0a46f32cdf93
Reviewed-on: https://chromium-review.googlesource.com/341315
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/common/cras_shm.h
389931c51bd5c320a0593e581c36b68d316ca0ad 23-Jul-2015 Hsin-Yu Chao <hychao@chromium.org> CRAS: shm - remove stream timeout tracking

The stream timeout stuff hasn't been used for a long time
so remove them all. Plus that CRAS no longer waits for
streams' response and send fetch request for each stream
regularly instead.
The original purpose of the stream timeout tracking will be
replaced by tracking the fetch interval in later change.

BUG=chromium:335774
TEST=None

Change-Id: I0342859dbf9d2e0c7867b1fdca1d8806f1c9fb0a
Reviewed-on: https://chromium-review.googlesource.com/289424
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/common/cras_shm.h
ec4d533f0b5866ac6be3ec4890443de98824167e 13-May-2015 Cheng-Yi Chiang <cychiang@chromium.org> cras_shm: skip update in cras_shm_buffer_written if frames is 0

Do not update read/write offset if frames is 0.

Currently there is no race condition here because client changes
read/write offset of read_idx and read_idx itself _after_ audio thread
changes read/write offset of write_idx and write_idx itself.
Therefore this schedule will make sure write_idx and read_idx will be
different when either audio thread or client updates read/write offset.
However, it makes sense to only touch read/write offset when needed.

BUG=chrome-os-partner:39277
TEST=check capture is fine on board with capture capability.

Change-Id: I9ae81084eabc8cc386cf23b73caac1fd9cef572b
Reviewed-on: https://chromium-review.googlesource.com/270605
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
e0b153ac49a3d28fd824a1de7f2da6065395df02 12-May-2015 Cheng-Yi Chiang <cychiang@chromium.org> cras_shm: skip update in cras_shm_buffer_read when there is no frame

When there is no change in frame, do not update shared memory index and
offset.
There are two purposes:
1. It does not make sense to change the read/write index and offset when
there is no change in frames getting read.
2. When audio thread is waked up by timer and there is no frame to play.
Changing the read/write index and offset may collide with client when
client update the same read/write index and offset.
The schedule that has no race condition is like:

a. audio thread fetch
b. audio thread has no frame to play.
c. audio thread does not update shm because there is no frame written to
device.
d. client access shm to move write offset and index.
e. audio thread sleep.
f. audio thread is waked up by client after a short time.
g. audio thread writes frames to device.
h. audio thread update shm based on number of frames written.
i. audio thread sleep.
j. audio thread is waked up by timer after a period.
k. audio thread fetch (=a).

We want to avoid the race condition in (c) and (d) where audio thread and
client both access shm.
Without this patch, in step (c), audio thread will change shm even when
number of frames written to device is 0.

However, even with this patch, it is not guaranteed that (d) will happen
after (b). When (d) happens before (b), there will be frames to play in
(b).
So in (b), frames written to device is not 0. Then, in (g), there will be no
frames available. This will break the above schedule.

BUG=chrome-os-partner:39277
TEST=Use cplay_buffer to play a sine tone and listen for the audio drop.
Change-Id: I20c14d92eb081493712b6fa0bbe1716363353897
Reviewed-on: https://chromium-review.googlesource.com/270444
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
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/common/cras_shm.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/common/cras_shm.h
7c908ed61a7db60cdf93872e81455c119916ac62 17-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: shm - fix const of arguments

These won't modify the object. This allows for future functions to
take a const shm as an argument.

Change-Id: I8f34802bd1171d7482884c07db0aad3d8bf8ab23
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224469
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Anatol Pomazau <anatol@google.com>
/external/adhd/cras/src/common/cras_shm.h
c7f7d5bf1bdf344113153c56bd7c4be96a57ec4b 28-Oct-2014 Dylan Reid <dgreid@chromium.org> CRAS: client - always write samples from the start

The client never wants to append samples to a buffer, it always wants
to write to the beginning. Chrome will always write cb_threshold
samples, no matter where in the buffer the write pointer is, this can
lead to a buffer overrun when the audio output overruns.

BUG=chromium:423929
TEST=play/record audio on Blaze

Change-Id: Ia9cacabef11f4a29c5c11c72fe7b55cea38438cf
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225973
/external/adhd/cras/src/common/cras_shm.h
7658ac7265dc268375d97088b09a155e2d5c054e 30-Sep-2014 Dylan Reid <dgreid@chromium.org> CRAS: shm - make accessors take a const pointer

This will allow other functions to be more const correct.

Change-Id: I61ed9d97b5a7660b22ae1bd6461eab5dddbd912c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220491
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
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/common/cras_shm.h
422ce651e940f7a4ec5f4d6f1a241efde3a07a40 23-Sep-2014 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>
Reviewed-on: https://chromium-review.googlesource.com/219966
/external/adhd/cras/src/common/cras_shm.h
2c1e4a94b93ea1ca23ae1ab177a80ad769a7c18a 17-Apr-2014 Dylan Reid <dgreid@chromium.org> CRAS: Use MIN and MAX from glibc instead of local macros.

Replace all instances of min and max with the version from glibc.
This prevents name collision with std::min and std::max when chrome
uses libcras.

BUG=chromium:364382
TEST=still builds and runs.

Change-Id: Iafc200fb0de82bbfbe105551250207392cb2f42a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/195451
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
f11e4d0d1e288faa3635203c9ebf9891008e4802 11-Apr-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS audio_thread - Send longest timeout length to UMA

Add a pipe for audio thread to send message to main thread.
Note that the existing to_main_fds is used for synchronous
message reply sent from audio thread to main thread, and the new
main_msg_fds is for message sent to main thread. Right now
it is used for sending audio thread metrics to UMA.

If a stream timeout within the 10 seconds limit, keep
track of the longest timeout period length in milliseconds
and log this value when the stream is removed.

BUG=chromium:327817
TEST=Manual modify cras_test_client to create a bad
stream, verify histogram in about:histograms

Change-Id: I34fa220db6cbefdba3629070af8a5e3f39e741b9
Reviewed-on: https://chromium-review.googlesource.com/192110
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/common/cras_shm.h
fd4959184d7cd91b0b3e53143aa045b9070d53ca 27-Mar-2014 Hsin-Yu Chao <hychao@chromium.org> CRAS audio_thread - Drop a stream if timeout too long

Keep track of the timestamp of the first of consecutive timeouts
of a stream. Checks the accumulated timeout period, if it's
too long(longer then 10 seconds), drop the stream.

BUG=chromium:327817
TEST=Manual add a bad client while playing youtube, check any
audio crackling disappear after 10 seconds.

Change-Id: I81428eab08e718ab59ca7c08add179627691b734
Reviewed-on: https://chromium-review.googlesource.com/191822
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
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/common/cras_shm.h
14e9e90cd05b80174c9aff5cdab90e51e0e18cb0 29-Nov-2013 Chih-Chung Chang <chihchung@chromium.org> CRAS: consume only data in the current buffer for client reading.

The crash happens when the read pointer moves to a wrong place and tries
to read over the end of the buffer:

cras_audio_shm_area: [header][...buf0...][...buf1...]
^
|
+-- ptr

This could happen if the client reads buf0 too slowly, and
cras_shm_buffer_read() found read_offset > write_offset because the
write_offset is being updated with a value in the middle of buffer,
and it thinks it should consume part of buf1.

The fix is to only consume data in one buffer during client capture
callback, because the client can only read from one buffer at a time.

BUG=chromium:322788
TEST=start two "cras_test_client --capture_file" with different values
of --callback_threshold and verify the client does not access memory
over the end the buffer.

Change-Id: I244f489171f6a53be1ba2afb5ff18d4f8db45203
Reviewed-on: https://chromium-review.googlesource.com/178406
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
5f22947107e9e05bb0daca8693e09d9e1f9f76f0 11-Oct-2013 Dylan Reid <dgreid@chromium.org> CRAS: shm - Handle reading all of both shm buffers.

There was a bug when reading all the samples across two buffers. The
read buffer index wasn't increased after all the samples from the second
buffer were read. Fix that.

BUG=none, but probably a bunch about audio glitches.
TEST=play audio, updated shm_unittest

Change-Id: I178089bcd657b69fcc5e5138dbf064a99fa2569e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172934
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
c58e3891c1823683f6687a967c6624877f05c44f 24-Sep-2013 Dylan Reid <dgreid@chromium.org> CRAS: shm - return error if odd number of bytes available.

Instead of asserting when the byte count isn't a multiple of
bytes-per-frame, return an error. This is better than an assert, if a
client overwrites the shm region accidentally it shouldn't reset the
server, instead it will drop that stream.

BUG=chromium:297670
TEST=make check, and play/record audio on Daisy.

Change-Id: Ie6bcdbeb4cee52e509b843a1f6f3b479c41b37bf
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170514
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
c5df6f97395a271a0c066e51d0a365b33cfd2287 11-May-2013 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add parameter to get_writeable_frames

Allow the total number of frames to be specified in calls to
cras_shm_get_writeable_frames. A following commit will use this to
limit the amount unified streams read to the amount that should be
passed to the stream instead of greedily taking everything that will
fit in the buffer.

BUG=chromium:238971
TEST=make check, no functional change yet.

Change-Id: Ib6753ab484c0ef4bb6f6015bb1bb4d71b15d30f8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50948
/external/adhd/cras/src/common/cras_shm.h
b351ab6037eb8a19719ed45ba45fb1e62e58a2ad 20-Mar-2013 Dylan Reid <dgreid@chromium.org> CRAS: Bound limit for read and write differently.

Write pointers will now be limited to the max size for the buffers,
and read buffers are limited to 0 if they are invalid.

This way if the write pointer passes the end, the audio will still be
played.

BUG=none.
TEST=updated unit test.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I3432054c4704c0b5657fab8f39a1fef16962b44d
Reviewed-on: https://gerrit.chromium.org/gerrit/45950
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
8b8c23a61fa1b25a531daa992d391086edf57dbf 04-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: Add support for multiple capture streams.

Remove the limitation that only one capture stream can be active at a
time. This is needed because with WebAudio input enabled, Chrome
opens all output streams as bi-directional, each opening an input as
well.

Note that this initial implementation doesn't yet support streams with
non-multiple buffer sizes of each other.

BUG=chromium-os:35272
TEST=updated audio_thread_unittest

Change-Id: Ieccb26c3d9d9aefde4f00b36a3612646679a94fc
Reviewed-on: https://gerrit.chromium.org/gerrit/41054
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
87d6e1fdf1b9ce92d9442563661a8210cc3bde27 04-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add function to get write buffer base address.

This function will be used to get the base of the current write buffer
so it can be passed to cras_dsp for processing before signalling the
client.

BUG=chromium-os:35272
TEST=updated shm_unittest

Change-Id: I0958e5358d19e6ab75511d87a0be90064d625765
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41052
/external/adhd/cras/src/common/cras_shm.h
1bf44ec5aaed5b8f332dc4c8ce6373ea5ff8414d 04-Jan-2013 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add ability to check how many frames are written.

New function returns the number of frames that have been written to
the current buffer. This will be used to check if there are enough
frames to tell the client about when multiple capture streams are
allowed per device.

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

Change-Id: I7b704a0b6ffa277f421650eef243e28f0bb7852d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41051
/external/adhd/cras/src/common/cras_shm.h
48e89578dc2dec90ec2c41a2a6726ce986f1fd88 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Make get_write_buffer check how much can be written.

Change cras_shm_curr_write_buffer to cras_shm_get_writeable_frames. The
new function still returns a pointer to the location to write, but also
fills in a parameter with the count of frames that can be written. This
mirrors the behavior of cras_shm_get_readable_frames. Checking both of
these in one place allows bounds checking of writes to the buffer.

BUG=chromium-os:33123
TEST=manual, youtube playback, youtube.com/my_webcam.

Change-Id: I75be87a961f261f6a53e725fd217a9a82edd2248
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29294
/external/adhd/cras/src/common/cras_shm.h
40d873b8d2a16c6b2f965eb6efc3d9e13090c398 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add bounds check for read/write offsets.

Now that used_size from config can be trusted, bounds check the read and
write offsets.

BUG=chromium-os:33123
TEST=updated shm unittest.

Change-Id: I78dd372d1c6cfaccebb66032c74fcdf98eaff89a
Reviewed-on: https://gerrit.chromium.org/gerrit/29293
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
dd7bec3156b6a8da1f7bf954c78726f82e4a5cb8 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Use volume scaler setter/getter.

A few places were accessing the member directly instead of using the
setter/getter.

BUG=chromium-os:33123
TEST=updated unittests.

Change-Id: Idb35ec87510ae69748d2867205413796723812f1
Reviewed-on: https://gerrit.chromium.org/gerrit/29291
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
0cdbbbaab919676ca0087984bf1b650fbd02da6e 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add set/get of overruns and timeouts.

Add setter and getter for callback timeouts and overruns so that it will
be easier to move these two members to a different struct.

BUG=chromium-os:33123
TEST=updated alsa_io unittest, youtube, and GTalk still work.
Signed-off-by: Dylan Reid <dgreid@chromium.org>

Change-Id: Ifcd880b440663afdbfe14d0bf978d94ef9007dd4
Reviewed-on: https://gerrit.chromium.org/gerrit/29290
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
991d36c2af3a07bde6fdbe9282d506ba5c915dcc 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Remove size member.

This member was only being used in one place and can be easily
calculated. Add a function instead to return the total size of shm.

BUG=chromium-os:3312
TEST=updated unittests.

Change-Id: I367e240cfc995579a772ea8170cd8cbc52ef6262
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29288
/external/adhd/cras/src/common/cras_shm.h
b0eceb98c9a1dc4fc3664e0718364e07cd167ac7 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add get/set for used size.

Add a setter and getter for used_size. Remove direct access to used size to
ease moving it to another structure.

BUG=chromium-os:33123
TEST=shm and alsa_io unittests still pass, play and record audio with
aplay.

Change-Id: Ie1856117606c06f2d9507b8f444d2151bb987bab
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29287
/external/adhd/cras/src/common/cras_shm.h
2d4c04f8b28f2a237151cd34038acc8b5173bbe5 06-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Add getters and setters.

Get and Set callback_pending and frame_bytes through inline functions
instead of directly. This will make it easier to move these members to
another struct in a future change.

BUG=chromium-os:33123
TEST=shm and alsa_io unittests still pass, play and record audio with
aplay.

Change-Id: Ia976b6c2c2706ca069b8ce273b9d198704b1082c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29286
/external/adhd/cras/src/common/cras_shm.h
06c004a4a5f7956f93720fcbdd333b801e94ae12 01-Aug-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Bounds check buffer index.

Check the bounds of read and write buffer index in case they get set to
a crazy value in shm.

BUG=chromium-os:33123
TEST=shm unittest, play audio with test client and chrome.

Change-Id: Iedb2446e2d31d7c5539f7bca46b46ad8fd56a3f7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29285
/external/adhd/cras/src/common/cras_shm.h
af31a246f861df2ea382f10650677f3014456a78 06-Jun-2012 Dylan Reid <dgreid@chromium.org> CRAS: shm - Fix cras_shm_get_avail_curr_buffer.

This function was unused until recently. It was checking the wrong
buffer (using read_idx instead of write_idx). Change the function to
enforce that a buffer is only written to once before it is read. The
server only requests data when there is a buffer available so if
write_offset is non-zero in a client callback there has been an error
(alsa_io, checks on the server side before requesting data). In this
case return zero so nothing is written.

BUG=none
TEST=updated shm unit test, build and run on ZGB, youtube, gtalk and
WebAudio drum kit demo.

Change-Id: Idd1aade02b2c23c76fc5e79ff57c3ba9bf6be7c8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
726189964a2f2f7fef808ec20cc7efeb7971a502 06-May-2012 Dylan Reid <dgreid@chromium.org> CRAS: alsa capture - handle split buffers.

Handle alsa returning a set of samples in two chunks because of
wrapping past then end of the ring buffer. Don't mark a buffer as
written until both chunks are read into the buffer.

BUG=chromium-os:30607
TEST=Manual, build and run cras on stumpy/lumpy check GTalk and that
can record from command line. Previously crash would happen while
recording and capturing simultaneously.

Change-Id: I2f3edce11c2f7759626b2a8c4d56e314702933fa
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
20e15b710035bec49c83af0003fe252c02cc2a39 10-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Rename stream volume to volume_scaler.

This is done to indicate that the volume is a scaling factor and not
an index. Keep some difference between this and the system volume
that is an index.

Change-Id: I3965f2c5410d4d197f88f4e97e3c63dcf40491e2
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
c49a8038bd7e0c195f2d8719286be282705d5e97 07-Feb-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add volume and mute parameters to shm area.

The volume and mute parameters will be set by the client and read by
the server.

BUG=chromium-os:25411
TEST=mix_unittest

Change-Id: Icd835c770864901f183cf93902b07b7a0ca84a4c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
f63a462d21eb16b23aaeb312d03e7898458f123d 26-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Simplify check for available buffer.

The read index can never pass the write index. There is no need to
double check.

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

Change-Id: Idf0dad8b1b658f15f394ab642b63407ed5065fd7
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
aaf9a7a0e58e8ab1d35ae90f02f018eb9a9dd64b 26-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Wrap read index when it passes write index.

If the read index catches up to or passes the write index, move on to
the next buffer.

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

Change-Id: I8df3f1a43b43d5adc8a0c83bf65a22ebf7dca9e3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h
d6fabc37ee7e0d450873d22bdefca68526ee05d7 18-Jan-2012 Dylan Reid <dgreid@chromium.org> CRAS: Add shm infrastructure.

This is used to manage the sharing of audio samples bewteen the audio
server and clients.

BUG=chrome-os-partner:6382
TEST=included shm_ut gtest.

Change-Id: I333a61be6f4d604f7f93d4b304bcbc295e374ac6
Signed-off-by: Dylan Reid <dgreid@chromium.org>
/external/adhd/cras/src/common/cras_shm.h