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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/DefaultAudioDestinationNode.cpp

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 30 matching lines...) Expand all
41 m_channelInterpretation = AudioBus::Speakers; 41 m_channelInterpretation = AudioBus::Speakers;
42 } 42 }
43 43
44 PassRefPtr<DefaultAudioDestinationHandler> DefaultAudioDestinationHandler::creat e(AudioNode& node) 44 PassRefPtr<DefaultAudioDestinationHandler> DefaultAudioDestinationHandler::creat e(AudioNode& node)
45 { 45 {
46 return adoptRef(new DefaultAudioDestinationHandler(node)); 46 return adoptRef(new DefaultAudioDestinationHandler(node));
47 } 47 }
48 48
49 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler() 49 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler()
50 { 50 {
51 ASSERT(!isInitialized()); 51 DCHECK(!isInitialized());
52 } 52 }
53 53
54 void DefaultAudioDestinationHandler::dispose() 54 void DefaultAudioDestinationHandler::dispose()
55 { 55 {
56 uninitialize(); 56 uninitialize();
57 AudioDestinationHandler::dispose(); 57 AudioDestinationHandler::dispose();
58 } 58 }
59 59
60 void DefaultAudioDestinationHandler::initialize() 60 void DefaultAudioDestinationHandler::initialize()
61 { 61 {
62 ASSERT(isMainThread()); 62 DCHECK(isMainThread());
63 if (isInitialized()) 63 if (isInitialized())
64 return; 64 return;
65 65
66 createDestination(); 66 createDestination();
67 AudioHandler::initialize(); 67 AudioHandler::initialize();
68 } 68 }
69 69
70 void DefaultAudioDestinationHandler::uninitialize() 70 void DefaultAudioDestinationHandler::uninitialize()
71 { 71 {
72 ASSERT(isMainThread()); 72 DCHECK(isMainThread());
73 if (!isInitialized()) 73 if (!isInitialized())
74 return; 74 return;
75 75
76 m_destination->stop(); 76 m_destination->stop();
77 m_numberOfInputChannels = 0; 77 m_numberOfInputChannels = 0;
78 78
79 AudioHandler::uninitialize(); 79 AudioHandler::uninitialize();
80 } 80 }
81 81
82 void DefaultAudioDestinationHandler::createDestination() 82 void DefaultAudioDestinationHandler::createDestination()
83 { 83 {
84 float hardwareSampleRate = AudioDestination::hardwareSampleRate(); 84 float hardwareSampleRate = AudioDestination::hardwareSampleRate();
85 VLOG(1) << ">>>> hardwareSampleRate = " << hardwareSampleRate; 85 VLOG(1) << ">>>> hardwareSampleRate = " << hardwareSampleRate;
86 86
87 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI nputChannels, channelCount(), hardwareSampleRate, context()->getSecurityOrigin() ); 87 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI nputChannels, channelCount(), hardwareSampleRate, context()->getSecurityOrigin() );
88 } 88 }
89 89
90 void DefaultAudioDestinationHandler::startRendering() 90 void DefaultAudioDestinationHandler::startRendering()
91 { 91 {
92 ASSERT(isInitialized()); 92 DCHECK(isInitialized());
93 if (isInitialized()) { 93 if (isInitialized()) {
94 ASSERT(!m_destination->isPlaying()); 94 DCHECK(!m_destination->isPlaying());
95 m_destination->start(); 95 m_destination->start();
96 } 96 }
97 } 97 }
98 98
99 void DefaultAudioDestinationHandler::stopRendering() 99 void DefaultAudioDestinationHandler::stopRendering()
100 { 100 {
101 ASSERT(isInitialized()); 101 DCHECK(isInitialized());
102 if (isInitialized()) { 102 if (isInitialized()) {
103 ASSERT(m_destination->isPlaying()); 103 DCHECK(m_destination->isPlaying());
104 m_destination->stop(); 104 m_destination->stop();
105 } 105 }
106 } 106 }
107 107
108 unsigned long DefaultAudioDestinationHandler::maxChannelCount() const 108 unsigned long DefaultAudioDestinationHandler::maxChannelCount() const
109 { 109 {
110 return AudioDestination::maxChannelCount(); 110 return AudioDestination::maxChannelCount();
111 } 111 }
112 112
113 void DefaultAudioDestinationHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState) 113 void DefaultAudioDestinationHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState)
114 { 114 {
115 // The channelCount for the input to this node controls the actual number of channels we 115 // The channelCount for the input to this node controls the actual number of channels we
116 // send to the audio hardware. It can only be set depending on the maximum n umber of 116 // send to the audio hardware. It can only be set depending on the maximum n umber of
117 // channels supported by the hardware. 117 // channels supported by the hardware.
118 118
119 ASSERT(isMainThread()); 119 DCHECK(isMainThread());
120 120
121 if (!maxChannelCount() || channelCount > maxChannelCount()) { 121 if (!maxChannelCount() || channelCount > maxChannelCount()) {
122 exceptionState.throwDOMException( 122 exceptionState.throwDOMException(
123 IndexSizeError, 123 IndexSizeError,
124 ExceptionMessages::indexOutsideRange<unsigned>("channel count", chan nelCount, 1, ExceptionMessages::InclusiveBound, maxChannelCount(), ExceptionMess ages::InclusiveBound)); 124 ExceptionMessages::indexOutsideRange<unsigned>("channel count", chan nelCount, 1, ExceptionMessages::InclusiveBound, maxChannelCount(), ExceptionMess ages::InclusiveBound));
125 return; 125 return;
126 } 126 }
127 127
128 unsigned long oldChannelCount = this->channelCount(); 128 unsigned long oldChannelCount = this->channelCount();
129 AudioHandler::setChannelCount(channelCount, exceptionState); 129 AudioHandler::setChannelCount(channelCount, exceptionState);
(...skipping 14 matching lines...) Expand all
144 setHandler(DefaultAudioDestinationHandler::create(*this)); 144 setHandler(DefaultAudioDestinationHandler::create(*this));
145 } 145 }
146 146
147 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create(BaseAudioContex t* context) 147 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create(BaseAudioContex t* context)
148 { 148 {
149 return new DefaultAudioDestinationNode(*context); 149 return new DefaultAudioDestinationNode(*context);
150 } 150 }
151 151
152 } // namespace blink 152 } // namespace blink
153 153
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698