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 | |
70 // Returns the audio buffer size in frames used by the underlying audio | |
71 // hardware. | |
Raymond Toy
2016/12/08 17:14:38
This isn't the size of the underlying audio hardwa
Andrew MacPherson
2016/12/09 12:34:14
Makes sense, I've updated it now.
| |
72 virtual int framesPerBuffer() const = 0; | |
73 | |
68 protected: | 74 protected: |
69 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for | 75 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for |
70 // local/live audio input. If there is local/live audio input, we call set() | 76 // local/live audio input. If there is local/live audio input, we call set() |
71 // with the audio input data every render quantum. | 77 // with the audio input data every render quantum. |
72 class LocalAudioInputProvider final : public AudioSourceProvider { | 78 class LocalAudioInputProvider final : public AudioSourceProvider { |
73 public: | 79 public: |
74 LocalAudioInputProvider() | 80 LocalAudioInputProvider() |
75 : m_sourceBus(AudioBus::create( | 81 : m_sourceBus(AudioBus::create( |
76 2, | 82 2, |
77 AudioUtilities::kRenderQuantumFrames)) // FIXME: handle | 83 AudioUtilities::kRenderQuantumFrames)) // FIXME: handle |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 118 |
113 unsigned long maxChannelCount() const; | 119 unsigned long maxChannelCount() const; |
114 | 120 |
115 protected: | 121 protected: |
116 AudioDestinationNode(BaseAudioContext&); | 122 AudioDestinationNode(BaseAudioContext&); |
117 }; | 123 }; |
118 | 124 |
119 } // namespace blink | 125 } // namespace blink |
120 | 126 |
121 #endif // AudioDestinationNode_h | 127 #endif // AudioDestinationNode_h |
OLD | NEW |