OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 28 matching lines...) Expand all Loading... |
39 class OfflineAudioDestinationHandler final : public AudioDestinationHandler { | 39 class OfflineAudioDestinationHandler final : public AudioDestinationHandler { |
40 public: | 40 public: |
41 static PassRefPtr<OfflineAudioDestinationHandler> create(AudioNode&, AudioBu
ffer* renderTarget); | 41 static PassRefPtr<OfflineAudioDestinationHandler> create(AudioNode&, AudioBu
ffer* renderTarget); |
42 virtual ~OfflineAudioDestinationHandler(); | 42 virtual ~OfflineAudioDestinationHandler(); |
43 | 43 |
44 // AudioHandler | 44 // AudioHandler |
45 virtual void dispose() override; | 45 virtual void dispose() override; |
46 virtual void initialize() override; | 46 virtual void initialize() override; |
47 virtual void uninitialize() override; | 47 virtual void uninitialize() override; |
48 | 48 |
49 // AudioDestinationHandler | 49 // Override the one from AudioContext. Create a rendering thread and |
| 50 // initiate rendering loop or resume rendering if already started and |
| 51 // suspended. |
50 virtual void startRendering() override; | 52 virtual void startRendering() override; |
| 53 |
| 54 // There is no support of the explicit stopping in OfflineAudioContext. This |
| 55 // is just to match the class method signature. |
51 virtual void stopRendering() override; | 56 virtual void stopRendering() override; |
52 | 57 |
53 virtual float sampleRate() const override { return m_renderTarget->sampleRa
te(); } | 58 virtual float sampleRate() const override { return m_renderTarget->sampleRat
e(); } |
| 59 |
| 60 // Return the frame position by quantizing the time (in seconds) and |
| 61 // rounding it down to the nearest render quantum boundary. |
| 62 size_t quantizeTimeToRenderQuantum(double when) const; |
| 63 |
| 64 virtual WebThread* offlineRenderThread() override; |
54 | 65 |
55 private: | 66 private: |
56 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget); | 67 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget); |
57 void offlineRender(); | 68 |
58 void offlineRenderInternal(); | 69 // For start/suspend/resume rendering in the destination node. |
| 70 void startOfflineRendering(); |
| 71 void runOfflineRendering(); |
| 72 void finishOfflineRendering(); |
59 | 73 |
60 // For completion callback on main thread. | 74 // For completion callback on main thread. |
61 void notifyComplete(); | 75 void notifyComplete(); |
62 | 76 |
63 // This AudioHandler renders into this AudioBuffer. | 77 // This AudioHandler renders into this AudioBuffer. |
64 // This Persistent doesn't make a reference cycle including the owner | 78 // This Persistent doesn't make a reference cycle including the owner |
65 // OfflineAudioDestinationNode. | 79 // OfflineAudioDestinationNode. |
66 Persistent<AudioBuffer> m_renderTarget; | 80 Persistent<AudioBuffer> m_renderTarget; |
67 // Temporary AudioBus for each render quantum. | 81 // Temporary AudioBus for each render quantum. |
68 RefPtr<AudioBus> m_renderBus; | 82 RefPtr<AudioBus> m_renderBus; |
69 | 83 |
70 // Rendering thread. | 84 // Rendering thread. |
71 OwnPtr<WebThread> m_renderThread; | 85 OwnPtr<WebThread> m_renderThread; |
72 bool m_startedRendering; | 86 |
| 87 size_t m_framesProcessed; |
| 88 size_t m_framesToProcess; |
| 89 |
| 90 bool m_isRenderingStarted; |
73 }; | 91 }; |
74 | 92 |
75 class OfflineAudioDestinationNode final : public AudioDestinationNode { | 93 class OfflineAudioDestinationNode final : public AudioDestinationNode { |
76 public: | 94 public: |
77 static OfflineAudioDestinationNode* create(AudioContext*, AudioBuffer* rende
rTarget); | 95 static OfflineAudioDestinationNode* create(AudioContext*, AudioBuffer* rende
rTarget); |
78 | 96 |
79 private: | 97 private: |
80 OfflineAudioDestinationNode(AudioContext&, AudioBuffer* renderTarget); | 98 OfflineAudioDestinationNode(AudioContext&, AudioBuffer* renderTarget); |
81 }; | 99 }; |
82 | 100 |
83 } // namespace blink | 101 } // namespace blink |
84 | 102 |
85 #endif // OfflineAudioDestinationNode_h | 103 #endif // OfflineAudioDestinationNode_h |
OLD | NEW |