[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
crogers at google.com
crogers at google.com
Wed Dec 22 13:52:20 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 594688c1b84e70c9085dd53c6911b785e2ece9bc
Author: crogers at google.com <crogers at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 28 17:43:40 2010 +0000
2010-09-28 Chris Rogers <crogers at google.com>
Reviewed by Kenneth Russell.
audio engine: audio output classes
https://bugs.webkit.org/show_bug.cgi?id=34716
No new tests since audio API is not yet implemented.
* platform/audio/AudioDestination.h: Added.
(WebCore::AudioDestination::~AudioDestination):
* platform/audio/mac/AudioDestinationMac.cpp: Added.
(WebCore::AudioDestination::create):
(WebCore::AudioDestination::hardwareSampleRate):
(WebCore::AudioDestinationMac::AudioDestinationMac):
(WebCore::AudioDestinationMac::~AudioDestinationMac):
(WebCore::AudioDestinationMac::configure):
(WebCore::AudioDestinationMac::start):
(WebCore::AudioDestinationMac::stop):
(WebCore::AudioDestinationMac::render):
(WebCore::AudioDestinationMac::inputProc):
* platform/audio/mac/AudioDestinationMac.h: Added.
(WebCore::AudioDestinationMac::isPlaying):
(WebCore::AudioDestinationMac::sampleRate):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68539 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a015dc6..1a55f42 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,31 @@
Reviewed by Kenneth Russell.
+ audio engine: audio output classes
+ https://bugs.webkit.org/show_bug.cgi?id=34716
+
+ No new tests since audio API is not yet implemented.
+
+ * platform/audio/AudioDestination.h: Added.
+ (WebCore::AudioDestination::~AudioDestination):
+ * platform/audio/mac/AudioDestinationMac.cpp: Added.
+ (WebCore::AudioDestination::create):
+ (WebCore::AudioDestination::hardwareSampleRate):
+ (WebCore::AudioDestinationMac::AudioDestinationMac):
+ (WebCore::AudioDestinationMac::~AudioDestinationMac):
+ (WebCore::AudioDestinationMac::configure):
+ (WebCore::AudioDestinationMac::start):
+ (WebCore::AudioDestinationMac::stop):
+ (WebCore::AudioDestinationMac::render):
+ (WebCore::AudioDestinationMac::inputProc):
+ * platform/audio/mac/AudioDestinationMac.h: Added.
+ (WebCore::AudioDestinationMac::isPlaying):
+ (WebCore::AudioDestinationMac::sampleRate):
+
+2010-09-28 Chris Rogers <crogers at google.com>
+
+ Reviewed by Kenneth Russell.
+
Add AudioGain files
https://bugs.webkit.org/show_bug.cgi?id=46285
diff --git a/WebCore/platform/audio/AudioDestination.h b/WebCore/platform/audio/AudioDestination.h
new file mode 100644
index 0000000..9498110
--- /dev/null
+++ b/WebCore/platform/audio/AudioDestination.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioDestination_h
+#define AudioDestination_h
+
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+
+class AudioSourceProvider;
+
+// Abstraction for an audio output to the audio hardware
+// An AudioSourceProvider is called back periodically to provide the rendered audio stream.
+
+class AudioDestination {
+public:
+ static PassOwnPtr<AudioDestination> create(AudioSourceProvider&, double sampleRate);
+
+ virtual ~AudioDestination() { }
+
+ virtual void start() = 0;
+ virtual void stop() = 0;
+ virtual bool isPlaying() = 0;
+
+ // Sample-rate conversion may happen in AudioDestination to the hardware sample-rate
+ virtual double sampleRate() const = 0;
+ static double hardwareSampleRate();
+};
+
+} // namespace WebCore
+
+#endif // AudioDestination_h
diff --git a/WebCore/platform/audio/mac/AudioDestinationMac.cpp b/WebCore/platform/audio/mac/AudioDestinationMac.cpp
new file mode 100644
index 0000000..523729f
--- /dev/null
+++ b/WebCore/platform/audio/mac/AudioDestinationMac.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioDestinationMac.h"
+
+#include "AudioSourceProvider.h"
+#include <CoreAudio/AudioHardware.h>
+
+namespace WebCore {
+
+const int kBufferSize = 128;
+
+// Factory method: Mac-implementation
+PassOwnPtr<AudioDestination> AudioDestination::create(AudioSourceProvider& provider, double sampleRate)
+{
+ return adoptPtr(new AudioDestinationMac(provider, sampleRate));
+}
+
+double AudioDestination::hardwareSampleRate()
+{
+ // Determine the default output device's sample-rate.
+ AudioDeviceID deviceID = kAudioDeviceUnknown;
+ UInt32 infoSize = sizeof(deviceID);
+
+ AudioObjectPropertyAddress defaultInputDeviceAddress = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+ OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultInputDeviceAddress, 0, 0, &infoSize, (void*)&deviceID);
+ if (result)
+ return 0.0; // error
+
+ Float64 nominalSampleRate;
+ infoSize = sizeof(Float64);
+
+ AudioObjectPropertyAddress nominalSampleRateAddress = { kAudioDevicePropertyNominalSampleRate, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+ result = AudioObjectGetPropertyData(deviceID, &nominalSampleRateAddress, 0, 0, &infoSize, (void*)&nominalSampleRate);
+ if (result)
+ return 0.0; // error
+
+ return nominalSampleRate;
+}
+
+AudioDestinationMac::AudioDestinationMac(AudioSourceProvider& provider, double sampleRate)
+ : m_outputUnit(0)
+ , m_provider(provider)
+ , m_renderBus(2, kBufferSize, false)
+ , m_sampleRate(sampleRate)
+ , m_isPlaying(false)
+{
+ // Open and initialize DefaultOutputUnit
+ Component comp;
+ ComponentDescription desc;
+
+ desc.componentType = kAudioUnitType_Output;
+ desc.componentSubType = kAudioUnitSubType_DefaultOutput;
+ desc.componentManufacturer = kAudioUnitManufacturer_Apple;
+ desc.componentFlags = 0;
+ desc.componentFlagsMask = 0;
+ comp = FindNextComponent(0, &desc);
+
+ ASSERT(comp);
+
+ OSStatus result = OpenAComponent(comp, &m_outputUnit);
+ ASSERT(!result);
+
+ result = AudioUnitInitialize(m_outputUnit);
+ ASSERT(!result);
+
+ configure();
+}
+
+AudioDestinationMac::~AudioDestinationMac()
+{
+ if (m_outputUnit)
+ CloseComponent(m_outputUnit);
+}
+
+void AudioDestinationMac::configure()
+{
+ // Set render callback
+ AURenderCallbackStruct input;
+ input.inputProc = inputProc;
+ input.inputProcRefCon = this;
+ OSStatus result = AudioUnitSetProperty(m_outputUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &input, sizeof(input));
+ ASSERT(!result);
+
+ // Set stream format
+ AudioStreamBasicDescription streamFormat;
+ streamFormat.mSampleRate = m_sampleRate;
+ streamFormat.mFormatID = kAudioFormatLinearPCM;
+ streamFormat.mFormatFlags = kAudioFormatFlagsCanonical | kAudioFormatFlagIsNonInterleaved;
+ streamFormat.mBitsPerChannel = 8 * sizeof(AudioSampleType);
+ streamFormat.mChannelsPerFrame = 2;
+ streamFormat.mFramesPerPacket = 1;
+ streamFormat.mBytesPerPacket = sizeof(AudioSampleType);
+ streamFormat.mBytesPerFrame = sizeof(AudioSampleType);
+
+ result = AudioUnitSetProperty(m_outputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, (void*)&streamFormat, sizeof(AudioStreamBasicDescription));
+ ASSERT(!result);
+
+ // Set the buffer frame size.
+ UInt32 bufferSize = kBufferSize;
+ result = AudioUnitSetProperty(m_outputUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Output, 0, (void*)&bufferSize, sizeof(bufferSize));
+ ASSERT(!result);
+}
+
+void AudioDestinationMac::start()
+{
+ OSStatus result = AudioOutputUnitStart(m_outputUnit);
+
+ if (!result)
+ m_isPlaying = true;
+}
+
+void AudioDestinationMac::stop()
+{
+ OSStatus result = AudioOutputUnitStop(m_outputUnit);
+
+ if (!result)
+ m_isPlaying = false;
+}
+
+// Pulls on our provider to get rendered audio stream.
+OSStatus AudioDestinationMac::render(UInt32 numberOfFrames, AudioBufferList* ioData)
+{
+ AudioBuffer* buffers = ioData->mBuffers;
+ m_renderBus.setChannelMemory(0, (float*)buffers[0].mData, numberOfFrames);
+ m_renderBus.setChannelMemory(1, (float*)buffers[1].mData, numberOfFrames);
+
+ m_provider.provideInput(&m_renderBus, numberOfFrames);
+
+ return noErr;
+}
+
+// DefaultOutputUnit callback
+OSStatus AudioDestinationMac::inputProc(void* userData, AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32 /*busNumber*/, UInt32 numberOfFrames, AudioBufferList* ioData)
+{
+ AudioDestinationMac* audioOutput = static_cast<AudioDestinationMac*>(userData);
+ return audioOutput->render(numberOfFrames, ioData);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)
diff --git a/WebCore/platform/audio/mac/AudioDestinationMac.h b/WebCore/platform/audio/mac/AudioDestinationMac.h
new file mode 100644
index 0000000..197440c
--- /dev/null
+++ b/WebCore/platform/audio/mac/AudioDestinationMac.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AudioDestinationMac_h
+#define AudioDestinationMac_h
+
+#include "AudioBus.h"
+#include "AudioDestination.h"
+#include <AudioUnit/AudioUnit.h>
+
+namespace WebCore {
+
+// An AudioDestination using CoreAudio's default output AudioUnit
+
+class AudioDestinationMac : public AudioDestination {
+public:
+ AudioDestinationMac(AudioSourceProvider&, double sampleRate);
+ virtual ~AudioDestinationMac();
+
+ virtual void start();
+ virtual void stop();
+ bool isPlaying() { return m_isPlaying; }
+
+ double sampleRate() const { return m_sampleRate; }
+
+private:
+ void configure();
+
+ // DefaultOutputUnit callback
+ static OSStatus inputProc(void* userData, AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32 busNumber, UInt32 numberOfFrames, AudioBufferList* ioData);
+
+ OSStatus render(UInt32 numberOfFrames, AudioBufferList* ioData);
+
+ AudioUnit m_outputUnit;
+ AudioSourceProvider& m_provider;
+ AudioBus m_renderBus;
+
+ double m_sampleRate;
+ bool m_isPlaying;
+};
+
+} // namespace WebCore
+
+#endif // AudioDestinationMac_h
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list