[PATCH 07/26] android/hal-audio: Send packets only when data were encoded

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 android/hal-audio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 534620a..9807a5d 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
 			 */
-- 
1.9.3

--
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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux