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 26 matching lines...) Expand all Loading... |
37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class AudioFIFO; | 42 class AudioFIFO; |
43 class AudioPullFIFO; | 43 class AudioPullFIFO; |
44 | 44 |
45 // An AudioDestination using Chromium's audio system | 45 // An AudioDestination using Chromium's audio system |
46 | 46 |
47 class PLATFORM_EXPORT AudioDestination : public blink::WebAudioDevice::RenderCal
lback, public AudioSourceProvider { | 47 class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback,
public AudioSourceProvider { |
48 WTF_MAKE_NONCOPYABLE(AudioDestination); | 48 WTF_MAKE_NONCOPYABLE(AudioDestination); |
49 public: | 49 public: |
50 AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned num
berOfInputChannels, unsigned numberOfOutputChannels, float sampleRate); | 50 AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned num
berOfInputChannels, unsigned numberOfOutputChannels, float sampleRate); |
51 virtual ~AudioDestination(); | 51 virtual ~AudioDestination(); |
52 | 52 |
53 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. | 53 // Pass in (numberOfInputChannels > 0) if live/local audio input is desired. |
54 // Port-specific device identification information for live/local input stre
ams can be passed in the inputDeviceId. | 54 // Port-specific device identification information for live/local input stre
ams can be passed in the inputDeviceId. |
55 static PassOwnPtr<AudioDestination> create(AudioIOCallback&, const String& i
nputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, f
loat sampleRate); | 55 static PassOwnPtr<AudioDestination> create(AudioIOCallback&, const String& i
nputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, f
loat sampleRate); |
56 | 56 |
57 virtual void start(); | 57 virtual void start(); |
58 virtual void stop(); | 58 virtual void stop(); |
59 bool isPlaying() { return m_isPlaying; } | 59 bool isPlaying() { return m_isPlaying; } |
60 | 60 |
61 float sampleRate() const { return m_sampleRate; } | 61 float sampleRate() const { return m_sampleRate; } |
62 | 62 |
63 // blink::WebAudioDevice::RenderCallback | 63 // WebAudioDevice::RenderCallback |
64 virtual void render(const blink::WebVector<float*>& sourceData, const blink:
:WebVector<float*>& audioData, size_t numberOfFrames) OVERRIDE; | 64 virtual void render(const WebVector<float*>& sourceData, const WebVector<flo
at*>& audioData, size_t numberOfFrames) OVERRIDE; |
65 | 65 |
66 // blink::AudioSourceProvider | 66 // AudioSourceProvider |
67 virtual void provideInput(AudioBus*, size_t framesToProcess) OVERRIDE; | 67 virtual void provideInput(AudioBus*, size_t framesToProcess) OVERRIDE; |
68 | 68 |
69 static float hardwareSampleRate(); | 69 static float hardwareSampleRate(); |
70 | 70 |
71 // maxChannelCount() returns the total number of output channels of the audi
o hardware. | 71 // maxChannelCount() returns the total number of output channels of the audi
o hardware. |
72 // A value of 0 indicates that the number of channels cannot be configured a
nd | 72 // A value of 0 indicates that the number of channels cannot be configured a
nd |
73 // that only stereo (2-channel) destinations can be created. | 73 // that only stereo (2-channel) destinations can be created. |
74 // The numberOfOutputChannels parameter of AudioDestination::create() is all
owed to | 74 // The numberOfOutputChannels parameter of AudioDestination::create() is all
owed to |
75 // be a value: 1 <= numberOfOutputChannels <= maxChannelCount(), | 75 // be a value: 1 <= numberOfOutputChannels <= maxChannelCount(), |
76 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. | 76 // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2. |
77 static unsigned long maxChannelCount(); | 77 static unsigned long maxChannelCount(); |
78 | 78 |
79 private: | 79 private: |
80 AudioIOCallback& m_callback; | 80 AudioIOCallback& m_callback; |
81 unsigned m_numberOfOutputChannels; | 81 unsigned m_numberOfOutputChannels; |
82 RefPtr<AudioBus> m_inputBus; | 82 RefPtr<AudioBus> m_inputBus; |
83 RefPtr<AudioBus> m_renderBus; | 83 RefPtr<AudioBus> m_renderBus; |
84 float m_sampleRate; | 84 float m_sampleRate; |
85 bool m_isPlaying; | 85 bool m_isPlaying; |
86 OwnPtr<blink::WebAudioDevice> m_audioDevice; | 86 OwnPtr<WebAudioDevice> m_audioDevice; |
87 size_t m_callbackBufferSize; | 87 size_t m_callbackBufferSize; |
88 | 88 |
89 OwnPtr<AudioFIFO> m_inputFifo; | 89 OwnPtr<AudioFIFO> m_inputFifo; |
90 OwnPtr<AudioPullFIFO> m_fifo; | 90 OwnPtr<AudioPullFIFO> m_fifo; |
91 }; | 91 }; |
92 | 92 |
93 } // namespace blink | 93 } // namespace blink |
94 | 94 |
95 #endif // AudioDestination_h | 95 #endif // AudioDestination_h |
OLD | NEW |