Switch audio synchronization from sleep() based to select() based.

Uses select() to efficiently wait for data from the renderer with a
timeout instead of using sleep() or always assuming the renderer
is ready.

Fixes glitching and / or CPU hogging when the renderer isn't ready.

BUG=179058, 180841, 260772, 269672, 
TEST=Swap from 44kHz to 16kHz html5 playback, ensure glitch free.

Review URL: https://codereview.chromium.org/22886005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230515 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ppapi/proxy/audio_input_resource.cc b/ppapi/proxy/audio_input_resource.cc
index 4a7afff..7c29df5 100644
--- a/ppapi/proxy/audio_input_resource.cc
+++ b/ppapi/proxy/audio_input_resource.cc
@@ -8,7 +8,6 @@
 #include "base/logging.h"
 #include "ipc/ipc_platform_file.h"
 #include "media/audio/audio_parameters.h"
-#include "media/audio/shared_memory_util.h"
 #include "ppapi/c/pp_errors.h"
 #include "ppapi/proxy/ppapi_messages.h"
 #include "ppapi/proxy/resource_message_params.h"
@@ -168,15 +167,9 @@
         params.TakeHandleOfTypeAtIndex(1, SerializedHandle::SHARED_MEMORY);
     CHECK(serialized_shared_memory_handle.IsHandleValid());
 
-    // See the comment in pepper_audio_input_host.cc about how we must call
-    // TotalSharedMemorySizeInBytes to get the actual size of the buffer. Here,
-    // we must call PacketSizeInBytes to get back the size of the audio buffer,
-    // excluding the bytes that audio uses for book-keeping.
-    size_t shared_memory_size = media::PacketSizeInBytes(
-        serialized_shared_memory_handle.size());
-
     open_state_ = OPENED;
-    SetStreamInfo(serialized_shared_memory_handle.shmem(), shared_memory_size,
+    SetStreamInfo(serialized_shared_memory_handle.shmem(),
+                  serialized_shared_memory_handle.size(),
                   socket_handle);
   } else {
     capturing_ = false;