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

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

Issue 2699403002: Simplify MediaStreamAudioSourceNode ownerships. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 25 matching lines...) Expand all
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class BaseAudioContext; 39 class BaseAudioContext;
40 class MediaStreamAudioSourceOptions; 40 class MediaStreamAudioSourceOptions;
41 41
42 class MediaStreamAudioSourceHandler final : public AudioHandler { 42 class MediaStreamAudioSourceHandler final : public AudioHandler {
43 public: 43 public:
44 static PassRefPtr<MediaStreamAudioSourceHandler> create( 44 static PassRefPtr<MediaStreamAudioSourceHandler> create(
45 AudioNode&, 45 AudioNode&,
46 MediaStream&,
47 MediaStreamTrack*,
48 std::unique_ptr<AudioSourceProvider>); 46 std::unique_ptr<AudioSourceProvider>);
49 ~MediaStreamAudioSourceHandler() override; 47 ~MediaStreamAudioSourceHandler() override;
50 48
51 MediaStream* getMediaStream() { return m_mediaStream.get(); }
52
53 // AudioHandler 49 // AudioHandler
54 void process(size_t framesToProcess) override; 50 void process(size_t framesToProcess) override;
55 51
56 // A helper for AudioSourceProviderClient implementation of 52 // A helper for AudioSourceProviderClient implementation of
57 // MediaStreamAudioSourceNode. 53 // MediaStreamAudioSourceNode.
58 void setFormat(size_t numberOfChannels, float sampleRate); 54 void setFormat(size_t numberOfChannels, float sampleRate);
59 55
56 private:
57 MediaStreamAudioSourceHandler(AudioNode&,
58 std::unique_ptr<AudioSourceProvider>);
59
60 // As an audio source, we will never propagate silence.
61 bool propagatesSilence() const override { return false; }
62
60 AudioSourceProvider* getAudioSourceProvider() const { 63 AudioSourceProvider* getAudioSourceProvider() const {
61 return m_audioSourceProvider.get(); 64 return m_audioSourceProvider.get();
62 } 65 }
63 66
64 private:
65 MediaStreamAudioSourceHandler(AudioNode&,
66 MediaStream&,
67 MediaStreamTrack*,
68 std::unique_ptr<AudioSourceProvider>);
69 // As an audio source, we will never propagate silence.
70 bool propagatesSilence() const override { return false; }
71
72 // These Persistents don't make reference cycles including the owner
73 // MediaStreamAudioSourceNode.
74 Persistent<MediaStream> m_mediaStream;
75 Persistent<MediaStreamTrack> m_audioTrack;
76 std::unique_ptr<AudioSourceProvider> m_audioSourceProvider; 67 std::unique_ptr<AudioSourceProvider> m_audioSourceProvider;
77 68
78 Mutex m_processLock; 69 Mutex m_processLock;
79 70
80 unsigned m_sourceNumberOfChannels; 71 unsigned m_sourceNumberOfChannels;
81 }; 72 };
82 73
83 class MediaStreamAudioSourceNode final : public AudioNode, 74 class MediaStreamAudioSourceNode final : public AudioNode,
84 public AudioSourceProviderClient { 75 public AudioSourceProviderClient {
85 DEFINE_WRAPPERTYPEINFO(); 76 DEFINE_WRAPPERTYPEINFO();
86 USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode); 77 USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode);
87 78
88 public: 79 public:
89 static MediaStreamAudioSourceNode* create(BaseAudioContext&, 80 static MediaStreamAudioSourceNode* create(BaseAudioContext&,
90 MediaStream&, 81 MediaStream&,
91 ExceptionState&); 82 ExceptionState&);
92 static MediaStreamAudioSourceNode* create( 83 static MediaStreamAudioSourceNode* create(
93 BaseAudioContext*, 84 BaseAudioContext*,
94 const MediaStreamAudioSourceOptions&, 85 const MediaStreamAudioSourceOptions&,
95 ExceptionState&); 86 ExceptionState&);
96 87
97 DECLARE_VIRTUAL_TRACE(); 88 DECLARE_VIRTUAL_TRACE();
98 MediaStreamAudioSourceHandler& mediaStreamAudioSourceHandler() const;
99 89
100 MediaStream* getMediaStream() const; 90 MediaStream* getMediaStream() const;
101 91
102 // AudioSourceProviderClient functions: 92 // AudioSourceProviderClient functions:
103 void setFormat(size_t numberOfChannels, float sampleRate) override; 93 void setFormat(size_t numberOfChannels, float sampleRate) override;
104 94
105 private: 95 private:
106 MediaStreamAudioSourceNode(BaseAudioContext&, 96 MediaStreamAudioSourceNode(BaseAudioContext&,
107 MediaStream&, 97 MediaStream&,
108 MediaStreamTrack*, 98 MediaStreamTrack*,
109 std::unique_ptr<AudioSourceProvider>); 99 std::unique_ptr<AudioSourceProvider>);
100
101 MediaStreamAudioSourceHandler& mediaStreamAudioSourceHandler() const;
102
103 Member<MediaStreamTrack> m_audioTrack;
104 Member<MediaStream> m_mediaStream;
110 }; 105 };
111 106
112 } // namespace blink 107 } // namespace blink
113 108
114 #endif // MediaStreamAudioSourceNode_h 109 #endif // MediaStreamAudioSourceNode_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698