system/bt
Revision | 8587f4f9a808dc15c1b949c10a5b049f83fda2f8 (tree) |
---|---|
Time | 2016-10-05 08:24:56 |
Author | Steve Kondik <steve@cyng...> |
Commiter | Steve Kondik |
Merge tag 'android-7.0.0_r14' of https://android.googlesource.com/platform/system/bt into cm-14.0
Android 7.0.0 Release 14 (NBD90Z)
Change-Id: I634414c79b6cb207d22bb29dfb2854e96ae77e46
@@ -671,8 +671,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, | ||
671 | 671 | size_t bytes) |
672 | 672 | { |
673 | 673 | struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream; |
674 | - int sent; | |
675 | - int us_delay; | |
674 | + int sent = -1; | |
676 | 675 | #ifdef BT_AUDIO_SYSTRACE_LOG |
677 | 676 | char trace_buf[512]; |
678 | 677 | #endif |
@@ -682,8 +681,8 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, | ||
682 | 681 | pthread_mutex_lock(&out->common.lock); |
683 | 682 | if (out->common.state == AUDIO_A2DP_STATE_SUSPENDED || |
684 | 683 | out->common.state == AUDIO_A2DP_STATE_STOPPING) { |
685 | - INFO("stream suspended or closing"); | |
686 | - goto error; | |
684 | + DEBUG("stream suspended or closing"); | |
685 | + goto finish; | |
687 | 686 | } |
688 | 687 | |
689 | 688 | /* only allow autostarting if we are in stopped or standby */ |
@@ -696,13 +695,13 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, | ||
696 | 695 | if (start_audio_datapath(&out->common) < 0) |
697 | 696 | #endif |
698 | 697 | { |
699 | - goto error; | |
698 | + goto finish; | |
700 | 699 | } |
701 | 700 | } |
702 | 701 | else if (out->common.state != AUDIO_A2DP_STATE_STARTED) |
703 | 702 | { |
704 | 703 | ERROR("stream not in stopped or standby"); |
705 | - goto error; | |
704 | + goto finish; | |
706 | 705 | } |
707 | 706 | #ifdef BT_AUDIO_SAMPLE_LOG |
708 | 707 | if (outputpcmsamplefile) |
@@ -751,26 +750,24 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, | ||
751 | 750 | } else { |
752 | 751 | ERROR("write failed : stream suspended, avoid resetting state"); |
753 | 752 | } |
754 | - goto error; | |
753 | + goto finish; | |
755 | 754 | } |
756 | 755 | |
756 | +finish: ; | |
757 | 757 | const size_t frames = bytes / audio_stream_out_frame_size(stream); |
758 | 758 | out->frames_rendered += frames; |
759 | 759 | out->frames_presented += frames; |
760 | 760 | pthread_mutex_unlock(&out->common.lock); |
761 | - return bytes; | |
762 | 761 | |
763 | -error: | |
764 | - pthread_mutex_unlock(&out->common.lock); | |
765 | - us_delay = calc_audiotime(out->common.cfg, bytes); | |
766 | - | |
767 | - DEBUG("emulate a2dp write delay (%d us)", us_delay); | |
768 | - | |
769 | - usleep(us_delay); | |
762 | + // If send didn't work out, sleep to emulate write delay. | |
763 | + if (sent == -1) { | |
764 | + const int us_delay = calc_audiotime(out->common.cfg, bytes); | |
765 | + DEBUG("emulate a2dp write delay (%d us)", us_delay); | |
766 | + usleep(us_delay); | |
767 | + } | |
770 | 768 | return bytes; |
771 | 769 | } |
772 | 770 | |
773 | - | |
774 | 771 | static uint32_t out_get_sample_rate(const struct audio_stream *stream) |
775 | 772 | { |
776 | 773 | struct a2dp_stream_out *out = (struct a2dp_stream_out *)stream; |
@@ -1051,7 +1051,6 @@ static void btif_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req) | ||
1051 | 1051 | return; |
1052 | 1052 | } |
1053 | 1053 | if (check_cod(&bd_addr, COD_AV_HEADSETS) || |
1054 | - check_cod(&bd_addr, COD_AV_HANDSFREE) || | |
1055 | 1054 | check_cod(&bd_addr, COD_AV_HEADPHONES) || |
1056 | 1055 | check_cod(&bd_addr, COD_AV_PORTABLE_AUDIO) || |
1057 | 1056 | check_cod(&bd_addr, COD_AV_HIFI_AUDIO) || |