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

Side by Side Diff: Source/modules/webaudio/AudioScheduledSourceNode.h

Issue 1256053006: Protect AudioScheduledSoureNode::m_startTime and m_endTime. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 // Called when we have no more sound to play or the stop() time has been rea ched. No onEnded 97 // Called when we have no more sound to play or the stop() time has been rea ched. No onEnded
98 // event is called. 98 // event is called.
99 virtual void finishWithoutOnEnded(); 99 virtual void finishWithoutOnEnded();
100 100
101 // Like finishWithoutOnEnded(), but an onEnded (if specified) is called. 101 // Like finishWithoutOnEnded(), but an onEnded (if specified) is called.
102 virtual void finish(); 102 virtual void finish();
103 103
104 void notifyEnded(); 104 void notifyEnded();
105 105
106 // Both |m_startTime| and |m_endTime| are accessed from both the main thread and the audio
107 // thread. Use the setters and getters to protect the access to these!
108
109 double startTime() const
110 {
111 return acquireLoad(&m_startTime);
tkent 2015/08/07 01:10:03 I'm not sure acquireLoad and releaseStore are enou
Raymond Toy 2015/08/07 15:45:00 Hmm. I perhaps erroneously assumed floating-point
tkent 2015/08/11 00:45:19 Alternative would be a normal mutex, or a spin loc
112 }
113
114 void setStartTime(double newStartTime)
115 {
116 releaseStore(&m_startTime, newStartTime);
117 }
118
119 double endTime() const
120 {
121 return acquireLoad(&m_endTime);
122 }
123
124 void setEndTime(double newEndTime)
125 {
126 releaseStore(&m_endTime, newEndTime);
127 }
128
129 bool m_hasEndedListener;
130
131 static const double UnknownTime;
132 private:
106 // m_startTime is the time to start playing based on the context's timeline (0 or a time less than the context's current time means "now"). 133 // m_startTime is the time to start playing based on the context's timeline (0 or a time less than the context's current time means "now").
107 double m_startTime; // in seconds 134 double m_startTime; // in seconds
108 135
109 // m_endTime is the time to stop playing based on the context's timeline (0 or a time less than the context's current time means "now"). 136 // m_endTime is the time to stop playing based on the context's timeline (0 or a time less than the context's current time means "now").
110 // If it hasn't been set explicitly, then the sound will not stop playing (i f looping) or will stop when the end of the AudioBuffer 137 // If it hasn't been set explicitly, then the sound will not stop playing (i f looping) or will stop when the end of the AudioBuffer
111 // has been reached. 138 // has been reached.
112 double m_endTime; // in seconds 139 double m_endTime; // in seconds
113 140
114 bool m_hasEndedListener;
115
116 static const double UnknownTime;
117 private:
118 // This is accessed by both the main thread and audio thread. Use the sette r and getter to 141 // This is accessed by both the main thread and audio thread. Use the sette r and getter to
119 // protect the access to this! 142 // protect the access to this!
120 int m_playbackState; 143 int m_playbackState;
121 }; 144 };
122 145
123 class AudioScheduledSourceNode : public AudioSourceNode { 146 class AudioScheduledSourceNode : public AudioSourceNode {
124 public: 147 public:
125 void start(ExceptionState&); 148 void start(ExceptionState&);
126 void start(double when, ExceptionState&); 149 void start(double when, ExceptionState&);
127 void stop(ExceptionState&); 150 void stop(ExceptionState&);
128 void stop(double when, ExceptionState&); 151 void stop(double when, ExceptionState&);
129 152
130 EventListener* onended(); 153 EventListener* onended();
131 void setOnended(PassRefPtrWillBeRawPtr<EventListener>); 154 void setOnended(PassRefPtrWillBeRawPtr<EventListener>);
132 155
133 protected: 156 protected:
134 explicit AudioScheduledSourceNode(AbstractAudioContext&); 157 explicit AudioScheduledSourceNode(AbstractAudioContext&);
135 AudioScheduledSourceHandler& audioScheduledSourceHandler() const; 158 AudioScheduledSourceHandler& audioScheduledSourceHandler() const;
136 }; 159 };
137 160
138 } // namespace blink 161 } // namespace blink
139 162
140 #endif // AudioScheduledSourceNode_h 163 #endif // AudioScheduledSourceNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698