Source.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. /**
  2. * Copyright (c) 2006-2015 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #include "Source.h"
  21. #include "Pool.h"
  22. #include "common/math.h"
  23. // STD
  24. #include <iostream>
  25. #include <float.h>
  26. namespace love
  27. {
  28. namespace audio
  29. {
  30. namespace openal
  31. {
  32. StaticDataBuffer::StaticDataBuffer(ALenum format, const ALvoid *data, ALsizei size, ALsizei freq)
  33. {
  34. alGenBuffers(1, &buffer);
  35. alBufferData(buffer, format, data, size, freq);
  36. }
  37. StaticDataBuffer::~StaticDataBuffer()
  38. {
  39. alDeleteBuffers(1, &buffer);
  40. }
  41. Source::Source(Pool *pool, love::sound::SoundData *soundData)
  42. : love::audio::Source(Source::TYPE_STATIC)
  43. , pool(pool)
  44. , valid(false)
  45. , staticBuffer(nullptr)
  46. , pitch(1.0f)
  47. , volume(1.0f)
  48. , relative(false)
  49. , looping(false)
  50. , paused(false)
  51. , minVolume(0.0f)
  52. , maxVolume(1.0f)
  53. , referenceDistance(1.0f)
  54. , rolloffFactor(1.0f)
  55. , maxDistance(FLT_MAX)
  56. , cone()
  57. , offsetSamples(0)
  58. , offsetSeconds(0)
  59. , sampleRate(soundData->getSampleRate())
  60. , channels(soundData->getChannels())
  61. , decoder(nullptr)
  62. , toLoop(0)
  63. {
  64. ALenum fmt = getFormat(soundData->getChannels(), soundData->getBitDepth());
  65. staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate()));
  66. // The buffer has a +2 retain count right now, but we want it to have +1.
  67. staticBuffer->release();
  68. float z[3] = {0, 0, 0};
  69. setFloatv(position, z);
  70. setFloatv(velocity, z);
  71. setFloatv(direction, z);
  72. }
  73. Source::Source(Pool *pool, love::sound::Decoder *decoder)
  74. : love::audio::Source(Source::TYPE_STREAM)
  75. , pool(pool)
  76. , valid(false)
  77. , staticBuffer(nullptr)
  78. , pitch(1.0f)
  79. , volume(1.0f)
  80. , relative(false)
  81. , looping(false)
  82. , paused(false)
  83. , minVolume(0.0f)
  84. , maxVolume(1.0f)
  85. , referenceDistance(1.0f)
  86. , rolloffFactor(1.0f)
  87. , maxDistance(FLT_MAX)
  88. , cone()
  89. , offsetSamples(0)
  90. , offsetSeconds(0)
  91. , sampleRate(decoder->getSampleRate())
  92. , channels(decoder->getChannels())
  93. , decoder(decoder)
  94. , toLoop(0)
  95. {
  96. alGenBuffers(MAX_BUFFERS, streamBuffers);
  97. float z[3] = {0, 0, 0};
  98. setFloatv(position, z);
  99. setFloatv(velocity, z);
  100. setFloatv(direction, z);
  101. }
  102. Source::Source(const Source &s)
  103. : love::audio::Source(s.type)
  104. , pool(s.pool)
  105. , valid(false)
  106. , staticBuffer(s.staticBuffer)
  107. , pitch(s.pitch)
  108. , volume(s.volume)
  109. , relative(s.relative)
  110. , looping(s.looping)
  111. , paused(false)
  112. , minVolume(s.minVolume)
  113. , maxVolume(s.maxVolume)
  114. , referenceDistance(s.referenceDistance)
  115. , rolloffFactor(s.rolloffFactor)
  116. , maxDistance(s.maxDistance)
  117. , cone(s.cone)
  118. , offsetSamples(0)
  119. , offsetSeconds(0)
  120. , sampleRate(s.sampleRate)
  121. , channels(s.channels)
  122. , decoder(nullptr)
  123. , toLoop(0)
  124. {
  125. if (type == TYPE_STREAM)
  126. {
  127. if (s.decoder.get())
  128. {
  129. love::sound::Decoder *dec = s.decoder->clone();
  130. decoder.set(dec);
  131. dec->release();
  132. }
  133. alGenBuffers(MAX_BUFFERS, streamBuffers);
  134. }
  135. setFloatv(position, s.position);
  136. setFloatv(velocity, s.velocity);
  137. setFloatv(direction, s.direction);
  138. }
  139. Source::~Source()
  140. {
  141. if (valid)
  142. pool->stop(this);
  143. if (type == TYPE_STREAM)
  144. alDeleteBuffers(MAX_BUFFERS, streamBuffers);
  145. }
  146. love::audio::Source *Source::clone()
  147. {
  148. return new Source(*this);
  149. }
  150. bool Source::play()
  151. {
  152. if (valid && paused)
  153. {
  154. pool->resume(this);
  155. return true;
  156. }
  157. valid = pool->play(this, source);
  158. return valid;
  159. }
  160. void Source::stop()
  161. {
  162. if (!isStopped())
  163. {
  164. pool->stop(this);
  165. pool->softRewind(this);
  166. }
  167. }
  168. void Source::pause()
  169. {
  170. pool->pause(this);
  171. }
  172. void Source::resume()
  173. {
  174. pool->resume(this);
  175. }
  176. void Source::rewind()
  177. {
  178. pool->rewind(this);
  179. }
  180. bool Source::isStopped() const
  181. {
  182. if (valid)
  183. {
  184. ALenum state;
  185. alGetSourcei(source, AL_SOURCE_STATE, &state);
  186. return (state == AL_STOPPED);
  187. }
  188. return true;
  189. }
  190. bool Source::isPaused() const
  191. {
  192. if (valid)
  193. {
  194. ALenum state;
  195. alGetSourcei(source, AL_SOURCE_STATE, &state);
  196. return (state == AL_PAUSED);
  197. }
  198. return false;
  199. }
  200. bool Source::isFinished() const
  201. {
  202. return type == TYPE_STATIC ? isStopped() : isStopped() && !isLooping() && decoder->isFinished();
  203. }
  204. bool Source::update()
  205. {
  206. if (!valid)
  207. return false;
  208. if (type == TYPE_STATIC)
  209. {
  210. // Looping mode could have changed.
  211. alSourcei(source, AL_LOOPING, isLooping() ? AL_TRUE : AL_FALSE);
  212. return !isStopped();
  213. }
  214. else if (type == TYPE_STREAM && (isLooping() || !isFinished()))
  215. {
  216. // Number of processed buffers.
  217. ALint processed = 0;
  218. alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
  219. while (processed--)
  220. {
  221. ALuint buffer;
  222. float curOffsetSamples, curOffsetSecs;
  223. alGetSourcef(source, AL_SAMPLE_OFFSET, &curOffsetSamples);
  224. int freq = decoder->getSampleRate();
  225. curOffsetSecs = curOffsetSamples / freq;
  226. // Get a free buffer.
  227. alSourceUnqueueBuffers(source, 1, &buffer);
  228. float newOffsetSamples, newOffsetSecs;
  229. alGetSourcef(source, AL_SAMPLE_OFFSET, &newOffsetSamples);
  230. newOffsetSecs = newOffsetSamples / freq;
  231. offsetSamples += (curOffsetSamples - newOffsetSamples);
  232. offsetSeconds += (curOffsetSecs - newOffsetSecs);
  233. streamAtomic(buffer, decoder.get());
  234. alSourceQueueBuffers(source, 1, &buffer);
  235. }
  236. return true;
  237. }
  238. return false;
  239. }
  240. void Source::setPitch(float pitch)
  241. {
  242. if (valid)
  243. alSourcef(source, AL_PITCH, pitch);
  244. this->pitch = pitch;
  245. }
  246. float Source::getPitch() const
  247. {
  248. if (valid)
  249. {
  250. ALfloat f;
  251. alGetSourcef(source, AL_PITCH, &f);
  252. return f;
  253. }
  254. // In case the Source isn't playing.
  255. return pitch;
  256. }
  257. void Source::setVolume(float volume)
  258. {
  259. if (valid)
  260. {
  261. alSourcef(source, AL_GAIN, volume);
  262. }
  263. this->volume = volume;
  264. }
  265. float Source::getVolume() const
  266. {
  267. if (valid)
  268. {
  269. ALfloat f;
  270. alGetSourcef(source, AL_GAIN, &f);
  271. return f;
  272. }
  273. // In case the Source isn't playing.
  274. return volume;
  275. }
  276. void Source::seekAtomic(float offset, void *unit)
  277. {
  278. if (valid)
  279. {
  280. switch (*((Source::Unit *) unit))
  281. {
  282. case Source::UNIT_SAMPLES:
  283. if (type == TYPE_STREAM)
  284. {
  285. offsetSamples = offset;
  286. offset /= decoder->getSampleRate();
  287. offsetSeconds = offset;
  288. decoder->seek(offset);
  289. }
  290. else
  291. {
  292. alSourcef(source, AL_SAMPLE_OFFSET, offset);
  293. }
  294. break;
  295. case Source::UNIT_SECONDS:
  296. default:
  297. if (type == TYPE_STREAM)
  298. {
  299. offsetSeconds = offset;
  300. decoder->seek(offset);
  301. offsetSamples = offset * decoder->getSampleRate();
  302. }
  303. else
  304. {
  305. alSourcef(source, AL_SEC_OFFSET, offset);
  306. }
  307. break;
  308. }
  309. if (type == TYPE_STREAM)
  310. {
  311. bool waspaused = paused;
  312. // Because we still have old data
  313. // from before the seek in the buffers
  314. // let's empty them.
  315. stopAtomic();
  316. playAtomic();
  317. if (waspaused)
  318. pauseAtomic();
  319. }
  320. }
  321. }
  322. void Source::seek(float offset, Source::Unit unit)
  323. {
  324. return pool->seek(this, offset, &unit);
  325. }
  326. float Source::tellAtomic(void *unit) const
  327. {
  328. if (valid)
  329. {
  330. float offset;
  331. switch (*((Source::Unit *) unit))
  332. {
  333. case Source::UNIT_SAMPLES:
  334. alGetSourcef(source, AL_SAMPLE_OFFSET, &offset);
  335. if (type == TYPE_STREAM) offset += offsetSamples;
  336. break;
  337. case Source::UNIT_SECONDS:
  338. default:
  339. {
  340. alGetSourcef(source, AL_SAMPLE_OFFSET, &offset);
  341. offset /= sampleRate;
  342. if (type == TYPE_STREAM) offset += offsetSeconds;
  343. }
  344. break;
  345. }
  346. return offset;
  347. }
  348. return 0.0f;
  349. }
  350. float Source::tell(Source::Unit unit)
  351. {
  352. return pool->tell(this, &unit);
  353. }
  354. void Source::setPosition(float *v)
  355. {
  356. if (valid)
  357. alSourcefv(source, AL_POSITION, v);
  358. setFloatv(position, v);
  359. }
  360. void Source::getPosition(float *v) const
  361. {
  362. if (valid)
  363. alGetSourcefv(source, AL_POSITION, v);
  364. else
  365. setFloatv(v, position);
  366. }
  367. void Source::setVelocity(float *v)
  368. {
  369. if (valid)
  370. alSourcefv(source, AL_VELOCITY, v);
  371. setFloatv(velocity, v);
  372. }
  373. void Source::getVelocity(float *v) const
  374. {
  375. if (valid)
  376. alGetSourcefv(source, AL_VELOCITY, v);
  377. else
  378. setFloatv(v, velocity);
  379. }
  380. void Source::setDirection(float *v)
  381. {
  382. if (valid)
  383. alSourcefv(source, AL_DIRECTION, v);
  384. else
  385. setFloatv(direction, v);
  386. }
  387. void Source::getDirection(float *v) const
  388. {
  389. if (valid)
  390. alGetSourcefv(source, AL_DIRECTION, v);
  391. else
  392. setFloatv(v, direction);
  393. }
  394. void Source::setCone(float innerAngle, float outerAngle, float outerVolume)
  395. {
  396. cone.innerAngle = (int) LOVE_TODEG(innerAngle);
  397. cone.outerAngle = (int) LOVE_TODEG(outerAngle);
  398. cone.outerVolume = outerVolume;
  399. if (valid)
  400. {
  401. alSourcei(source, AL_CONE_INNER_ANGLE, cone.innerAngle);
  402. alSourcei(source, AL_CONE_OUTER_ANGLE, cone.outerAngle);
  403. alSourcef(source, AL_CONE_OUTER_GAIN, cone.outerVolume);
  404. }
  405. }
  406. void Source::getCone(float &innerAngle, float &outerAngle, float &outerVolume) const
  407. {
  408. innerAngle = LOVE_TORAD(cone.innerAngle);
  409. outerAngle = LOVE_TORAD(cone.outerAngle);
  410. outerVolume = cone.outerVolume;
  411. }
  412. void Source::setRelative(bool enable)
  413. {
  414. if (valid)
  415. alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
  416. relative = enable;
  417. }
  418. bool Source::isRelative() const
  419. {
  420. return relative;
  421. }
  422. void Source::setLooping(bool looping)
  423. {
  424. if (valid && type == TYPE_STATIC)
  425. alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
  426. this->looping = looping;
  427. }
  428. bool Source::isLooping() const
  429. {
  430. return looping;
  431. }
  432. bool Source::playAtomic()
  433. {
  434. if (type == TYPE_STATIC)
  435. {
  436. alSourcei(source, AL_BUFFER, staticBuffer->getBuffer());
  437. }
  438. else if (type == TYPE_STREAM)
  439. {
  440. int usedBuffers = 0;
  441. for (unsigned int i = 0; i < MAX_BUFFERS; i++)
  442. {
  443. streamAtomic(streamBuffers[i], decoder.get());
  444. ++usedBuffers;
  445. if (decoder->isFinished())
  446. break;
  447. }
  448. if (usedBuffers > 0)
  449. alSourceQueueBuffers(source, usedBuffers, streamBuffers);
  450. }
  451. // This Source may now be associated with an OpenAL source that still has
  452. // the properties of another love Source. Let's reset it to the settings
  453. // of the new one.
  454. reset();
  455. // Clear errors.
  456. alGetError();
  457. alSourcePlay(source);
  458. // alSourcePlay may fail if the system has reached its limit of simultaneous
  459. // playing sources.
  460. bool success = alGetError() == AL_NO_ERROR;
  461. valid = true; //if it fails it will be set to false again
  462. //but this prevents a horrible, horrible bug
  463. return success;
  464. }
  465. void Source::stopAtomic()
  466. {
  467. if (valid)
  468. {
  469. if (type == TYPE_STATIC)
  470. {
  471. alSourceStop(source);
  472. }
  473. else if (type == TYPE_STREAM)
  474. {
  475. alSourceStop(source);
  476. int queued = 0;
  477. alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
  478. while (queued--)
  479. {
  480. ALuint buffer;
  481. alSourceUnqueueBuffers(source, 1, &buffer);
  482. }
  483. }
  484. alSourcei(source, AL_BUFFER, AL_NONE);
  485. }
  486. toLoop = 0;
  487. valid = false;
  488. }
  489. void Source::pauseAtomic()
  490. {
  491. if (valid)
  492. {
  493. alSourcePause(source);
  494. paused = true;
  495. }
  496. }
  497. void Source::resumeAtomic()
  498. {
  499. if (valid && paused)
  500. {
  501. alSourcePlay(source);
  502. paused = false;
  503. }
  504. }
  505. void Source::rewindAtomic()
  506. {
  507. if (valid && type == TYPE_STATIC)
  508. {
  509. alSourceRewind(source);
  510. if (!paused)
  511. alSourcePlay(source);
  512. }
  513. else if (valid && type == TYPE_STREAM)
  514. {
  515. bool waspaused = paused;
  516. decoder->rewind();
  517. // Because we still have old data
  518. // from before the seek in the buffers
  519. // let's empty them.
  520. stopAtomic();
  521. playAtomic();
  522. if (waspaused)
  523. pauseAtomic();
  524. offsetSamples = 0;
  525. offsetSeconds = 0;
  526. }
  527. else if (type == TYPE_STREAM)
  528. {
  529. decoder->rewind();
  530. offsetSamples = 0;
  531. offsetSeconds = 0;
  532. }
  533. }
  534. void Source::reset()
  535. {
  536. alSourcefv(source, AL_POSITION, position);
  537. alSourcefv(source, AL_VELOCITY, velocity);
  538. alSourcefv(source, AL_DIRECTION, direction);
  539. alSourcef(source, AL_PITCH, pitch);
  540. alSourcef(source, AL_GAIN, volume);
  541. alSourcef(source, AL_MIN_GAIN, minVolume);
  542. alSourcef(source, AL_MAX_GAIN, maxVolume);
  543. alSourcef(source, AL_REFERENCE_DISTANCE, referenceDistance);
  544. alSourcef(source, AL_ROLLOFF_FACTOR, rolloffFactor);
  545. alSourcef(source, AL_MAX_DISTANCE, maxDistance);
  546. alSourcei(source, AL_LOOPING, isStatic() && isLooping() ? AL_TRUE : AL_FALSE);
  547. alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
  548. alSourcei(source, AL_CONE_INNER_ANGLE, cone.innerAngle);
  549. alSourcei(source, AL_CONE_OUTER_ANGLE, cone.outerAngle);
  550. alSourcef(source, AL_CONE_OUTER_GAIN, cone.outerVolume);
  551. }
  552. void Source::setFloatv(float *dst, const float *src) const
  553. {
  554. dst[0] = src[0];
  555. dst[1] = src[1];
  556. dst[2] = src[2];
  557. }
  558. ALenum Source::getFormat(int channels, int bitDepth) const
  559. {
  560. if (channels == 1 && bitDepth == 8)
  561. return AL_FORMAT_MONO8;
  562. else if (channels == 1 && bitDepth == 16)
  563. return AL_FORMAT_MONO16;
  564. else if (channels == 2 && bitDepth == 8)
  565. return AL_FORMAT_STEREO8;
  566. else if (channels == 2 && bitDepth == 16)
  567. return AL_FORMAT_STEREO16;
  568. else
  569. return 0;
  570. }
  571. int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
  572. {
  573. // Get more sound data.
  574. int decoded = d->decode();
  575. decoded = decoded >= 0 ? decoded : 0;
  576. int fmt = getFormat(d->getChannels(), d->getBitDepth());
  577. if (fmt != 0)
  578. alBufferData(buffer, fmt, d->getBuffer(), decoded, d->getSampleRate());
  579. if (decoder->isFinished() && isLooping())
  580. {
  581. int queued, processed;
  582. alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
  583. alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
  584. if (queued > processed)
  585. toLoop = queued-processed;
  586. else
  587. toLoop = MAX_BUFFERS-processed;
  588. d->rewind();
  589. }
  590. if (toLoop > 0)
  591. {
  592. if (--toLoop == 0)
  593. {
  594. offsetSamples = 0;
  595. offsetSeconds = 0;
  596. }
  597. }
  598. return decoded;
  599. }
  600. bool Source::isStatic() const
  601. {
  602. return (type == TYPE_STATIC);
  603. }
  604. void Source::setMinVolume(float volume)
  605. {
  606. if (valid)
  607. {
  608. alSourcef(source, AL_MIN_GAIN, volume);
  609. }
  610. this->minVolume = volume;
  611. }
  612. float Source::getMinVolume() const
  613. {
  614. if (valid)
  615. {
  616. ALfloat f;
  617. alGetSourcef(source, AL_MIN_GAIN, &f);
  618. return f;
  619. }
  620. // In case the Source isn't playing.
  621. return this->minVolume;
  622. }
  623. void Source::setMaxVolume(float volume)
  624. {
  625. if (valid)
  626. {
  627. alSourcef(source, AL_MAX_GAIN, volume);
  628. }
  629. this->maxVolume = volume;
  630. }
  631. float Source::getMaxVolume() const
  632. {
  633. if (valid)
  634. {
  635. ALfloat f;
  636. alGetSourcef(source, AL_MAX_GAIN, &f);
  637. return f;
  638. }
  639. // In case the Source isn't playing.
  640. return this->maxVolume;
  641. }
  642. void Source::setReferenceDistance(float distance)
  643. {
  644. if (valid)
  645. {
  646. alSourcef(source, AL_REFERENCE_DISTANCE, distance);
  647. }
  648. this->referenceDistance = distance;
  649. }
  650. float Source::getReferenceDistance() const
  651. {
  652. if (valid)
  653. {
  654. ALfloat f;
  655. alGetSourcef(source, AL_REFERENCE_DISTANCE, &f);
  656. return f;
  657. }
  658. // In case the Source isn't playing.
  659. return this->referenceDistance;
  660. }
  661. void Source::setRolloffFactor(float factor)
  662. {
  663. if (valid)
  664. {
  665. alSourcef(source, AL_ROLLOFF_FACTOR, factor);
  666. }
  667. this->rolloffFactor = factor;
  668. }
  669. float Source::getRolloffFactor() const
  670. {
  671. if (valid)
  672. {
  673. ALfloat f;
  674. alGetSourcef(source, AL_ROLLOFF_FACTOR, &f);
  675. return f;
  676. }
  677. // In case the Source isn't playing.
  678. return this->rolloffFactor;
  679. }
  680. void Source::setMaxDistance(float distance)
  681. {
  682. if (valid)
  683. {
  684. alSourcef(source, AL_MAX_DISTANCE, distance);
  685. }
  686. this->maxDistance = distance;
  687. }
  688. float Source::getMaxDistance() const
  689. {
  690. if (valid)
  691. {
  692. ALfloat f;
  693. alGetSourcef(source, AL_MAX_DISTANCE, &f);
  694. return f;
  695. }
  696. // In case the Source isn't playing.
  697. return this->maxDistance;
  698. }
  699. int Source::getChannels() const
  700. {
  701. return channels;
  702. }
  703. } // openal
  704. } // audio
  705. } // love