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

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

Issue 773273002: Update the current frame count in a safe place (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioContext.h
diff --git a/Source/modules/webaudio/AudioContext.h b/Source/modules/webaudio/AudioContext.h
index 4ce5c232b9851c55acb611b78d09b0acacea1e68..4c6facfedaa22255740098bc5cfad724228c0030 100644
--- a/Source/modules/webaudio/AudioContext.h
+++ b/Source/modules/webaudio/AudioContext.h
@@ -106,7 +106,12 @@ public:
virtual bool hasPendingActivity() const override;
AudioDestinationNode* destination() { return m_destinationNode.get(); }
+ // currentSampleFrame() returns the current sample frame. It should only be called from the
+ // audio thread.
size_t currentSampleFrame() const { return m_destinationNode->currentSampleFrame(); }
+ // sampleFrame() is like currentSampleFrame() but must be called from the main thread to get the
+ // sample frame. It might be slightly behind curentSampleFrame() due to locking.
+ size_t sampleFrame() const;
hongchan 2014/12/03 18:50:47 Just a thought - can't this be shadowCurrentSample
Raymond Toy 2014/12/03 19:04:44 I'm terrible at names. m_shadowCurrentSampleFrame
hongchan 2014/12/03 19:13:29 I agree that it is too much. How about using the
Raymond Toy 2014/12/03 19:34:21 Sounds good.
double currentTime() const { return m_destinationNode->currentTime(); }
float sampleRate() const { return m_destinationNode->sampleRate(); }
String state() const;
@@ -396,6 +401,9 @@ private:
GC_PLUGIN_IGNORE("http://crbug.com/404527")
HashSet<AudioNode*> m_deferredCountModeChange;
+ // Follows the destinations currentSampleFrame, but might be slightly behind due to locking.
+ size_t m_shadowCurrentSampleFrame;
+
// This is considering 32 is large enough for multiple channels audio.
// It is somewhat arbitrary and could be increased if necessary.
enum { MaxNumberOfChannels = 32 };
« no previous file with comments | « no previous file | Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698