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

Side by Side Diff: Source/modules/webaudio/AudioBuffer.cpp

Issue 270103005: Tried to move AudioSummingJuction to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/modules/webaudio/AudioBuffer.idl » ('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) 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // crbug.com/344375 45 // crbug.com/344375
46 return 3000; 46 return 3000;
47 } 47 }
48 48
49 float AudioBuffer::maxAllowedSampleRate() 49 float AudioBuffer::maxAllowedSampleRate()
50 { 50 {
51 // Windows can support up to this rate. 51 // Windows can support up to this rate.
52 return 192000; 52 return 192000;
53 } 53 }
54 54
55 PassRefPtr<AudioBuffer> AudioBuffer::create(unsigned numberOfChannels, size_t nu mberOfFrames, float sampleRate) 55 PassRefPtrWillBeRawPtr<AudioBuffer> AudioBuffer::create(unsigned numberOfChannel s, size_t numberOfFrames, float sampleRate)
56 { 56 {
57 if (sampleRate < minAllowedSampleRate() || sampleRate > maxAllowedSampleRate () || numberOfChannels > AudioContext::maxNumberOfChannels() || !numberOfFrames) 57 if (sampleRate < minAllowedSampleRate() || sampleRate > maxAllowedSampleRate () || numberOfChannels > AudioContext::maxNumberOfChannels() || !numberOfFrames)
58 return nullptr; 58 return nullptr;
59 59
60 RefPtr<AudioBuffer> buffer = adoptRef(new AudioBuffer(numberOfChannels, numb erOfFrames, sampleRate)); 60 RefPtrWillBeRawPtr<AudioBuffer> buffer = adoptRefWillBeNoop(new AudioBuffer( numberOfChannels, numberOfFrames, sampleRate));
61 61
62 if (!buffer->createdSuccessfully(numberOfChannels)) 62 if (!buffer->createdSuccessfully(numberOfChannels))
63 return nullptr; 63 return nullptr;
64 return buffer; 64 return buffer;
65 } 65 }
66 66
67 PassRefPtr<AudioBuffer> AudioBuffer::createFromAudioFileData(const void* data, s ize_t dataSize, bool mixToMono, float sampleRate) 67 PassRefPtrWillBeRawPtr<AudioBuffer> AudioBuffer::createFromAudioFileData(const v oid* data, size_t dataSize, bool mixToMono, float sampleRate)
68 { 68 {
69 RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(data, dataSize, mixToM ono, sampleRate); 69 RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(data, dataSize, mixToM ono, sampleRate);
70 if (bus.get()) { 70 if (bus.get()) {
71 RefPtr<AudioBuffer> buffer = adoptRef(new AudioBuffer(bus.get())); 71 RefPtrWillBeRawPtr<AudioBuffer> buffer = adoptRefWillBeNoop(new AudioBuf fer(bus.get()));
72 if (buffer->createdSuccessfully(bus->numberOfChannels())) 72 if (buffer->createdSuccessfully(bus->numberOfChannels()))
73 return buffer; 73 return buffer;
74 } 74 }
75 75
76 return nullptr; 76 return nullptr;
77 } 77 }
78 78
79 PassRefPtrWillBeRawPtr<AudioBuffer> AudioBuffer::createFromAudioBus(AudioBus* bu s)
80 {
81 if (!bus)
82 return nullptr;
83 RefPtrWillBeRawPtr<AudioBuffer> buffer = adoptRefWillBeNoop(new AudioBuffer( bus));
84 if (buffer->createdSuccessfully(bus->numberOfChannels()))
85 return buffer;
86 return nullptr;
87 }
88
79 bool AudioBuffer::createdSuccessfully(unsigned desiredNumberOfChannels) const 89 bool AudioBuffer::createdSuccessfully(unsigned desiredNumberOfChannels) const
80 { 90 {
81 return numberOfChannels() == desiredNumberOfChannels; 91 return numberOfChannels() == desiredNumberOfChannels;
82 } 92 }
83 93
84 AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate) 94 AudioBuffer::AudioBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
85 : m_sampleRate(sampleRate) 95 : m_sampleRate(sampleRate)
86 , m_length(numberOfFrames) 96 , m_length(numberOfFrames)
87 { 97 {
88 ScriptWrappable::init(this); 98 ScriptWrappable::init(this);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { 155 {
146 for (unsigned i = 0; i < m_channels.size(); ++i) { 156 for (unsigned i = 0; i < m_channels.size(); ++i) {
147 if (getChannelData(i)) 157 if (getChannelData(i))
148 getChannelData(i)->zeroRange(0, length()); 158 getChannelData(i)->zeroRange(0, length());
149 } 159 }
150 } 160 }
151 161
152 } // namespace WebCore 162 } // namespace WebCore
153 163
154 #endif // ENABLE(WEB_AUDIO) 164 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/modules/webaudio/AudioBuffer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698