diff options
Diffstat (limited to 'linden/indra/llaudio/audioengine.cpp')
-rw-r--r-- | linden/indra/llaudio/audioengine.cpp | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 438aefc..dd0ffff 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2000&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2000&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2000-2008, Linden Research, Inc. | 8 | * Copyright (c) 2000-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -98,12 +98,12 @@ void LLAudioEngine::setDefaults() | |||
98 | mInternetStreamGain = 0.125f; | 98 | mInternetStreamGain = 0.125f; |
99 | mNextWindUpdate = 0.f; | 99 | mNextWindUpdate = 0.f; |
100 | 100 | ||
101 | mInternetStreamMedia = NULL; | ||
102 | mInternetStreamURL.clear(); | ||
103 | |||
104 | for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) | 101 | for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) |
105 | mSecondaryGain[i] = 1.0f; | 102 | mSecondaryGain[i] = 1.0f; |
106 | 103 | ||
104 | mInternetStreamMedia = NULL; | ||
105 | mInternetStreamURL.clear(); | ||
106 | |||
107 | mStatus = LLMediaBase::STATUS_UNKNOWN; | 107 | mStatus = LLMediaBase::STATUS_UNKNOWN; |
108 | } | 108 | } |
109 | 109 | ||
@@ -120,7 +120,7 @@ bool LLAudioEngine::init(const S32 num_channels, void* userdata) | |||
120 | // Initialize the decode manager | 120 | // Initialize the decode manager |
121 | gAudioDecodeMgrp = new LLAudioDecodeMgr; | 121 | gAudioDecodeMgrp = new LLAudioDecodeMgr; |
122 | 122 | ||
123 | LL_INFOS("AudioEngine") << "LLAudioEngine::init() AudioEngine successfully initialized" << llendl; | 123 | llinfos << "LLAudioEngine::init() AudioEngine successfully initialized" << llendl; |
124 | 124 | ||
125 | return true; | 125 | return true; |
126 | } | 126 | } |
@@ -183,7 +183,7 @@ LLMediaBase::EStatus LLAudioEngine::getStatus() | |||
183 | // virtual | 183 | // virtual |
184 | void LLAudioEngine::startInternetStream(const std::string& url) | 184 | void LLAudioEngine::startInternetStream(const std::string& url) |
185 | { | 185 | { |
186 | LL_INFOS("AudioEngine") << "entered startInternetStream()" << llendl; | 186 | llinfos << "entered startInternetStream()" << llendl; |
187 | 187 | ||
188 | if (!mInternetStreamMedia) | 188 | if (!mInternetStreamMedia) |
189 | { | 189 | { |
@@ -191,7 +191,7 @@ void LLAudioEngine::startInternetStream(const std::string& url) | |||
191 | if (mgr) | 191 | if (mgr) |
192 | { | 192 | { |
193 | mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis. | 193 | mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis. |
194 | LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; | 194 | llinfos << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
@@ -202,7 +202,7 @@ void LLAudioEngine::startInternetStream(const std::string& url) | |||
202 | // Check for a dead stream from gstreamer, just in case | 202 | // Check for a dead stream from gstreamer, just in case |
203 | else if(getStatus() == LLMediaBase::STATUS_DEAD) | 203 | else if(getStatus() == LLMediaBase::STATUS_DEAD) |
204 | { | 204 | { |
205 | LL_INFOS("AudioEngine") << "don't play dead stream urls"<< llendl; | 205 | llinfos << "don't play dead stream urls"<< llendl; |
206 | mInternetStreamURL.clear(); | 206 | mInternetStreamURL.clear(); |
207 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); | 207 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); |
208 | mInternetStreamMedia->updateMedia(); | 208 | mInternetStreamMedia->updateMedia(); |
@@ -210,7 +210,7 @@ void LLAudioEngine::startInternetStream(const std::string& url) | |||
210 | } | 210 | } |
211 | else if (url.empty()) | 211 | else if (url.empty()) |
212 | { | 212 | { |
213 | LL_INFOS("AudioEngine") << "url is emptly. Setting stream to NULL"<< llendl; | 213 | llinfos << "url is emptly. Setting stream to NULL"<< llendl; |
214 | mInternetStreamURL.clear(); | 214 | mInternetStreamURL.clear(); |
215 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); | 215 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); |
216 | mInternetStreamMedia->updateMedia(); | 216 | mInternetStreamMedia->updateMedia(); |
@@ -221,10 +221,10 @@ void LLAudioEngine::startInternetStream(const std::string& url) | |||
221 | // stop any other stream first | 221 | // stop any other stream first |
222 | stopInternetStream(); | 222 | stopInternetStream(); |
223 | 223 | ||
224 | LL_INFOS("AudioEngine") << "Starting internet stream: " << url << llendl; | 224 | llinfos << "Starting internet stream: " << url << llendl; |
225 | mInternetStreamURL = url; | 225 | mInternetStreamURL = url; |
226 | mInternetStreamMedia->navigateTo(url); | 226 | mInternetStreamMedia->navigateTo(url); |
227 | //LL_INFOS("AudioEngine") << "Playing....." << llendl; | 227 | //llinfos << "Playing....." << llendl; |
228 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); | 228 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); |
229 | mInternetStreamMedia->updateMedia(); | 229 | mInternetStreamMedia->updateMedia(); |
230 | mStatus = LLMediaBase::STATUS_STARTED; | 230 | mStatus = LLMediaBase::STATUS_STARTED; |
@@ -234,17 +234,42 @@ void LLAudioEngine::startInternetStream(const std::string& url) | |||
234 | // virtual | 234 | // virtual |
235 | void LLAudioEngine::stopInternetStream() | 235 | void LLAudioEngine::stopInternetStream() |
236 | { | 236 | { |
237 | LL_INFOS("AudioEngine") << "entered stopInternetStream()" << llendl; | 237 | llinfos << "entered stopInternetStream()" << llendl; |
238 | mInternetStreamURL.clear(); | 238 | mInternetStreamURL.clear(); |
239 | 239 | ||
240 | if(mInternetStreamMedia) | 240 | if(mInternetStreamMedia) |
241 | { | 241 | { |
242 | if(!mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)) | 242 | if(!mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)) |
243 | { | 243 | { |
244 | LL_INFOS("AudioEngine") << "attempting to stop stream failed!" << llendl; | 244 | llinfos << "attempting to stop stream failed!" << llendl; |
245 | } | 245 | } |
246 | mInternetStreamMedia->updateMedia(); | 246 | mInternetStreamMedia->updateMedia(); |
247 | } | 247 | } |
248 | |||
249 | mInternetStreamURL.clear(); | ||
250 | } | ||
251 | |||
252 | // virtual | ||
253 | void LLAudioEngine::pauseInternetStream(int pause) | ||
254 | { | ||
255 | llinfos << "entered pauseInternetStream()" << llendl; | ||
256 | |||
257 | if(!mInternetStreamMedia) | ||
258 | return; | ||
259 | |||
260 | if(pause) | ||
261 | { | ||
262 | if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_PAUSE)) | ||
263 | { | ||
264 | llinfos << "attempting to pause stream failed!" << llendl; | ||
265 | } | ||
266 | } else { | ||
267 | if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START)) | ||
268 | { | ||
269 | llinfos << "attempting to unpause stream failed!" << llendl; | ||
270 | } | ||
271 | } | ||
272 | mInternetStreamMedia->updateMedia(); | ||
248 | } | 273 | } |
249 | 274 | ||
250 | // virtual | 275 | // virtual |
@@ -265,6 +290,11 @@ int LLAudioEngine::isInternetStreamPlaying() | |||
265 | return 1; // Active and playing | 290 | return 1; // Active and playing |
266 | } | 291 | } |
267 | 292 | ||
293 | if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_PAUSED) | ||
294 | { | ||
295 | return 2; // paused | ||
296 | } | ||
297 | |||
268 | return 0; // Stopped | 298 | return 0; // Stopped |
269 | } | 299 | } |
270 | 300 | ||
@@ -1526,7 +1556,7 @@ bool LLAudioSource::isDone() | |||
1526 | { | 1556 | { |
1527 | // We don't have a channel assigned, and it's been | 1557 | // We don't have a channel assigned, and it's been |
1528 | // over 5 seconds since we tried to play it. Don't bother. | 1558 | // over 5 seconds since we tried to play it. Don't bother. |
1529 | //LL_INFOS("AudioEngine") << "No channel assigned, source is done" << llendl; | 1559 | //llinfos << "No channel assigned, source is done" << llendl; |
1530 | return true; | 1560 | return true; |
1531 | } | 1561 | } |
1532 | else | 1562 | else |
@@ -1716,6 +1746,8 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep) | |||
1716 | } | 1746 | } |
1717 | 1747 | ||
1718 | mCurrentSourcep = sourcep; | 1748 | mCurrentSourcep = sourcep; |
1749 | |||
1750 | |||
1719 | updateBuffer(); | 1751 | updateBuffer(); |
1720 | update3DPosition(); | 1752 | update3DPosition(); |
1721 | } | 1753 | } |
@@ -1730,6 +1762,12 @@ bool LLAudioChannel::updateBuffer() | |||
1730 | return false; | 1762 | return false; |
1731 | } | 1763 | } |
1732 | 1764 | ||
1765 | // Initialize the channel's gain setting for this sound. | ||
1766 | if(gAudiop) | ||
1767 | { | ||
1768 | setSecondaryGain(gAudiop->getSecondaryGain(mCurrentSourcep->getType())); | ||
1769 | } | ||
1770 | |||
1733 | LLAudioBuffer *bufferp = mCurrentSourcep->getCurrentBuffer(); | 1771 | LLAudioBuffer *bufferp = mCurrentSourcep->getCurrentBuffer(); |
1734 | if (bufferp == mCurrentBufferp) | 1772 | if (bufferp == mCurrentBufferp) |
1735 | { | 1773 | { |
@@ -1804,7 +1842,7 @@ bool LLAudioData::load() | |||
1804 | if (mBufferp) | 1842 | if (mBufferp) |
1805 | { | 1843 | { |
1806 | // We already have this sound in a buffer, don't do anything. | 1844 | // We already have this sound in a buffer, don't do anything. |
1807 | LL_INFOS("AudioEngine") << "Already have a buffer for this sound, don't bother loading!" << llendl; | 1845 | llinfos << "Already have a buffer for this sound, don't bother loading!" << llendl; |
1808 | return true; | 1846 | return true; |
1809 | } | 1847 | } |
1810 | 1848 | ||
@@ -1812,7 +1850,7 @@ bool LLAudioData::load() | |||
1812 | if (!mBufferp) | 1850 | if (!mBufferp) |
1813 | { | 1851 | { |
1814 | // No free buffers, abort. | 1852 | // No free buffers, abort. |
1815 | LL_INFOS("AudioEngine") << "Not able to allocate a new audio buffer, aborting." << llendl; | 1853 | llinfos << "Not able to allocate a new audio buffer, aborting." << llendl; |
1816 | return false; | 1854 | return false; |
1817 | } | 1855 | } |
1818 | 1856 | ||