| 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 19 matching lines...) Expand all Loading... |
| 30 #define AudioDestination_h | 30 #define AudioDestination_h |
| 31 | 31 |
| 32 #include "platform/audio/AudioBus.h" | 32 #include "platform/audio/AudioBus.h" |
| 33 #include "platform/audio/AudioIOCallback.h" | 33 #include "platform/audio/AudioIOCallback.h" |
| 34 #include "platform/audio/AudioSourceProvider.h" | 34 #include "platform/audio/AudioSourceProvider.h" |
| 35 #include "public/platform/WebAudioDevice.h" | 35 #include "public/platform/WebAudioDevice.h" |
| 36 #include "public/platform/WebVector.h" | 36 #include "public/platform/WebVector.h" |
| 37 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
| 38 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
| 39 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 40 #include <memory> | |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 class AudioFIFO; | 43 class AudioFIFO; |
| 45 class AudioPullFIFO; | 44 class AudioPullFIFO; |
| 46 class SecurityOrigin; | 45 class SecurityOrigin; |
| 47 | 46 |
| 48 // An AudioDestination using Chromium's audio system | 47 // An AudioDestination using Chromium's audio system |
| 49 | 48 |
| 50 class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback,
public AudioSourceProvider { | 49 class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback,
public AudioSourceProvider { |
| 51 USING_FAST_MALLOC(AudioDestination); | 50 USING_FAST_MALLOC(AudioDestination); |
| 52 WTF_MAKE_NONCOPYABLE(AudioDestination); | 51 WTF_MAKE_NONCOPYABLE(AudioDestination); |
| 53 public: | 52 public: |
| 54 AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned num
berOfInputChannels, unsigned numberOfOutputChannels, float sampleRate, const Pas
sRefPtr<SecurityOrigin>&); | 53 AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned num
berOfInputChannels, unsigned numberOfOutputChannels, float sampleRate, const Pas
sRefPtr<SecurityOrigin>&); |
| 55 ~AudioDestination() override; | 54 ~AudioDestination() override; |
| 56 | 55 |
| 57 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. | 56 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. |
| 58 // Port-specific device identification information for live/local input stre
ams can be passed in the inputDeviceId. | 57 // Port-specific device identification information for live/local input stre
ams can be passed in the inputDeviceId. |
| 59 static std::unique_ptr<AudioDestination> create(AudioIOCallback&, const Stri
ng& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChanne
ls, float sampleRate, const PassRefPtr<SecurityOrigin>&); | 58 static PassOwnPtr<AudioDestination> create(AudioIOCallback&, const String& i
nputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, f
loat sampleRate, const PassRefPtr<SecurityOrigin>&); |
| 60 | 59 |
| 61 virtual void start(); | 60 virtual void start(); |
| 62 virtual void stop(); | 61 virtual void stop(); |
| 63 bool isPlaying() { return m_isPlaying; } | 62 bool isPlaying() { return m_isPlaying; } |
| 64 | 63 |
| 65 float sampleRate() const { return m_sampleRate; } | 64 float sampleRate() const { return m_sampleRate; } |
| 66 | 65 |
| 67 // WebAudioDevice::RenderCallback | 66 // WebAudioDevice::RenderCallback |
| 68 void render(const WebVector<float*>& sourceData, const WebVector<float*>& au
dioData, size_t numberOfFrames) override; | 67 void render(const WebVector<float*>& sourceData, const WebVector<float*>& au
dioData, size_t numberOfFrames) override; |
| 69 | 68 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. | 79 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. |
| 81 static unsigned long maxChannelCount(); | 80 static unsigned long maxChannelCount(); |
| 82 | 81 |
| 83 private: | 82 private: |
| 84 AudioIOCallback& m_callback; | 83 AudioIOCallback& m_callback; |
| 85 unsigned m_numberOfOutputChannels; | 84 unsigned m_numberOfOutputChannels; |
| 86 RefPtr<AudioBus> m_inputBus; | 85 RefPtr<AudioBus> m_inputBus; |
| 87 RefPtr<AudioBus> m_renderBus; | 86 RefPtr<AudioBus> m_renderBus; |
| 88 float m_sampleRate; | 87 float m_sampleRate; |
| 89 bool m_isPlaying; | 88 bool m_isPlaying; |
| 90 std::unique_ptr<WebAudioDevice> m_audioDevice; | 89 OwnPtr<WebAudioDevice> m_audioDevice; |
| 91 size_t m_callbackBufferSize; | 90 size_t m_callbackBufferSize; |
| 92 | 91 |
| 93 std::unique_ptr<AudioFIFO> m_inputFifo; | 92 OwnPtr<AudioFIFO> m_inputFifo; |
| 94 std::unique_ptr<AudioPullFIFO> m_fifo; | 93 OwnPtr<AudioPullFIFO> m_fifo; |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace blink | 96 } // namespace blink |
| 98 | 97 |
| 99 #endif // AudioDestination_h | 98 #endif // AudioDestination_h |
| OLD | NEW |