DO NOT MERGE: Ignore pause key released state only if pressed is ignored.

Scenario: Music is playing, incoming call - headset sends pause (pressed).
That gets processed but pause release is not and then the headset
and music player get into a weird state.

Bug id: 3143711
Change-Id: I12d70f1380e121c0802c18100776ef498274c2a8
diff --git a/audio/control.c b/audio/control.c
index 617b7c7..b821cd1 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -182,6 +182,8 @@
 	gboolean target;
 
 	uint8_t key_quirks[256];
+
+	gboolean ignore_pause;
 };
 
 static struct {
@@ -376,8 +378,18 @@
 #ifdef ANDROID
 	if ((operands[0] & 0x7F) == PAUSE_OP) {
 		if (!sink_is_streaming(control->dev)) {
-			DBG("AVRCP: Ignoring Pause key");
-			return;
+			if (pressed) {
+				uint8_t key_quirks =
+					control->key_quirks[PAUSE_OP];
+				DBG("AVRCP: Ignoring Pause key - pressed");
+				if (!(key_quirks & QUIRK_NO_RELEASE))
+					control->ignore_pause = TRUE;
+				return;
+			} else if (!pressed && control->ignore_pause) {
+				DBG("AVRCP: Ignoring Pause key - released");
+				control->ignore_pause = FALSE;
+				return;
+			}
 		}
 	}
 #endif
@@ -667,6 +679,7 @@
 		control->key_quirks[PLAY_OP] |= QUIRK_NO_RELEASE;
 		control->key_quirks[PAUSE_OP] |= QUIRK_NO_RELEASE;
 	}
+	control->ignore_pause = FALSE;
 
 	ba2str(&dev->dst, address);