2013年11月26日星期二

Bluetooth A2DP audio quality in depth

Summary

This post explains Bluetooth audio profile A2DP, and discuss audio quality of it in technical aspect.

1. Bluetooth A2DP profile

Let's begin with Bluetooth core specification, the most popular and widely supported one is Bluetooth 2.0/2.1 + EDR, which can transmit at 2.1Mbit/s at most. High speed feature is introduced since Bluetooth 3.0, its speed can go up to 24Mbit/s when transfering data through WiFi. The devices support this feature would be marked Bluetooth 3.0 + HS. So those support Bluetooth 3.0 or even 4.0 but without the "HS" logo will remain the same as their Bluetooth 2.1 peers. As for Bluetooth 4.0, it contains 3 subsets that are called classic Bluetooth, high speed Bluetooth and low energy Bluetooth, which is actually equals to 2.1 plus 3.0 + HS and low energy Bluetooth.

A2DP(Advanced Audio Distribution Profile) is a Bluetooth profile, which is supported by almost all Bluetooth speakers and headphones. It is the key that defines audio data bandwidth and audio quality.

2013年11月19日星期二

How to detect Android Cursor leak

Summary:This post tells the theory of detecting SQLite database Cursor leak of your Android app, alongside some common mistake examples. Some leaks are hardly noticable in the code until memory errors happen. This sort of method can be applied to other kinds of resources leak as well.

Cursor leak means that you have opened a Cursor object, which is usually associated with a portion of memory, but fail to close it before you lost referece to it. If it do happens and is repeated several hundreds of times, you would finally be unable to query SQLite database, and exception like this would appear. The log says 866 Cursors are opened and memory allocation of 2MB is failed.