summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OWNERS2
-rw-r--r--include/hardware/bluetooth.h33
-rw-r--r--modules/audio_remote_submix/audio_hw.cpp45
3 files changed, 61 insertions, 19 deletions
diff --git a/OWNERS b/OWNERS
index da2454a9..b6b18dac 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,4 @@
-eisenbach@google.com
+zachoverflow@google.com
elaurent@google.com
jpawlowski@google.com
malchev@google.com
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index f95b75fb..96edd9fc 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -267,19 +267,25 @@ typedef struct
void *val;
} bt_property_t;
-/** Bluetooth Out Of Band data for bonding */
-typedef struct
-{
- uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
- uint8_t c192[16]; /* Simple Pairing Hash C-192 */
- uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
- uint8_t c256[16]; /* Simple Pairing Hash C-256 */
- uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
- uint8_t sm_tk[16]; /* Security Manager TK Value */
- uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
- uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
-} bt_out_of_band_data_t;
+/** Represents the actual Out of Band data itself */
+typedef struct {
+ // Both
+ uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type (1) */
+ uint8_t c[16]; /* Simple Pairing Hash C-192/256 (Classic or LE) */
+ uint8_t r[16]; /* Simple Pairing Randomizer R-192/256 (Classic or LE) */
+ uint8_t device_name[256]; /* Name of the device */
+
+ // Classic
+ uint8_t oob_data_length[2]; /* Classic only data Length. Value includes this
+ in length */
+ uint8_t class_of_device[2]; /* Class of Device (Classic or LE) */
+ // LE
+ uint8_t le_device_role; /* Supported and preferred role of device */
+ uint8_t sm_tk[16]; /* Security Manager TK Value (LE Only) */
+ uint8_t le_flags; /* LE Flags for discoverability and features */
+ uint8_t le_appearance[2]; /* For the appearance of the device */
+} bt_oob_data_t;
/** Bluetooth Device Type */
@@ -517,7 +523,8 @@ typedef struct {
/** Create Bluetooth Bond using out of band data */
int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport,
- const bt_out_of_band_data_t *oob_data);
+ const bt_oob_data_t *p192_data,
+ const bt_oob_data_t *p256_data);
/** Remove Bond */
int (*remove_bond)(const RawAddress *bd_addr);
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 72e1fa55..b43a44dc 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -196,6 +196,7 @@ struct submix_stream_in {
struct timespec record_start_time;
// how many frames have been requested to be read
uint64_t read_counter_frames;
+ uint64_t read_counter_frames_since_standby;
#if ENABLE_LEGACY_INPUT_OPEN
// Number of references to this input stream.
@@ -836,7 +837,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
sp<MonoPipeReader> source = rsxadev->routes[out->route_handle].rsxSource;
const struct submix_stream_in *in = rsxadev->routes[out->route_handle].input;
const bool dont_block = (in == NULL)
- || (in->input_standby && (in->read_counter_frames != 0));
+ || (in->input_standby && (in->read_counter_frames_since_standby != 0));
if (dont_block && availableToWrite < frames) {
static uint8_t flush_buffer[64];
const size_t flushBufferSizeFrames = sizeof(flush_buffer) / frame_size;
@@ -1141,11 +1142,12 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
// or when we start recording silence, and reset projected time
int rc = clock_gettime(CLOCK_MONOTONIC, &in->record_start_time);
if (rc == 0) {
- in->read_counter_frames = 0;
+ in->read_counter_frames_since_standby = 0;
}
}
in->read_counter_frames += frames_to_read;
+ in->read_counter_frames_since_standby += frames_to_read;
size_t remaining_frames = frames_to_read;
{
@@ -1324,12 +1326,12 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
record_duration.tv_nsec += 1000000000;
}
- // read_counter_frames contains the number of frames that have been read since the
- // beginning of recording (including this call): it's converted to usec and compared to
+ // read_counter_frames_since_standby contains the number of frames that have been read since
+ // the beginning of recording (including this call): it's converted to usec and compared to
// how long we've been recording for, which gives us how long we must wait to sync the
// projected recording time, and the observed recording time.
long projected_vs_observed_offset_us =
- ((int64_t)(in->read_counter_frames
+ ((int64_t)(in->read_counter_frames_since_standby
- (record_duration.tv_sec*sample_rate)))
* 1000000 / sample_rate
- (record_duration.tv_nsec / 1000);
@@ -1353,6 +1355,37 @@ static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
return 0;
}
+static int in_get_capture_position(const struct audio_stream_in *stream,
+ int64_t *frames, int64_t *time)
+{
+ if (stream == NULL || frames == NULL || time == NULL) {
+ return -EINVAL;
+ }
+
+ struct submix_stream_in * const in = audio_stream_in_get_submix_stream_in(
+ (struct audio_stream_in*)stream);
+ struct submix_audio_device * const rsxadev = in->dev;
+
+ pthread_mutex_lock(&rsxadev->lock);
+ sp<MonoPipeReader> source = rsxadev->routes[in->route_handle].rsxSource;
+ if (source == NULL) {
+ ALOGW("%s called on released input", __FUNCTION__);
+ pthread_mutex_unlock(&rsxadev->lock);
+ return -ENODEV;
+ }
+ *frames = in->read_counter_frames;
+ const ssize_t frames_in_pipe = source->availableToRead();
+ pthread_mutex_unlock(&rsxadev->lock);
+ if (frames_in_pipe > 0) {
+ *frames += frames_in_pipe;
+ }
+
+ struct timespec timestamp;
+ clock_gettime(CLOCK_MONOTONIC, &timestamp);
+ *time = timestamp.tv_sec * 1000000000LL + timestamp.tv_nsec;
+ return 0;
+}
+
static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
{
(void)stream;
@@ -1671,6 +1704,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
in->stream.set_gain = in_set_gain;
in->stream.read = in_read;
in->stream.get_input_frames_lost = in_get_input_frames_lost;
+ in->stream.get_capture_position = in_get_capture_position;
in->dev = rsxadev;
#if LOG_STREAMS_TO_FILES
@@ -1680,6 +1714,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev,
// Initialize the input stream.
in->read_counter_frames = 0;
+ in->read_counter_frames_since_standby = 0;
in->input_standby = true;
if (rsxadev->routes[route_idx].output != NULL) {
in->output_standby_rec_thr = rsxadev->routes[route_idx].output->output_standby;