alsa_sound: Fix for unhandled NULL pointer

-Passing NULL pointer to pcm_read()/pcm_write()/
 pcm_prepare() would crash, since it doesnt perform
 a NULL check before using the pointer, resulting
 in random crash
-Fix is to check whether handle is NULL or not.

Change-Id: I7061d40bddcaaae2145f5fc0a0229abeebead878
CRs-fixed: 549257
audio: fix for unhandled NULL pointer in HAL

- Check if handle is NULL before calling pcm_close
- Check if usecase is NULL before string comparison
  operations
- Disable unnecessary debug logs in HAL

Change-Id: I569cbf510c820e1a155abf3efb4bbb525e68aafb
alsa_sound: Fix a memory leak

A pointer variable was not being freed up which is
causing memory leak.
This change is to fix the same.

Change-Id: I12728a4a75fb303d34d10657fe9cbc1b55c1687e
CRs-Fixed: 523572
Merge "audio: fix for unhandled NULL pointer in HAL"
Merge "alsa_sound: Fix for unhandled NULL pointer"
Merge "Merge "alsa_sound: Fix for unhandled NULL pointer""
Merge "Merge "Merge "alsa_sound: Fix for unhandled NULL pointer"""
audio: Choose Speaker instead of USB Headset on force use

- getNewDevice() is selecting USB Dock Headset when user
  forces it to be speaker during VOIP/VOICE call
- Fix is to return speaker as output device in this case
CRs-Fixed: 571801

Change-Id: I81cbcef17ac6d07ac0a174e4ab35c8f5c6426257
Merge "Merge "alsa_sound: Fix for unhandled NULL pointer""
Merge "Merge "Merge "alsa_sound: Fix for unhandled NULL pointer"""
audio: avoid muting already muted stream

-Issue: FM or music is getting mixed with ringtone over the
 speaker when BT or wired HS is connected. Because the stream will
 not get temporarily muted if its already muted.But during unmute,
 there is no condition to check whether stream is temporarily muted
 or not.This is leading to unmuting of non-muted stream
-Fix is added to avoid muting of stream if its already
 muted

CRs-Fixed: 574271
Change-Id: I6b4962f402b87781846e37aed1872a639d06f488
Merge "audio: Choose Speaker instead of USB Headset on force use"
Merge "audio: avoid muting already muted stream"
Merge "alsa_sound: Fix a memory leak"
Merge "Merge "alsa_sound: Fix a memory leak""
Merge "Merge "Merge "alsa_sound: Fix a memory leak"""
Merge remote-tracking branch 'ca/kk_2.7.1' into kk-4.4

Conflicts:
	legacy/alsa_sound/AudioSessionOut.cpp