diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-03 02:10:03 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-03 02:10:03 +0000 |
commit | 16e5891999ead6783786b6ca43a4320a86856c4b (patch) | |
tree | 145a333ddd565d247c1333d4ce70ec7cf5f3269c | |
parent | 3bb642c4e252ec29f7f798c4fb131055410aa1c3 (diff) | |
parent | 1e78a4260d6e2cd3d876b3ee4ae77129f385cc38 (diff) | |
download | libhardware-16e5891999ead6783786b6ca43a4320a86856c4b.tar.gz |
Snap for 8142553 from 1e78a4260d6e2cd3d876b3ee4ae77129f385cc38 to tm-release
Change-Id: I5970cb03cdfb83ff57855147d2dec1229a38f26b
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | include/hardware/audio.h | 18 | ||||
-rw-r--r-- | modules/audio_remote_submix/audio_hw.cpp | 22 |
3 files changed, 38 insertions, 6 deletions
@@ -58,6 +58,10 @@ cc_library_headers { ], }, }, + apex_available: [ + "//apex_available:platform", + "com.android.bluetooth", + ], min_sdk_version: "29", host_supported: true, diff --git a/include/hardware/audio.h b/include/hardware/audio.h index a3b52146..daaa16f1 100644 --- a/include/hardware/audio.h +++ b/include/hardware/audio.h @@ -1047,6 +1047,24 @@ struct audio_hw_device { */ int (*get_audio_port_v7)(struct audio_hw_device *dev, struct audio_port_v7 *port); + + /** + * Called when the state of the connection of an external device has been changed. + * The "port" parameter is only used as input and besides identifying the device + * port, also may contain additional information such as extra audio descriptors. + * + * HAL version 3.2 and higher only. If the HAL does not implement this method, + * it must leave the function entry as null, or return -ENOSYS. In this case + * the framework will use 'set_parameters', which can only pass the device address. + * + * @param dev the audio HAL device context. + * @param port device port identification and extra information. + * @param connected whether the external device is connected. + * @return retval operation completion status. + */ + int (*set_device_connected_state_v7)(struct audio_hw_device *dev, + struct audio_port_v7 *port, + bool connected); }; typedef struct audio_hw_device audio_hw_device_t; diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp index 42d3b98d..f96854b5 100644 --- a/modules/audio_remote_submix/audio_hw.cpp +++ b/modules/audio_remote_submix/audio_hw.cpp @@ -63,7 +63,7 @@ namespace android { #endif // SUBMIX_VERBOSE_LOGGING // NOTE: This value will be rounded up to the nearest power of 2 by MonoPipe(). -#define DEFAULT_PIPE_SIZE_IN_FRAMES (1024*4) +#define DEFAULT_PIPE_SIZE_IN_FRAMES (1024*4) // size at default sample rate // Value used to divide the MonoPipe() buffer into segments that are written to the source and // read from the sink. The maximum latency of the device is the size of the MonoPipe's buffer // the minimum latency is the MonoPipe buffer size divided by this value. @@ -208,6 +208,11 @@ static bool sample_rate_supported(const uint32_t sample_rate) return return_value; } +static size_t pipe_size_in_frames(const uint32_t sample_rate) +{ + return DEFAULT_PIPE_SIZE_IN_FRAMES * ((float) sample_rate / DEFAULT_SAMPLE_RATE_HZ); +} + // Determine whether the specified sample rate is supported, if it is return the specified sample // rate, otherwise return the default sample rate for the submix module. static uint32_t get_supported_sample_rate(uint32_t sample_rate) @@ -1289,8 +1294,10 @@ static int adev_open_output_stream(struct audio_hw_device *dev, // Store a pointer to the device from the output stream. out->dev = rsxadev; // Initialize the pipe. - ALOGV("adev_open_output_stream(): about to create pipe at index %d", route_idx); - submix_audio_device_create_pipe_l(rsxadev, config, DEFAULT_PIPE_SIZE_IN_FRAMES, + const size_t pipeSizeInFrames = pipe_size_in_frames(config->sample_rate); + ALOGI("adev_open_output_stream(): about to create pipe at index %d, rate %u, pipe size %zu", + route_idx, config->sample_rate, pipeSizeInFrames); + submix_audio_device_create_pipe_l(rsxadev, config, pipeSizeInFrames, DEFAULT_PIPE_PERIOD_COUNT, NULL, out, address, route_idx); #if LOG_STREAMS_TO_FILES out->log_fd = open(LOG_STREAM_OUT_FILENAME, O_CREAT | O_TRUNC | O_WRONLY, @@ -1419,7 +1426,8 @@ static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev, const size_t frame_size_in_bytes = audio_channel_count_from_in_mask(config->channel_mask) * audio_bytes_per_sample(config->format); if (max_buffer_period_size_frames == 0) { - max_buffer_period_size_frames = DEFAULT_PIPE_SIZE_IN_FRAMES; + max_buffer_period_size_frames = + pipe_size_in_frames(get_supported_sample_rate(config->sample_rate));; } const size_t buffer_size = max_buffer_period_size_frames * frame_size_in_bytes; SUBMIX_ALOGV("adev_get_input_buffer_size() returns %zu bytes, %zu frames", @@ -1532,8 +1540,10 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->read_error_count = 0; // Initialize the pipe. - ALOGV("adev_open_input_stream(): about to create pipe"); - submix_audio_device_create_pipe_l(rsxadev, config, DEFAULT_PIPE_SIZE_IN_FRAMES, + const size_t pipeSizeInFrames = pipe_size_in_frames(config->sample_rate); + ALOGI("adev_open_input_stream(): about to create pipe at index %d, rate %u, pipe size %zu", + route_idx, config->sample_rate, pipeSizeInFrames); + submix_audio_device_create_pipe_l(rsxadev, config, pipeSizeInFrames, DEFAULT_PIPE_PERIOD_COUNT, in, NULL, address, route_idx); sp <MonoPipe> sink = rsxadev->routes[route_idx].rsxSink; |