1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webaudio/AudioProcessingEvent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,82 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef AudioProcessingEvent_h_ 1.11 +#define AudioProcessingEvent_h_ 1.12 + 1.13 +#include "AudioBuffer.h" 1.14 +#include "ScriptProcessorNode.h" 1.15 +#include "mozilla/dom/Event.h" 1.16 + 1.17 +namespace mozilla { 1.18 +namespace dom { 1.19 + 1.20 +class AudioProcessingEvent : public Event 1.21 +{ 1.22 +public: 1.23 + AudioProcessingEvent(ScriptProcessorNode* aOwner, 1.24 + nsPresContext* aPresContext, 1.25 + WidgetEvent* aEvent); 1.26 + 1.27 + NS_DECL_ISUPPORTS_INHERITED 1.28 + NS_FORWARD_TO_EVENT 1.29 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioProcessingEvent, Event) 1.30 + 1.31 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.32 + 1.33 + void InitEvent(AudioBuffer* aInputBuffer, 1.34 + uint32_t aNumberOfInputChannels, 1.35 + double aPlaybackTime) 1.36 + { 1.37 + InitEvent(NS_LITERAL_STRING("audioprocess"), false, false); 1.38 + mInputBuffer = aInputBuffer; 1.39 + mNumberOfInputChannels = aNumberOfInputChannels; 1.40 + mPlaybackTime = aPlaybackTime; 1.41 + } 1.42 + 1.43 + double PlaybackTime() const 1.44 + { 1.45 + return mPlaybackTime; 1.46 + } 1.47 + 1.48 + AudioBuffer* GetInputBuffer(ErrorResult& aRv) 1.49 + { 1.50 + if (!mInputBuffer) { 1.51 + mInputBuffer = LazilyCreateBuffer(mNumberOfInputChannels, aRv); 1.52 + } 1.53 + return mInputBuffer; 1.54 + } 1.55 + 1.56 + AudioBuffer* GetOutputBuffer(ErrorResult& aRv) 1.57 + { 1.58 + if (!mOutputBuffer) { 1.59 + mOutputBuffer = LazilyCreateBuffer(mNode->NumberOfOutputChannels(), aRv); 1.60 + } 1.61 + return mOutputBuffer; 1.62 + } 1.63 + 1.64 + bool HasOutputBuffer() const 1.65 + { 1.66 + return !!mOutputBuffer; 1.67 + } 1.68 + 1.69 +private: 1.70 + already_AddRefed<AudioBuffer> 1.71 + LazilyCreateBuffer(uint32_t aNumberOfChannels, ErrorResult& rv); 1.72 + 1.73 +private: 1.74 + double mPlaybackTime; 1.75 + nsRefPtr<AudioBuffer> mInputBuffer; 1.76 + nsRefPtr<AudioBuffer> mOutputBuffer; 1.77 + nsRefPtr<ScriptProcessorNode> mNode; 1.78 + uint32_t mNumberOfInputChannels; 1.79 +}; 1.80 + 1.81 +} 1.82 +} 1.83 + 1.84 +#endif 1.85 +