| 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; |
| 54 | 63 |
| 55 private: | 64 private: |
| 56 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget); | 65 OfflineAudioDestinationHandler(AudioNode&, AudioBuffer* renderTarget); |
| 57 void offlineRender(); | 66 |
| 58 void offlineRenderInternal(); | 67 // For start/suspend/resume rendering in the destination node. |
| 68 void startOfflineRendering(); |
| 69 void runOfflineRendering(); |
| 70 void finishOfflineRendering(); |
| 59 | 71 |
| 60 // For completion callback on main thread. | 72 // For completion callback on main thread. |
| 61 void notifyComplete(); | 73 void notifyComplete(); |
| 62 | 74 |
| 63 // This AudioHandler renders into this AudioBuffer. | 75 // This AudioHandler renders into this AudioBuffer. |
| 64 // This Persistent doesn't make a reference cycle including the owner | 76 // This Persistent doesn't make a reference cycle including the owner |
| 65 // OfflineAudioDestinationNode. | 77 // OfflineAudioDestinationNode. |
| 66 Persistent<AudioBuffer> m_renderTarget; | 78 Persistent<AudioBuffer> m_renderTarget; |
| 67 // Temporary AudioBus for each render quantum. | 79 // Temporary AudioBus for each render quantum. |
| 68 RefPtr<AudioBus> m_renderBus; | 80 RefPtr<AudioBus> m_renderBus; |
| 69 | 81 |
| 70 // Rendering thread. | 82 // Rendering thread. |
| 71 OwnPtr<WebThread> m_renderThread; | 83 OwnPtr<WebThread> m_renderThread; |
| 72 bool m_startedRendering; | 84 |
| 85 size_t m_framesProcessed; |
| 86 size_t m_framesToProcess; |
| 73 }; | 87 }; |
| 74 | 88 |
| 75 class OfflineAudioDestinationNode final : public AudioDestinationNode { | 89 class OfflineAudioDestinationNode final : public AudioDestinationNode { |
| 76 public: | 90 public: |
| 77 static OfflineAudioDestinationNode* create(AudioContext*, AudioBuffer* rende
rTarget); | 91 static OfflineAudioDestinationNode* create(AudioContext*, AudioBuffer* rende
rTarget); |
| 78 | 92 |
| 79 private: | 93 private: |
| 80 OfflineAudioDestinationNode(AudioContext&, AudioBuffer* renderTarget); | 94 OfflineAudioDestinationNode(AudioContext&, AudioBuffer* renderTarget); |
| 81 }; | 95 }; |
| 82 | 96 |
| 83 } // namespace blink | 97 } // namespace blink |
| 84 | 98 |
| 85 #endif // OfflineAudioDestinationNode_h | 99 #endif // OfflineAudioDestinationNode_h |
| OLD | NEW |