HTTPStream and HTTPDataSource now support cancellation of the connection process, AwesomePlayer takes advantage of this in cases where ::reset() or ::suspend() is called while in the preparation phase to bail out early. Also fixes in issue where the audio codec was not properly stopped if no audio player object ever took ownership.

Change-Id: I6d73defe6d276693853a469db267bb2668d07af5
related-to-bugs: 2475845,2414536
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index 8468a07..284e3bc 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -101,8 +101,11 @@
     if (!strncasecmp("file://", uri, 7)) {
         source = new FileSource(uri + 7);
     } else if (!strncasecmp("http://", uri, 7)) {
-        source = new HTTPDataSource(uri, headers);
-        source = new CachingDataSource(source, 32 * 1024, 20);
+        sp<HTTPDataSource> httpSource = new HTTPDataSource(uri, headers);
+        if (httpSource->connect() != OK) {
+            return NULL;
+        }
+        source = new CachingDataSource(httpSource, 32 * 1024, 20);
     } else {
         // Assume it's a filename.
         source = new FileSource(uri);