Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "modules/webaudio/AudioContext.h" | 29 #include "modules/webaudio/AudioContext.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class ExceptionState; | 33 class ExceptionState; |
| 34 | 34 |
| 35 class MODULES_EXPORT OfflineAudioContext final : public AudioContext { | 35 class MODULES_EXPORT OfflineAudioContext final : public AudioContext { |
| 36 DEFINE_WRAPPERTYPEINFO(); | 36 DEFINE_WRAPPERTYPEINFO(); |
| 37 public: | 37 public: |
| 38 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, size_t numberOfFrames, float sampleRate, ExceptionState&); | 38 static OfflineAudioContext* create(ExecutionContext*, unsigned numberOfChann els, size_t numberOfFrames, float sampleRate, ExceptionState&); |
| 39 | |
| 40 virtual ~OfflineAudioContext(); | 39 virtual ~OfflineAudioContext(); |
| 41 | 40 |
| 41 virtual bool suspendIfNecessary(); | |
| 42 bool isSuspendScheduled() const; | |
| 43 | |
| 42 ScriptPromise startOfflineRendering(ScriptState*); | 44 ScriptPromise startOfflineRendering(ScriptState*); |
| 45 ScriptPromise suspendOfflineRendering(ScriptState*, double suspendTime); | |
| 46 ScriptPromise resumeOfflineRendering(ScriptState*); | |
| 47 | |
| 43 private: | 48 private: |
| 44 OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFra mes, float sampleRate); | 49 OfflineAudioContext(Document*, unsigned numberOfChannels, size_t numberOfFra mes, float sampleRate); |
| 50 | |
| 51 // A container class for pairs of time information and suspend promise. | |
| 52 class ScheduledSuspendContainer : public NoBaseWillBeGarbageCollected<Schedu ledSuspendContainer> { | |
| 53 public: | |
| 54 static PassOwnPtr<ScheduledSuspendContainer> create(double, PassRefPtrWi llBeRawPtr<ScriptPromiseResolver>); | |
| 55 ~ScheduledSuspendContainer(); | |
| 56 PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver() { return m_reso lver; } | |
| 57 bool shouldBeSuspendedNow(double currentTime) const; | |
|
Raymond Toy
2015/05/19 22:04:45
Add comment on what this is supposed to do.
hongchan
2015/05/20 22:09:41
Done.
| |
| 58 | |
| 59 DECLARE_TRACE(); | |
| 60 | |
| 61 private: | |
| 62 ScheduledSuspendContainer(double, PassRefPtrWillBeRawPtr<ScriptPromiseRe solver>); | |
| 63 | |
| 64 double m_when; | |
| 65 RefPtrWillBeMember<ScriptPromiseResolver> m_resolver; | |
| 66 }; | |
| 67 | |
| 68 void suspendAndResolveOnMainThread(unsigned); | |
| 69 | |
| 70 // Unlike the design of real-time audio context, we keep suspend/resume | |
|
Raymond Toy
2015/05/19 22:04:45
This comment is wrong now since we're not using ju
| |
| 71 // promises in separate two vectors. This is because suspend() accompanies | |
| 72 // the timing information whereas resume() resolves when it is actually | |
| 73 // called. | |
| 74 WillBeHeapVector<OwnPtrWillBeMember<ScheduledSuspendContainer>> m_scheduledS uspends; | |
| 75 WillBeHeapVector<RefPtrWillBeMember<ScriptPromiseResolver>> m_resumeResolver s; | |
| 45 }; | 76 }; |
| 46 | 77 |
| 47 } // namespace blink | 78 } // namespace blink |
| 48 | 79 |
| 49 #endif // OfflineAudioContext_h | 80 #endif // OfflineAudioContext_h |
| OLD | NEW |