Minimum output buffer size in AudioManagerCras should be fetched from CRAS |
|||||||||||
Issue description
media/audio/cras/audio_manager_cras.cc currently contains the following:
int AudioManagerCras::GetMinimumOutputBufferSizePerBoard() {
// On faster boards we can use smaller buffer size for lower latency.
// On slower boards we should use larger buffer size to prevent underrun.
std::string board = base::SysInfo::GetLsbReleaseBoard();
if (board == "kevin")
return 768;
else if (board == "samus")
return 256;
return 512;
}
Instead of hardcoding board-specific behavior into Chrome, this should be passed via a command-line flag. The flag should be set from src/platform2/libchromeos-ui/chromeos/ui/chromium_command_builder.cc. Note that you'll also need to add it to IUSE in the libchromeos-use-flags ebuild.
In addition to keeping all of our per-board configuration in one place[1], this also makes it easy to test the Chrome code: unit tests can add the flag to base::CommandLine as needed.
1. Two if you count session_manager's chrome_setup.cc, used for browser-specific flags.
,
Jul 28 2017
Yes, values can't be attached to USE flags. While you could either check the board names directly in ChromiumCommandBuilder or add new e.g. "large_audio_buffer" and "slow_audio_buffer" USE flags, it's probably best to key the different buffer sizes off of USE flag(s) that describe the hardware characteristics that you actually care about. For example, what are the "faster" and "slower" here referring to -- CPU speed? The code in Chrome seems a bit odd, since it special-cases kevin as the only "slower board" and samus as the only "faster board". We have many boards that are slower than kevin: what about daisy, for example? Should that also use a larger buffer? If/when there are faster boards than samus, how will you ensure that they also get the smaller buffer size?
,
Aug 1 2017
Hi Derat, Thank you for the explanation. I see. I would check the board names directly in ChromiumCommandBuilder instead of using USE flag. As for the logic to set the buffer size, we expect the default buffer size 512 should work fine on every board. Since we have seen many feedback about audio noise on kevin, we set the buffer size higher. We are planning to test more boards that can support smaller buffer size, and will let them use smaller buffer size. So setting this value is an ad hoc process. Thanks!
,
Aug 1 2017
How about introducing e.g. small_audio_buffer and large_audio_buffer USE flags so it's easy to control this from board overlays instead of needing to change code in multiple places (libchromeos-use-flags, libchromeos-ui/session_manager, etc.) every time?
,
Aug 1 2017
cras/adhd already allow boards to install /etc/cras/get_device_config_dir to customize. shouldn't the boards use that ?
,
Aug 1 2017
I think that this is changing the size of a buffer in Chrome, not in CRAS. (I don't know if there's any way for Chrome to get audio settings from CRAS at startup. If not, maybe there should be!)
,
Aug 2 2017
I see. We can add a dBus API for Chrome to query the minimum output buffer size. However, this config is for Chrome, not CRAS, so putting the config in CRAS looks weird. For example, CRAS can play audio with output buffer size set to as low as client want. The output buffer size we set for Chrome is just a value that we think it should be appropriate for most of the Chrome's use cases. Setting small_audio_buffer for 256 and large_audio_buffer for 768, and set the flag in board overlay looks more reasonable to me. These three levels should be good enough for us. Thanks!
,
Aug 4 2017
Wucheng is very kind to help this issue. Thanks Wucheng!
,
Aug 8 2017
Jimmy, Hsin-yu and I discussed. - We may add other different buffer sizes in the future. Having three configuration (large, small, and default) won't be enough. We need a way to pass a number. - We may need more board-specific settings in the future. It's better to make this easy to change or add. Installing board-specific config files in /etc/cras is a good idea. - Currently cras does not have any knowledge of board-specific settings. But putting that knowledge in other places is not better. It's still better for chrome to get the audio settings (the minimum output buffer size) from cras at startup. I have two CLs to test this locally. One adds a Dbus API in cras. The other uses the api in chrome. They are not ready for review yet. https://chromium-review.googlesource.com/c/605340 https://chromium-review.googlesource.com/c/605341
,
Aug 8 2017
Thanks wuchengli. That plan seems totally good to me. I think exposing data cras already has to chrome is a good idea.
,
Aug 9 2017
,
Aug 10 2017
,
Aug 11 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/board-overlays/+/8f873153e77cce5130ab09985b83a40fd2cd4b24 commit 8f873153e77cce5130ab09985b83a40fd2cd4b24 Author: Wu-Cheng Li <wuchengli@google.com> Date: Fri Aug 11 07:46:22 2017 samus/kevin: add board.ini for cras-config. board.ini is per-board audio settings for cras. BUG= chromium:749345 TEST=cras can read the min output buffer size from the config. Change-Id: I74a86ab99e366efa4f0b33e90b5ebf635e2e060e Reviewed-on: https://chromium-review.googlesource.com/611681 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Hsinyu Chao <hychao@chromium.org> Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org> [add] https://crrev.com/8f873153e77cce5130ab09985b83a40fd2cd4b24/overlay-samus/chromeos-base/chromeos-bsp-samus/files/audio-config/cras-config/post_mp_a/board.ini [add] https://crrev.com/8f873153e77cce5130ab09985b83a40fd2cd4b24/overlay-samus/chromeos-base/chromeos-bsp-samus/files/audio-config/cras-config/pre_mp_a/board.ini [add] https://crrev.com/8f873153e77cce5130ab09985b83a40fd2cd4b24/overlay-kevin/chromeos-base/chromeos-bsp-kevin/files/audio-config/cras-config/board.ini [rename] https://crrev.com/8f873153e77cce5130ab09985b83a40fd2cd4b24/overlay-samus/chromeos-base/chromeos-bsp-samus/chromeos-bsp-samus-0.0.2-r17.ebuild [rename] https://crrev.com/8f873153e77cce5130ab09985b83a40fd2cd4b24/overlay-kevin/chromeos-base/chromeos-bsp-kevin/chromeos-bsp-kevin-0.0.3-r9.ebuild
,
Aug 11 2017
+Andrew from soundtrap and other audio folks. Hi Wucheng, sorry, I just realized today that the behavior of Chrome is changed in issue https://bugs.chromium.org/p/chromium/issues/detail?id=708917 CL https://codereview.chromium.org/2908073002 Before: samus: min = default = 256 kevin: min = default = 768 others: min = default = 512 If user requests a value larger than min, it will get min. E.g. WebRTC requests 480, and it gets 512. Web app requests 128, and it gets 512. Most other webaudio page uses default 512. After the CL: samus: default = 256 kevin: default = 768 others: default = 512 ( https://codereview.chromium.org/2908073002/patch/260001/270005 ) min: 256 ( https://codereview.chromium.org/2908073002/patch/260001/270008 ) Now WebRTC requests 480, and it gets 480. Web app requests 128, and it gets 256. Most other webaudio page uses default 512. Now we accept the fact that audio glitches badly if user requests small buffer size. (See discussion around https://codereview.chromium.org/2908073002#msg35 ) The original MinOutputBufferSize now should be renamed to DefaultOutputBufferSize to reflect its usage in audio_manager_cras. Does this sound good to everyone? Thanks!
,
Aug 11 2017
OK. I'll rename dbus API GetMinOutputBufferSize to GetDefaultOutputBufferSize.
,
Aug 11 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/adhd/+/f1d6d8f6e9375240cbfbd3885a976b9d95694f23 commit f1d6d8f6e9375240cbfbd3885a976b9d95694f23 Author: Wu-Cheng Li <wuchengli@google.com> Date: Fri Aug 11 17:35:54 2017 CRAS: add GetMinOutputBufferSize dbus API BUG= chromium:749345 TEST=Add a board.ini in cras-config and see chrome read the minimum output buffer size from the config. Change-Id: I85e511cf7ded092a2ec3848e0c62c15b3da2e578 Reviewed-on: https://chromium-review.googlesource.com/605340 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org> [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/common/cras_types.h [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/server/cras_system_state.h [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/tests/system_state_unittest.cc [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/Makefile.am [add] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/server/config/cras_board_config.c [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/server/cras_system_state.c [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/server/cras_dbus_control.c [add] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/src/server/config/cras_board_config.h [modify] https://crrev.com/f1d6d8f6e9375240cbfbd3885a976b9d95694f23/cras/README.dbus-api
,
Aug 11 2017
Thanks for working on this! I'm updating the title to match the current approach.
,
Aug 13 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/adhd/+/4fb25d096253960d9346ee74eba168a0908f7f6c commit 4fb25d096253960d9346ee74eba168a0908f7f6c Author: Kuang-che Wu <kcwu@chromium.org> Date: Sun Aug 13 07:57:08 2017 Revert "CRAS: add GetMinOutputBufferSize dbus API" This reverts commit f1d6d8f6e9375240cbfbd3885a976b9d95694f23. Reason for revert: break many CTS/GTS tests (b/64621074) Original change's description: > CRAS: add GetMinOutputBufferSize dbus API > > BUG= chromium:749345 > TEST=Add a board.ini in cras-config and see chrome read the > minimum output buffer size from the config. > > Change-Id: I85e511cf7ded092a2ec3848e0c62c15b3da2e578 > Reviewed-on: https://chromium-review.googlesource.com/605340 > Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> > Tested-by: Wu-Cheng Li <wuchengli@chromium.org> > Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> > Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org> Bug: chromium:749345 ,b:64621074 Change-Id: Ib9924b84d301cbfa6f68cc4370c7c29adb9c896e Reviewed-on: https://chromium-review.googlesource.com/611750 Commit-Ready: Kuang-che Wu <kcwu@chromium.org> Tested-by: Kuang-che Wu <kcwu@chromium.org> Reviewed-by: Kuang-che Wu <kcwu@chromium.org> [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/common/cras_types.h [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/server/cras_system_state.h [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/tests/system_state_unittest.cc [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/Makefile.am [delete] https://crrev.com/fa4192508082d60af91b89ea2c0b02e9bad56de8/cras/src/server/config/cras_board_config.c [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/server/cras_system_state.c [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/src/server/cras_dbus_control.c [delete] https://crrev.com/fa4192508082d60af91b89ea2c0b02e9bad56de8/cras/src/server/config/cras_board_config.h [modify] https://crrev.com/4fb25d096253960d9346ee74eba168a0908f7f6c/cras/README.dbus-api
,
Aug 15 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/board-overlays/+/1766ede2a432e45f9db3795ffa3758521a19928a commit 1766ede2a432e45f9db3795ffa3758521a19928a Author: Wu-Cheng Li <wuchengli@google.com> Date: Tue Aug 15 15:59:12 2017 kevin/samus: rename to default_output_buffer_size in cras config. Cras Dbus API was changed from min_output_buffer_size to default_output_buffer_size. Update cras config to match it. BUG= chromium:749345 TEST=Print log in cras and check if the size is correct. Change-Id: Id89a28eea4ee43689cff0a073f85d862cc5a627f Reviewed-on: https://chromium-review.googlesource.com/612978 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> [modify] https://crrev.com/1766ede2a432e45f9db3795ffa3758521a19928a/overlay-samus/chromeos-base/chromeos-bsp-samus/files/audio-config/cras-config/post_mp_a/board.ini [rename] https://crrev.com/1766ede2a432e45f9db3795ffa3758521a19928a/overlay-samus/chromeos-base/chromeos-bsp-samus/chromeos-bsp-samus-0.0.2-r18.ebuild [modify] https://crrev.com/1766ede2a432e45f9db3795ffa3758521a19928a/overlay-kevin/chromeos-base/chromeos-bsp-kevin/files/audio-config/cras-config/board.ini [rename] https://crrev.com/1766ede2a432e45f9db3795ffa3758521a19928a/overlay-kevin/chromeos-base/chromeos-bsp-kevin/chromeos-bsp-kevin-0.0.3-r10.ebuild [modify] https://crrev.com/1766ede2a432e45f9db3795ffa3758521a19928a/overlay-samus/chromeos-base/chromeos-bsp-samus/files/audio-config/cras-config/pre_mp_a/board.ini
,
Aug 16 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/system_api/+/c0181cc31bec13d32edf17fba9ceff94f638e524 commit c0181cc31bec13d32edf17fba9ceff94f638e524 Author: Wu-Cheng Li <wuchengli@google.com> Date: Wed Aug 16 05:22:01 2017 system_api: add constant for cras GetDefaultOutputBufferSize. BUG= chromium:749345 TEST=Add log and see dbus API is correctly called. Change-Id: I3612d5ece286453edd3c84718661b7c4cb05e4e4 Reviewed-on: https://chromium-review.googlesource.com/615215 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dan Erat (OOO Aug 15-16) <derat@chromium.org> [modify] https://crrev.com/c0181cc31bec13d32edf17fba9ceff94f638e524/dbus/service_constants.h
,
Aug 16 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/adhd/+/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa commit 96f1a8ca2b70b37b7d9841f476f451fe41cb1daa Author: Wu-Cheng Li <wuchengli@google.com> Date: Wed Aug 16 05:21:58 2017 CRAS: add GetDefaultOutputBufferSize dbus API This is a reland of http://crosreview.com/605340. The differences are: - CRAS_SERVER_STATE_VERSION is not changed. The new variable is added at the end so it is backward compatible. - Name is changed from GetMinOutputBufferSize to GetDefaultOutputBufferSize. BUG= chromium:749345 TEST=Add a board.ini in cras-config and see chrome read the minimum output buffer size from the config. Change-Id: I240bb39a1fe15bf940e25f278244e7283cbe03fe Reviewed-on: https://chromium-review.googlesource.com/612926 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/common/cras_types.h [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/server/cras_system_state.h [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/tests/system_state_unittest.cc [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/Makefile.am [add] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/server/config/cras_board_config.c [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/server/cras_system_state.c [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/server/cras_dbus_control.c [add] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/src/server/config/cras_board_config.h [modify] https://crrev.com/96f1a8ca2b70b37b7d9841f476f451fe41cb1daa/cras/README.dbus-api
,
Aug 18 2017
https://chromium-review.googlesource.com/c/605341/ is waiting for owner review.
,
Aug 19 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/96cbab92e2053621198dcef499ae6cca6a4b72de commit 96cbab92e2053621198dcef499ae6cca6a4b72de Author: Wu-Cheng Li <wuchengli@google.com> Date: Sat Aug 19 03:41:21 2017 cras: use GetDefaultOutputBufferSize dbus API. Dbus now provides an API to get default output buffer size. Use it so we do not need to hardcode the size in AudioManagerCras. BUG= chromium:749345 TEST=Print log and check if chrome reads the buffer size from cras config file. Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I146c82834534a5b622c5338a5cabd1991572859d Reviewed-on: https://chromium-review.googlesource.com/605341 Reviewed-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Max Morin <maxmorin@chromium.org> Reviewed-by: Jenny Zhang <jennyz@chromium.org> Commit-Queue: Wu-Cheng Li <wuchengli@chromium.org> Cr-Commit-Position: refs/heads/master@{#495798} [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/audio/cras_audio_handler.cc [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/audio/cras_audio_handler.h [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/dbus/cras_audio_client.cc [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/dbus/cras_audio_client.h [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/dbus/fake_cras_audio_client.cc [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/chromeos/dbus/fake_cras_audio_client.h [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/media/audio/cras/audio_manager_cras.cc [modify] https://crrev.com/96cbab92e2053621198dcef499ae6cca6a4b72de/media/audio/cras/audio_manager_cras.h
,
Aug 19 2017
,
Aug 31 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/adhd/+/0f26a9ce78261d34227dc1996e8fba379ecea3f0 commit 0f26a9ce78261d34227dc1996e8fba379ecea3f0 Author: Wu-Cheng Li <wuchengli@google.com> Date: Thu Aug 31 04:24:04 2017 CRAS: add GetDefaultOutputBufferSize dbus API This is a reland of http://crosreview.com/605340. The differences are: - CRAS_SERVER_STATE_VERSION is not changed. The new variable is added at the end so it is backward compatible. - Name is changed from GetMinOutputBufferSize to GetDefaultOutputBufferSize. BUG= chromium:749345 TEST=Add a board.ini in cras-config and see chrome read the minimum output buffer size from the config. Change-Id: I240bb39a1fe15bf940e25f278244e7283cbe03fe Reviewed-on: https://chromium-review.googlesource.com/612926 Commit-Ready: Wu-Cheng Li <wuchengli@chromium.org> Tested-by: Wu-Cheng Li <wuchengli@chromium.org> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> (cherry picked from commit 96f1a8ca2b70b37b7d9841f476f451fe41cb1daa) Reviewed-on: https://chromium-review.googlesource.com/644996 Reviewed-by: Hsinyu Chao <hychao@chromium.org> Tested-by: Hsinyu Chao <hychao@chromium.org> Commit-Queue: Hsinyu Chao <hychao@chromium.org> [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/common/cras_types.h [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/server/cras_system_state.h [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/tests/system_state_unittest.cc [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/Makefile.am [add] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/server/config/cras_board_config.c [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/server/cras_system_state.c [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/server/cras_dbus_control.c [add] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/src/server/config/cras_board_config.h [modify] https://crrev.com/0f26a9ce78261d34227dc1996e8fba379ecea3f0/cras/README.dbus-api
,
Jan 22 2018
|
|||||||||||
►
Sign in to add a comment |
|||||||||||
Comment 1 by cychiang@chromium.org
, Jul 28 2017