audioflinger: Fix reference counting protocol in OpPlayAudioMonitor

OpPlayAudioMonitor was constructing a weak pointer to itself
in the constructor. This practice can lead to crashes due to
race conditions vs object destruction. This code is now moved
to onFirstRef method which is called when at least one strong
reference exists.

This change also reduces the number of created OpPlayAudioMonitor
objects by using a factory method.

Bug: 130038586
Test: enable / disable DND mode
Change-Id: I22e63a883ebaa25b9c96e79271bb9693b5ed75cd
2 files changed