| 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, | 54 size_t numberOfFrames, |
| 55 const AudioIOPosition& outputPosition) final; | 55 const AudioIOPosition& outputPosition) final; |
| 56 | 56 |
| 57 size_t currentSampleFrame() const { | 57 size_t currentSampleFrame() const { |
| 58 return acquireLoad(&m_currentSampleFrame); | 58 return acquireLoad(&m_currentSampleFrame); |
| 59 } | 59 } |
| 60 double currentTime() const { | 60 double currentTime() const { |
| 61 return currentSampleFrame() / static_cast<double>(sampleRate()); | 61 return currentSampleFrame() / static_cast<double>(sampleRate()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual unsigned long maxChannelCount() const { return 0; } | 64 virtual unsigned long maxChannelCount() const { return 0; } |
| 65 | 65 |
| 66 virtual void startRendering() = 0; | 66 virtual void startRendering() = 0; |
| 67 virtual void stopRendering() = 0; | 67 virtual void stopRendering() = 0; |
| 68 | 68 |
| 69 // Returns the rendering callback buffer size. | 69 // Returns the rendering callback buffer size. |
| 70 virtual size_t callbackBufferSize() const = 0; | 70 virtual size_t callbackBufferSize() const = 0; |
| 71 virtual double sampleRate() const = 0; |
| 72 |
| 73 // Returns the audio buffer size in frames used by the AudioContext. |
| 74 virtual int framesPerBuffer() const = 0; |
| 71 | 75 |
| 72 protected: | 76 protected: |
| 73 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for | 77 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for |
| 74 // local/live audio input. If there is local/live audio input, we call set() | 78 // local/live audio input. If there is local/live audio input, we call set() |
| 75 // with the audio input data every render quantum. | 79 // with the audio input data every render quantum. |
| 76 class LocalAudioInputProvider final : public AudioSourceProvider { | 80 class LocalAudioInputProvider final : public AudioSourceProvider { |
| 77 public: | 81 public: |
| 78 LocalAudioInputProvider() | 82 LocalAudioInputProvider() |
| 79 : m_sourceBus(AudioBus::create( | 83 : m_sourceBus(AudioBus::create( |
| 80 2, | 84 2, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 unsigned long maxChannelCount() const; | 121 unsigned long maxChannelCount() const; |
| 118 size_t callbackBufferSize() const { return handler().callbackBufferSize(); } | 122 size_t callbackBufferSize() const { return handler().callbackBufferSize(); } |
| 119 | 123 |
| 120 protected: | 124 protected: |
| 121 AudioDestinationNode(BaseAudioContext&); | 125 AudioDestinationNode(BaseAudioContext&); |
| 122 }; | 126 }; |
| 123 | 127 |
| 124 } // namespace blink | 128 } // namespace blink |
| 125 | 129 |
| 126 #endif // AudioDestinationNode_h | 130 #endif // AudioDestinationNode_h |
| OLD | NEW |