NuPlayer: Prevents creation of Video Decoder when we use Music Player

- Prevents instantion of Video Decoder when we use applications like
Music Player  which do not support Video Playback
- Adds a check to prevent scanning for sources when it is either an
Audio only clip or a video only clip or an AV clip played with a
Music Player.

Change-Id: I74dd9bc53e54fd4f3682536c987289ac252690b0
Signed-off-by: Arvind Thatikonda <arvindt@codeaurora.org>
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 86e122f..bda8123 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -258,7 +258,9 @@
             ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
                  mAudioDecoder != NULL, mVideoDecoder != NULL);
 
-            instantiateDecoder(false, &mVideoDecoder);
+            if (mNativeWindow != NULL) {
+                instantiateDecoder(false, &mVideoDecoder);
+            }
 
             if (mAudioSink != NULL) {
                 instantiateDecoder(true, &mAudioDecoder);
@@ -279,7 +281,8 @@
                 break;
             }
 
-            if (mAudioDecoder == NULL || mVideoDecoder == NULL) {
+            if (mAudioDecoder == NULL && mAudioSink != NULL ||
+                mVideoDecoder == NULL && mNativeWindow != NULL) {
                 msg->post(100000ll);
                 mScanSourcesPending = true;
             }