Once stream is resumed it may be required to reset some state of codec, i.e. in case of SBC we need to reset monotonic clock and frames count which are used for synchronization. --- android/hal-audio.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/android/hal-audio.c b/android/hal-audio.c index 3f53295..aeb6ea4 100644 --- a/android/hal-audio.c +++ b/android/hal-audio.c @@ -71,6 +71,9 @@ struct sbc_data { uint8_t *out_buf; unsigned frame_duration; + + struct timespec start; + unsigned frames_sent; }; static int sbc_get_presets(struct audio_preset *preset, size_t *len); @@ -79,6 +82,7 @@ static int sbc_codec_init(struct audio_preset *preset, uint16_t mtu, static int sbc_cleanup(void *codec_data); static int sbc_get_config(void *codec_data, struct audio_input_config *config); +static void sbc_resume(void *codec_data); struct audio_codec { uint8_t type; @@ -90,6 +94,7 @@ struct audio_codec { int (*cleanup) (void *codec_data); int (*get_config) (void *codec_data, struct audio_input_config *config); + void (*resume) (void *codec_data); ssize_t (*write_data) (void *codec_data, const void *buffer, size_t bytes); }; @@ -103,6 +108,7 @@ static const struct audio_codec audio_codecs[] = { .init = sbc_codec_init, .cleanup = sbc_cleanup, .get_config = sbc_get_config, + .resume = sbc_resume, } }; @@ -349,6 +355,17 @@ static int sbc_get_config(void *codec_data, return AUDIO_STATUS_SUCCESS; } +static void sbc_resume(void *codec_data) +{ + struct sbc_data *sbc_data = (struct sbc_data *) codec_data; + + DBG(""); + + clock_gettime(CLOCK_MONOTONIC, &sbc_data->start); + + sbc_data->frames_sent = 0; +} + static void audio_ipc_cleanup(void) { if (audio_sk >= 0) { @@ -671,6 +688,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, if (ipc_resume_stream_cmd(out->ep->id) != AUDIO_STATUS_SUCCESS) return -1; + out->ep->codec->resume(out->ep->codec_data); + out->audio_state = AUDIO_A2DP_STATE_STARTED; } -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html