| 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 public: | 56 public: |
| 57 AudioDestination(AudioIOCallback&, | 57 AudioDestination(AudioIOCallback&, |
| 58 const String& inputDeviceId, | 58 const String& inputDeviceId, |
| 59 unsigned numberOfInputChannels, | 59 unsigned numberOfInputChannels, |
| 60 unsigned numberOfOutputChannels, | 60 unsigned numberOfOutputChannels, |
| 61 float sampleRate, | 61 float sampleRate, |
| 62 PassRefPtr<SecurityOrigin>); | 62 PassRefPtr<SecurityOrigin>); |
| 63 ~AudioDestination() override; | 63 ~AudioDestination() override; |
| 64 | 64 |
| 65 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. | 65 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. |
| 66 // Port-specific device identification information for live/local input stream
s can be passed in the inputDeviceId. | 66 // Port-specific device identification information for live/local input |
| 67 // streams can be passed in the inputDeviceId. |
| 67 static std::unique_ptr<AudioDestination> create( | 68 static std::unique_ptr<AudioDestination> create( |
| 68 AudioIOCallback&, | 69 AudioIOCallback&, |
| 69 const String& inputDeviceId, | 70 const String& inputDeviceId, |
| 70 unsigned numberOfInputChannels, | 71 unsigned numberOfInputChannels, |
| 71 unsigned numberOfOutputChannels, | 72 unsigned numberOfOutputChannels, |
| 72 float sampleRate, | 73 float sampleRate, |
| 73 PassRefPtr<SecurityOrigin>); | 74 PassRefPtr<SecurityOrigin>); |
| 74 | 75 |
| 75 virtual void start(); | 76 virtual void start(); |
| 76 virtual void stop(); | 77 virtual void stop(); |
| 77 bool isPlaying() { return m_isPlaying; } | 78 bool isPlaying() { return m_isPlaying; } |
| 78 | 79 |
| 79 float sampleRate() const { return m_sampleRate; } | 80 float sampleRate() const { return m_sampleRate; } |
| 80 | 81 |
| 81 // WebAudioDevice::RenderCallback | 82 // WebAudioDevice::RenderCallback |
| 82 void render(const WebVector<float*>& sourceData, | 83 void render(const WebVector<float*>& sourceData, |
| 83 const WebVector<float*>& audioData, | 84 const WebVector<float*>& audioData, |
| 84 size_t numberOfFrames) override; | 85 size_t numberOfFrames) override; |
| 85 | 86 |
| 86 // AudioSourceProvider | 87 // AudioSourceProvider |
| 87 void provideInput(AudioBus*, size_t framesToProcess) override; | 88 void provideInput(AudioBus*, size_t framesToProcess) override; |
| 88 | 89 |
| 89 static float hardwareSampleRate(); | 90 static float hardwareSampleRate(); |
| 90 | 91 |
| 91 // maxChannelCount() returns the total number of output channels of the audio
hardware. | 92 // maxChannelCount() returns the total number of output channels of the audio |
| 92 // A value of 0 indicates that the number of channels cannot be configured and | 93 // hardware. A value of 0 indicates that the number of channels cannot be |
| 93 // that only stereo (2-channel) destinations can be created. | 94 // configured and that only stereo (2-channel) destinations can be created. |
| 94 // The numberOfOutputChannels parameter of AudioDestination::create() is allow
ed to | 95 // The numberOfOutputChannels parameter of AudioDestination::create() is |
| 95 // be a value: 1 <= numberOfOutputChannels <= maxChannelCount(), | 96 // allowed to be a value: 1 <= numberOfOutputChannels <= maxChannelCount(), |
| 96 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. | 97 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. |
| 97 static unsigned long maxChannelCount(); | 98 static unsigned long maxChannelCount(); |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 AudioIOCallback& m_callback; | 101 AudioIOCallback& m_callback; |
| 101 unsigned m_numberOfOutputChannels; | 102 unsigned m_numberOfOutputChannels; |
| 102 RefPtr<AudioBus> m_inputBus; | 103 RefPtr<AudioBus> m_inputBus; |
| 103 RefPtr<AudioBus> m_renderBus; | 104 RefPtr<AudioBus> m_renderBus; |
| 104 float m_sampleRate; | 105 float m_sampleRate; |
| 105 bool m_isPlaying; | 106 bool m_isPlaying; |
| 106 std::unique_ptr<WebAudioDevice> m_audioDevice; | 107 std::unique_ptr<WebAudioDevice> m_audioDevice; |
| 107 size_t m_callbackBufferSize; | 108 size_t m_callbackBufferSize; |
| 108 | 109 |
| 109 std::unique_ptr<AudioFIFO> m_inputFifo; | 110 std::unique_ptr<AudioFIFO> m_inputFifo; |
| 110 std::unique_ptr<AudioPullFIFO> m_fifo; | 111 std::unique_ptr<AudioPullFIFO> m_fifo; |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 } // namespace blink | 114 } // namespace blink |
| 114 | 115 |
| 115 #endif // AudioDestination_h | 116 #endif // AudioDestination_h |
| OLD | NEW |