summaryrefslogtreecommitdiff
path: root/android/hal-audio.c
diff options
context:
space:
mode:
authorAndrzej Kaczmarek <andrzej.kaczmarek@tieto.com>2014-05-26 15:16:33 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-06-01 10:17:16 +0300
commit5dab4aaafaeff8d3a71e8e03eecbe62392075d19 (patch)
tree7128f100dc44203c0cbd75dd34702cd8227432cb /android/hal-audio.c
parent3e23bec36539f9c42a575577d9e973ec01a7461e (diff)
downloadbluez-5dab4aaafaeff8d3a71e8e03eecbe62392075d19.tar.gz
android/hal-audio: Send packets only when data were encoded
Codec may not return encoded packet on every encode_mediapacket call, i.e. in case there's not enough data it may buffer data and encode on subsequent calls when enough data were provided. We need to make sure media packet is written only in case somethind was encoded so we don't send empty packets.
Diffstat (limited to 'android/hal-audio.c')
-rw-r--r--android/hal-audio.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/android/hal-audio.c b/android/hal-audio.c
index 534620a91..9807a5d5a 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -691,8 +691,12 @@ static bool write_data(struct a2dp_stream_out *out, const void *buffer,
}
}
- /* in resync mode we'll just drop mediapackets */
- if (!ep->resync) {
+ /* we send data only in case codec encoded some data, i.e. some
+ * codecs do internal buffering and output data only if full
+ * frame can be encoded
+ * in resync mode we'll just drop mediapackets
+ */
+ if (written > 0 && !ep->resync) {
/* wait some time for socket to be ready for write,
* but we'll just skip writing data if timeout occurs
*/