Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1169)

Unified Diff: Source/modules/webaudio/AudioContext.h

Issue 1149913002: Access current frame counter carefully and remove m_cachedSampleFrame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/webaudio/AudioContext.h
diff --git a/Source/modules/webaudio/AudioContext.h b/Source/modules/webaudio/AudioContext.h
index 9ea7dd20da78526b65d5dd0672f0bbab69918f50..bfb33051c35606bc57ea36da3a23eabdf796e336 100644
--- a/Source/modules/webaudio/AudioContext.h
+++ b/Source/modules/webaudio/AudioContext.h
@@ -108,12 +108,15 @@ public:
AudioDestinationNode* destination() { return m_destinationNode.get(); }
- // currentSampleFrame() and currentTime() can be called from both the main
- // thread and the audio thread. Note that, however, they return the cached
- // value instead of actual current ones when they are accessed from the main
- // thread. See: crbug.com/431874
- size_t currentSampleFrame() const;
- double currentTime() const;
+ size_t currentSampleFrame() const
+ {
+ return m_destinationNode ? m_destinationNode->audioDestinationHandler().currentSampleFrame() : 0;
Ken Russell (switch to Gerrit) 2015/05/21 20:45:16 Is it safe to access the destination node's AudioD
Raymond Toy 2015/05/21 21:19:06 I believe this is safe. The purpose of the handler
tkent 2015/05/22 00:47:12 Yes, it's ok to touch handlers from the main threa
+ }
+
+ double currentTime() const
+ {
+ return m_destinationNode ? m_destinationNode->audioDestinationHandler().currentTime() : 0;
+ }
float sampleRate() const { return m_destinationNode ? m_destinationNode->handler().sampleRate() : 0; }
@@ -311,9 +314,6 @@ private:
// The Promise that is returned by close();
RefPtrWillBeMember<ScriptPromiseResolver> m_closeResolver;
- // Follows the destination's currentSampleFrame, but might be slightly behind due to locking.
- size_t m_cachedSampleFrame;
-
// Tries to handle AudioBufferSourceNodes that were started but became disconnected or was never
// connected. Because these never get pulled anymore, they will stay around forever. So if we
// can, try to stop them so they can be collected.
« no previous file with comments | « no previous file | Source/modules/webaudio/AudioContext.cpp » ('j') | Source/modules/webaudio/AudioDestinationNode.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698