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

Side by Side Diff: Source/platform/mediastream/MediaStreamComponent.cpp

Issue 552653005: Oilpan: Move MediaStreamSource, MediaStreamComponent and MediaStreamDescriptor to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved. 2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 22 matching lines...) Expand all
33 33
34 #include "platform/mediastream/MediaStreamComponent.h" 34 #include "platform/mediastream/MediaStreamComponent.h"
35 35
36 #include "platform/UUID.h" 36 #include "platform/UUID.h"
37 #include "platform/audio/AudioBus.h" 37 #include "platform/audio/AudioBus.h"
38 #include "platform/mediastream/MediaStreamSource.h" 38 #include "platform/mediastream/MediaStreamSource.h"
39 #include "public/platform/WebAudioSourceProvider.h" 39 #include "public/platform/WebAudioSourceProvider.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(PassRefPtr<MediaSt reamSource> source) 43 MediaStreamComponent* MediaStreamComponent::create(MediaStreamSource* source)
44 { 44 {
45 return adoptRef(new MediaStreamComponent(createCanonicalUUIDString(), source )); 45 return new MediaStreamComponent(createCanonicalUUIDString(), source);
46 } 46 }
47 47
48 PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(const String& id, PassRefPtr<MediaStreamSource> source) 48 MediaStreamComponent* MediaStreamComponent::create(const String& id, MediaStream Source* source)
49 { 49 {
50 return adoptRef(new MediaStreamComponent(id, source)); 50 return new MediaStreamComponent(id, source);
51 } 51 }
52 52
53 MediaStreamComponent::MediaStreamComponent(const String& id, PassRefPtr<MediaStr eamSource> source) 53 // The disposer pattern actually makes the deletion of the extra data happen
54 // earlier and not later. The disposer makes sure that the extra data is
55 // destructed in weak processing which is run before sweeping and therefore
56 // all the objects are still alive and can be touched.
57 //
58 // FIXME: Oilpan: This disposer pattern is duplicated in a lot of places.
59 // We should create a good abstraction class for this and remove the code duplic ation.
60 class MediaStreamComponentDisposer {
61 public:
62 explicit MediaStreamComponentDisposer(MediaStreamComponent& component) : m_c omponent(component) { }
63 ~MediaStreamComponentDisposer()
64 {
65 m_component.dispose();
66 }
67
68 private:
69 MediaStreamComponent& m_component;
70 };
71
72 typedef HeapHashMap<WeakMember<MediaStreamComponent>, OwnPtr<MediaStreamComponen tDisposer> > ComponentDisposers;
73
74 static ComponentDisposers& componentDisposers()
75 {
76 DEFINE_STATIC_LOCAL(Persistent<ComponentDisposers>, disposers, (new Componen tDisposers));
77 return *disposers;
78 }
79
80 MediaStreamComponent::MediaStreamComponent(const String& id, MediaStreamSource* source)
54 : m_source(source) 81 : m_source(source)
55 , m_id(id) 82 , m_id(id)
56 , m_enabled(true) 83 , m_enabled(true)
57 , m_muted(false) 84 , m_muted(false)
58 { 85 {
59 ASSERT(m_id.length()); 86 ASSERT(m_id.length());
87 componentDisposers().add(this, adoptPtr(new MediaStreamComponentDisposer(*th is)));
88 }
89
90 void MediaStreamComponent::dispose()
91 {
92 m_extraData = nullptr;
60 } 93 }
61 94
62 #if ENABLE(WEB_AUDIO) 95 #if ENABLE(WEB_AUDIO)
63 void MediaStreamComponent::AudioSourceProviderImpl::wrap(blink::WebAudioSourcePr ovider* provider) 96 void MediaStreamComponent::AudioSourceProviderImpl::wrap(blink::WebAudioSourcePr ovider* provider)
64 { 97 {
65 MutexLocker locker(m_provideInputLock); 98 MutexLocker locker(m_provideInputLock);
66 m_webAudioSourceProvider = provider; 99 m_webAudioSourceProvider = provider;
67 } 100 }
68 101
69 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus, size_t framesToProcess) 102 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus, size_t framesToProcess)
(...skipping 11 matching lines...) Expand all
81 // Wrap the AudioBus channel data using WebVector. 114 // Wrap the AudioBus channel data using WebVector.
82 size_t n = bus->numberOfChannels(); 115 size_t n = bus->numberOfChannels();
83 blink::WebVector<float*> webAudioData(n); 116 blink::WebVector<float*> webAudioData(n);
84 for (size_t i = 0; i < n; ++i) 117 for (size_t i = 0; i < n; ++i)
85 webAudioData[i] = bus->channel(i)->mutableData(); 118 webAudioData[i] = bus->channel(i)->mutableData();
86 119
87 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); 120 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
88 } 121 }
89 #endif // #if ENABLE(WEB_AUDIO) 122 #endif // #if ENABLE(WEB_AUDIO)
90 123
124 void MediaStreamComponent::trace(Visitor* visitor)
125 {
126 visitor->trace(m_source);
127 }
128
91 } // namespace blink 129 } // namespace blink
92 130
OLDNEW
« no previous file with comments | « Source/platform/mediastream/MediaStreamComponent.h ('k') | Source/platform/mediastream/MediaStreamDescriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698