| 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 28 matching lines...) Expand all Loading... |
| 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&, float sampleRate); |
| 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 i
nto destinationBus. | 49 // The audio hardware calls render() to get the next render quantum of audio |
| 50 // It will optionally give us local/live audio input in sourceBus (if it's not
0). | 50 // into destinationBus. It will optionally give us local/live audio input in |
| 51 // sourceBus (if it's not 0). |
| 51 void render(AudioBus* sourceBus, | 52 void render(AudioBus* sourceBus, |
| 52 AudioBus* destinationBus, | 53 AudioBus* destinationBus, |
| 53 size_t numberOfFrames) final; | 54 size_t numberOfFrames) final; |
| 54 | 55 |
| 55 size_t currentSampleFrame() const { | 56 size_t currentSampleFrame() const { |
| 56 return acquireLoad(&m_currentSampleFrame); | 57 return acquireLoad(&m_currentSampleFrame); |
| 57 } | 58 } |
| 58 double currentTime() const { | 59 double currentTime() const { |
| 59 return currentSampleFrame() / static_cast<double>(sampleRate()); | 60 return currentSampleFrame() / static_cast<double>(sampleRate()); |
| 60 } | 61 } |
| 61 | 62 |
| 62 virtual unsigned long maxChannelCount() const { return 0; } | 63 virtual unsigned long maxChannelCount() const { return 0; } |
| 63 | 64 |
| 64 virtual void startRendering() = 0; | 65 virtual void startRendering() = 0; |
| 65 virtual void stopRendering() = 0; | 66 virtual void stopRendering() = 0; |
| 66 | 67 |
| 67 protected: | 68 protected: |
| 68 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for loca
l/live audio input. | 69 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for |
| 69 // If there is local/live audio input, we call set() with the audio input data
every render quantum. | 70 // local/live audio input. If there is local/live audio input, we call set() |
| 71 // with the audio input data every render quantum. |
| 70 class LocalAudioInputProvider final : public AudioSourceProvider { | 72 class LocalAudioInputProvider final : public AudioSourceProvider { |
| 71 public: | 73 public: |
| 72 LocalAudioInputProvider() | 74 LocalAudioInputProvider() |
| 73 : m_sourceBus(AudioBus::create( | 75 : m_sourceBus(AudioBus::create( |
| 74 2, | 76 2, |
| 75 ProcessingSizeInFrames)) // FIXME: handle non-stereo local input. | 77 ProcessingSizeInFrames)) // FIXME: handle non-stereo local input. |
| 76 {} | 78 {} |
| 77 | 79 |
| 78 void set(AudioBus* bus) { | 80 void set(AudioBus* bus) { |
| 79 if (bus) | 81 if (bus) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 109 | 111 |
| 110 unsigned long maxChannelCount() const; | 112 unsigned long maxChannelCount() const; |
| 111 | 113 |
| 112 protected: | 114 protected: |
| 113 AudioDestinationNode(BaseAudioContext&); | 115 AudioDestinationNode(BaseAudioContext&); |
| 114 }; | 116 }; |
| 115 | 117 |
| 116 } // namespace blink | 118 } // namespace blink |
| 117 | 119 |
| 118 #endif // AudioDestinationNode_h | 120 #endif // AudioDestinationNode_h |
| OLD | NEW |