Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 21 matching lines...) Expand all Loading... | |
| 32 #include "platform/audio/AudioIOCallback.h" | 32 #include "platform/audio/AudioIOCallback.h" |
| 33 #include "platform/audio/AudioSourceProvider.h" | 33 #include "platform/audio/AudioSourceProvider.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class AudioBus; | 37 class AudioBus; |
| 38 class BaseAudioContext; | 38 class BaseAudioContext; |
| 39 | 39 |
| 40 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { | 40 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { |
| 41 public: | 41 public: |
| 42 AudioDestinationHandler(AudioNode&, float sampleRate); | 42 AudioDestinationHandler(AudioNode&); |
| 43 ~AudioDestinationHandler() override; | 43 ~AudioDestinationHandler() override; |
| 44 | 44 |
| 45 // AudioHandler | 45 // AudioHandler |
| 46 void process(size_t) final { | 46 void process(size_t) final { |
| 47 } // we're pulled by hardware so this is never called | 47 } // we're pulled by hardware so this is never called |
| 48 | 48 |
| 49 // The audio hardware calls render() to get the next render quantum of audio | 49 // The audio hardware calls render() to get the next render quantum of audio |
| 50 // into destinationBus. It will optionally give us local/live audio input in | 50 // into destinationBus. It will optionally give us local/live audio input in |
| 51 // sourceBus (if it's not 0). | 51 // sourceBus (if it's not 0). |
| 52 void render(AudioBus* sourceBus, | 52 void render(AudioBus* sourceBus, |
| 53 AudioBus* destinationBus, | 53 AudioBus* destinationBus, |
| 54 size_t numberOfFrames) final; | 54 size_t numberOfFrames) final; |
| 55 | 55 |
| 56 size_t currentSampleFrame() const { | 56 size_t currentSampleFrame() const { |
| 57 return acquireLoad(&m_currentSampleFrame); | 57 return acquireLoad(&m_currentSampleFrame); |
| 58 } | 58 } |
| 59 double currentTime() const { | 59 double currentTime() const { |
| 60 return currentSampleFrame() / static_cast<double>(sampleRate()); | 60 return currentSampleFrame() / static_cast<double>(sampleRate()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 virtual unsigned long maxChannelCount() const { return 0; } | 63 virtual unsigned long maxChannelCount() const { return 0; } |
| 64 | 64 |
| 65 virtual void startRendering() = 0; | 65 virtual void startRendering() = 0; |
| 66 virtual void stopRendering() = 0; | 66 virtual void stopRendering() = 0; |
| 67 | 67 |
| 68 virtual double sampleRate() const = 0; | |
| 69 virtual int framesPerBuffer() const = 0; | |
|
Raymond Toy
2016/11/30 21:50:27
Please add comment on what framesPerBuffer actuall
Andrew MacPherson
2016/12/01 12:11:56
Done.
| |
| 70 | |
| 68 protected: | 71 protected: |
| 69 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for | 72 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for |
| 70 // local/live audio input. If there is local/live audio input, we call set() | 73 // local/live audio input. If there is local/live audio input, we call set() |
| 71 // with the audio input data every render quantum. | 74 // with the audio input data every render quantum. |
| 72 class LocalAudioInputProvider final : public AudioSourceProvider { | 75 class LocalAudioInputProvider final : public AudioSourceProvider { |
| 73 public: | 76 public: |
| 74 LocalAudioInputProvider() | 77 LocalAudioInputProvider() |
| 75 : m_sourceBus(AudioBus::create( | 78 : m_sourceBus(AudioBus::create( |
| 76 2, | 79 2, |
| 77 AudioUtilities::kRenderQuantumFrames)) // FIXME: handle | 80 AudioUtilities::kRenderQuantumFrames)) // FIXME: handle |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 115 |
| 113 unsigned long maxChannelCount() const; | 116 unsigned long maxChannelCount() const; |
| 114 | 117 |
| 115 protected: | 118 protected: |
| 116 AudioDestinationNode(BaseAudioContext&); | 119 AudioDestinationNode(BaseAudioContext&); |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 } // namespace blink | 122 } // namespace blink |
| 120 | 123 |
| 121 #endif // AudioDestinationNode_h | 124 #endif // AudioDestinationNode_h |
| OLD | NEW |