Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioDestinationNode.h

Issue 2060833002: Implementation of 'AudioContext.getOutputTimestamp' method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementation of 'AudioContext.getOutputTimestamp' method Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 */ 23 */
24 24
25 #ifndef AudioDestinationNode_h 25 #ifndef AudioDestinationNode_h
26 #define AudioDestinationNode_h 26 #define AudioDestinationNode_h
27 27
28 #include "modules/webaudio/AudioBuffer.h" 28 #include "modules/webaudio/AudioBuffer.h"
29 #include "modules/webaudio/AudioNode.h" 29 #include "modules/webaudio/AudioNode.h"
30 #include "platform/audio/AudioBus.h" 30 #include "platform/audio/AudioBus.h"
31 #include "platform/audio/AudioIOCallback.h" 31 #include "platform/audio/AudioIOCallback.h"
32 #include "platform/audio/AudioSourceProvider.h" 32 #include "platform/audio/AudioSourceProvider.h"
33 #include "wtf/ThreadingPrimitives.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
36 class AudioBus; 37 class AudioBus;
37 class AbstractAudioContext; 38 class AbstractAudioContext;
39 class AudioTimestamp;
38 40
39 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback { 41 class AudioDestinationHandler : public AudioHandler, public AudioIOCallback {
40 public: 42 public:
41 AudioDestinationHandler(AudioNode&, float sampleRate); 43 AudioDestinationHandler(AudioNode&, float sampleRate);
42 ~AudioDestinationHandler() override; 44 ~AudioDestinationHandler() override;
43 45
44 // AudioHandler 46 // AudioHandler
45 void process(size_t) final { } // we're pulled by hardware so this is never called 47 void process(size_t) final { } // we're pulled by hardware so this is never called
46 48
47 // The audio hardware calls render() to get the next render quantum of audio into destinationBus. 49 // 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). 50 // It will optionally give us local/live audio input in sourceBus (if it's n ot 0).
49 void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFr ames) final; 51 void render(AudioBus* sourceBus, AudioBus* destinationBus, size_t numberOfFr ames, const WebAudioTimestamp& outputTimestamp) final;
50 52
51 size_t currentSampleFrame() const { return acquireLoad(&m_currentSampleFrame ); } 53 size_t currentSampleFrame() const { return acquireLoad(&m_currentSampleFrame ); }
52 double currentTime() const { return currentSampleFrame() / static_cast<doubl e>(sampleRate()); } 54 double currentTime() const { return currentSampleFrame() / static_cast<doubl e>(sampleRate()); }
53 55
54 virtual unsigned long maxChannelCount() const { return 0; } 56 virtual unsigned long maxChannelCount() const { return 0; }
55 57
56 virtual void startRendering() = 0; 58 virtual void startRendering() = 0;
57 virtual void stopRendering() = 0; 59 virtual void stopRendering() = 0;
58 60
61 WebAudioTimestamp outputTimestamp() const;
62
59 protected: 63 protected:
60 // LocalAudioInputProvider allows us to expose an AudioSourceProvider for lo cal/live audio input. 64 // 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. 65 // 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 { 66 class LocalAudioInputProvider final : public AudioSourceProvider {
63 public: 67 public:
64 LocalAudioInputProvider() 68 LocalAudioInputProvider()
65 : m_sourceBus(AudioBus::create(2, ProcessingSizeInFrames)) // FIXME: handle non-stereo local input. 69 : m_sourceBus(AudioBus::create(2, ProcessingSizeInFrames)) // FIXME: handle non-stereo local input.
66 { 70 {
67 } 71 }
68 72
(...skipping 12 matching lines...) Expand all
81 destinationBus->copyFrom(*m_sourceBus); 85 destinationBus->copyFrom(*m_sourceBus);
82 } 86 }
83 87
84 private: 88 private:
85 RefPtr<AudioBus> m_sourceBus; 89 RefPtr<AudioBus> m_sourceBus;
86 }; 90 };
87 91
88 // Counts the number of sample-frames processed by the destination. 92 // Counts the number of sample-frames processed by the destination.
89 size_t m_currentSampleFrame; 93 size_t m_currentSampleFrame;
90 94
95 // FIXME(Mikhail) : when allowed use std::atomic<WebAudioTimestamp> instead of mutex.
hongchan 2016/06/14 17:10:38 FIXME -> TODO.
Mikhail 2016/06/17 09:36:57 I've changed the approach so that it is using 'loc
96 WebAudioTimestamp m_outputTimestamp;
97 mutable Mutex m_mutex;
98
91 LocalAudioInputProvider m_localAudioInputProvider; 99 LocalAudioInputProvider m_localAudioInputProvider;
92 }; 100 };
93 101
94 class AudioDestinationNode : public AudioNode { 102 class AudioDestinationNode : public AudioNode {
95 DEFINE_WRAPPERTYPEINFO(); 103 DEFINE_WRAPPERTYPEINFO();
96 public: 104 public:
97 AudioDestinationHandler& audioDestinationHandler() const; 105 AudioDestinationHandler& audioDestinationHandler() const;
98 106
99 unsigned long maxChannelCount() const; 107 unsigned long maxChannelCount() const;
100 108
101 protected: 109 protected:
102 AudioDestinationNode(AbstractAudioContext&); 110 AudioDestinationNode(AbstractAudioContext&);
103 }; 111 };
104 112
105 } // namespace blink 113 } // namespace blink
106 114
107 #endif // AudioDestinationNode_h 115 #endif // AudioDestinationNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698