summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_util.h
diff options
context:
space:
mode:
authorenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 21:51:27 +0000
committerenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-15 21:51:27 +0000
commit06e639cdc5cf9b7d3e97c7d7c57920b56b4b6e17 (patch)
tree048f6ff41defac63e23924bc88b16a6fb439ed4b /media/audio/audio_util.h
parentd466b8a0b44ef89c81fa4ede86de1b488b8ec07d (diff)
downloadchromium_src-06e639cdc5cf9b7d3e97c7d7c57920b56b4b6e17.zip
chromium_src-06e639cdc5cf9b7d3e97c7d7c57920b56b4b6e17.tar.gz
chromium_src-06e639cdc5cf9b7d3e97c7d7c57920b56b4b6e17.tar.bz2
Fix problem when 'ended' event was fired before stream really ended.
That caused impression that rewind does not work. With that change small JS program var a = new Audio("file:///home/enal/temp/click2/click2.wav"); var num_played = 0; a.addEventListener('canplaythrough', function() { a.play(); }); a.addEventListener('ended', function() { num_played ++; if (num_played < 10) { a.currentTime = 0; a.play(); } }); works correctly, you hear 10 clicks one after another, and it takes ~1.5 seconds to play all 10 sounds (one click is 146ms). Current Chrome plays only beginnings of the first 9 clicks and then entire 10th click -- 'ended' event fires too early, so rewind stops audio playback for all clicks but last one. With that fix you can easily create pool of audio objects -- on 'ended' event just add audio object to the pool. Fix consists of 3 parts: 1) For low-latency code path pass entire "audio state" object to the renderer process. That allows renderer take into account number of pending bytes in the buffer. 2) When using low-latency code path renderer not only fills the buffer with data, but also writes length of data into first word of the buffer. That allows host process to pass correct byte counts to renderer. 3) Renderer now keeps track of the earliest time playback can end based on the number of rendered bytes, and will not call 'ended' callback till that time. BUG=http://code.google.com/p/chromium/issues/detail?id=78992 http://codereview.chromium.org/7328030 Review URL: http://codereview.chromium.org/7328030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_util.h')
-rw-r--r--media/audio/audio_util.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h
index 15a0935..a73a613 100644
--- a/media/audio/audio_util.h
+++ b/media/audio/audio_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,10 @@
#include "base/basictypes.h"
+namespace base {
+class SharedMemory;
+}
+
namespace media {
// For all audio functions 3 audio formats are supported:
@@ -94,6 +98,16 @@ void SwizzleCoreAudioLayout5_1(Format* b, uint32 filled) {
// Returns the default audio hardware sample-rate.
double GetAudioHardwareSampleRate();
+// Functions that handle data buffer passed between processes in the shared
+// memory. Called on both IPC sides.
+
+uint32 TotalSharedMemorySizeInBytes(uint32 packet_size);
+uint32 GetMaxDataSizeInBytes(uint32 shared_memory_size);
+uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory);
+void SetActualDataSizeInBytes(base::SharedMemory* shared_memory,
+ uint32 actual_data_size);
+void* GetDataPointer(base::SharedMemory* shared_memory);
+
} // namespace media
#endif // MEDIA_AUDIO_AUDIO_UTIL_H_