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