audiopolicy: Use C++11 atomics, factor out handle generation

Update the code to use C++11 atomics. Make sure that
unsigned ints are used as id counters (signed ints have undefined
overflow behavior). Factor out common code from AudioPatch
and AudioPort.

Test: compiles
Change-Id: Ic359e97795a6282a2937d88bead8a1de27c8db7a
7 files changed