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/AudioSourceProvider.h" | 32 #include "platform/audio/AudioSourceProvider.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class AudioBus; | 36 class AudioBus; |
37 class AudioContext; | 37 class AudioContext; |
38 | 38 |
39 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { | 39 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { |
40 public: | 40 public: |
41 AudioDestinationHandler(AudioNode&, float sampleRate); | 41 AudioDestinationHandler(AudioNode&, float sampleRate); |
42 virtual ~AudioDestinationHandler(); | 42 ~AudioDestinationHandler() override; |
43 | 43 |
44 // AudioHandler | 44 // AudioHandler |
45 virtual void process(size_t) override final { } // we're pulled by hardware
so this is never called | 45 void process(size_t) final { } // we're pulled by hardware so this is never
called |
46 | 46 |
47 // The audio hardware calls render() to get the next render quantum of audio
into destinationBus. | 47 // The audio hardware calls render() to get the next render quantum of audio
into destinationBus. |
48 // It will optionally give us local/live audio input in sourceBus (if it's n
ot 0). | 48 // It will optionally give us local/live audio input in sourceBus (if it's n
ot 0). |
49 virtual void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t nu
mberOfFrames) override final; | 49 void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFr
ames) final; |
50 | 50 |
51 size_t currentSampleFrame() const { return acquireLoad(&m_currentSampleFrame
); } | 51 size_t currentSampleFrame() const { return acquireLoad(&m_currentSampleFrame
); } |
52 double currentTime() const { return currentSampleFrame() / static_cast<doubl
e>(sampleRate()); } | 52 double currentTime() const { return currentSampleFrame() / static_cast<doubl
e>(sampleRate()); } |
53 | 53 |
54 virtual unsigned long maxChannelCount() const { return 0; } | 54 virtual unsigned long maxChannelCount() const { return 0; } |
55 | 55 |
56 virtual void startRendering() = 0; | 56 virtual void startRendering() = 0; |
57 virtual void stopRendering() = 0; | 57 virtual void stopRendering() = 0; |
58 | 58 |
59 protected: | 59 protected: |
60 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for lo
cal/live audio input. | 60 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for lo
cal/live audio input. |
61 // If there is local/live audio input, we call set() with the audio input da
ta every render quantum. | 61 // If there is local/live audio input, we call set() with the audio input da
ta every render quantum. |
62 class LocalAudioInputProvider final : public AudioSourceProvider { | 62 class LocalAudioInputProvider final : public AudioSourceProvider { |
63 public: | 63 public: |
64 LocalAudioInputProvider() | 64 LocalAudioInputProvider() |
65 : m_sourceBus(AudioBus::create(2, ProcessingSizeInFrames)) // FIXME:
handle non-stereo local input. | 65 : m_sourceBus(AudioBus::create(2, ProcessingSizeInFrames)) // FIXME:
handle non-stereo local input. |
66 { | 66 { |
67 } | 67 } |
68 | 68 |
69 void set(AudioBus* bus) | 69 void set(AudioBus* bus) |
70 { | 70 { |
71 if (bus) | 71 if (bus) |
72 m_sourceBus->copyFrom(*bus); | 72 m_sourceBus->copyFrom(*bus); |
73 } | 73 } |
74 | 74 |
75 // AudioSourceProvider. | 75 // AudioSourceProvider. |
76 virtual void provideInput(AudioBus* destinationBus, size_t numberOfFrame
s) override | 76 void provideInput(AudioBus* destinationBus, size_t numberOfFrames) overr
ide |
77 { | 77 { |
78 bool isGood = destinationBus && destinationBus->length() == numberOf
Frames && m_sourceBus->length() == numberOfFrames; | 78 bool isGood = destinationBus && destinationBus->length() == numberOf
Frames && m_sourceBus->length() == numberOfFrames; |
79 ASSERT(isGood); | 79 ASSERT(isGood); |
80 if (isGood) | 80 if (isGood) |
81 destinationBus->copyFrom(*m_sourceBus); | 81 destinationBus->copyFrom(*m_sourceBus); |
82 } | 82 } |
83 | 83 |
84 private: | 84 private: |
85 RefPtr<AudioBus> m_sourceBus; | 85 RefPtr<AudioBus> m_sourceBus; |
86 }; | 86 }; |
(...skipping 11 matching lines...) Expand all Loading... |
98 | 98 |
99 unsigned long maxChannelCount() const; | 99 unsigned long maxChannelCount() const; |
100 | 100 |
101 protected: | 101 protected: |
102 AudioDestinationNode(AudioContext&); | 102 AudioDestinationNode(AudioContext&); |
103 }; | 103 }; |
104 | 104 |
105 } // namespace blink | 105 } // namespace blink |
106 | 106 |
107 #endif // AudioDestinationNode_h | 107 #endif // AudioDestinationNode_h |
OLD | NEW |