A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control except fillPendingFromDecoder(), which is synchronized for the Audio worker thread. 更多...
#include <Source.h>
Public 成员函数 | |
| Source (Audio *audio, sound::SoundData *data) | |
| Creates a static source from decoded audio (both arguments required). | |
| Source (Audio *audio, sound::Decoder *decoder, bool streaming, bool takeDecoderOwnership=false) | |
| Creates a streaming (or static-decoder) source; ownership of decoder is optional. | |
| ~Source () override | |
| void | play () |
| Starts (or resumes) playback. | |
| void | pause () |
| Pauses playback, keeping the play position. | |
| void | stop () |
| Stops playback and rewinds the play position. | |
| bool | isPlaying () const |
| void | setVolume (float v) |
| Sets source gain (clamped to >= 0). | |
| float | getVolume () const |
| void | setPitch (float p) |
| Sets playback pitch (clamped to >= 0). | |
| float | getPitch () const |
| void | setLooping (bool l) |
| Enables/disables looping. | |
| bool | isLooping () const |
| bool | seek (double seconds) |
| Seeks to a time in seconds; false when seeking is unsupported. | |
| double | tell () const |
| Current play time in seconds. | |
| double | getDuration () const |
| Total duration in seconds (0 for live/unbounded streams). | |
| void | setPosition (float x, float y, float z) |
| Sets the source position in world units. | |
| void | setVelocity (float x, float y, float z) |
| Sets the source velocity (used by OpenAL doppler). | |
| void | setDirection (float x, float y, float z) |
| Sets the source directional cone orientation. | |
| void | setRelative (bool relative) |
| Makes the source ignore the listener position (head-relative). | |
| void | setAttenuationDistances (float ref, float max) |
| Sets OpenAL reference and maximum attenuation distances. | |
| bool | isStreaming () const |
| void | pump () |
| Main thread: queues/unqueues AL buffers for a streaming source. | |
| void | fillPendingFromDecoder () |
| Called by the Audio worker thread. Internally synchronized against concurrent decoder teardown (see decoderMutex) — safe to call even if another thread is stopping/seeking/destroying this Source. | |
Public 成员函数 继承自 eve::Object | |
| Object () | |
| void | setUpdate (Object *update) |
| Update the current object with a replacement. You don't need to care about the reference to the old object since it will be automatically updated in the ref smart pointer. | |
友元 | |
| class | Audio |
额外继承的成员函数 | |
Protected 成员函数 继承自 eve::Object | |
| virtual | ~Object () |
| bool | isDirty () const |
| Object * | getUpdate () const |
| void | ref () |
| void | unref () |
Protected 属性 继承自 eve::Object | |
| Object * | update |
| unsigned | ref_count = 0 |
详细描述
A playable audio source (static buffer or streaming decoder). Not thread-safe for playback control except fillPendingFromDecoder(), which is synchronized for the Audio worker thread.
构造及析构函数说明
◆ Source() [1/2]
| eve::audio::Source::Source | ( | Audio * | audio, |
| sound::SoundData * | data | ||
| ) |
Creates a static source from decoded audio (both arguments required).
在文件 Source.cpp 第 18 行定义.
引用了 data.
◆ Source() [2/2]
| eve::audio::Source::Source | ( | Audio * | audio, |
| sound::Decoder * | decoder, | ||
| bool | streaming, | ||
| bool | takeDecoderOwnership = false |
||
| ) |
Creates a streaming (or static-decoder) source; ownership of decoder is optional.
在文件 Source.cpp 第 28 行定义.
引用了 eve::audio::kStreamBufferCount, eve::audio::Audio::notifyWorker() , 以及 eve::audio::Audio::registerStream().
◆ ~Source()
|
override |
在文件 Source.cpp 第 46 行定义.
引用了 stop() , 以及 eve::audio::Audio::unregisterSource().
成员函数说明
◆ fillPendingFromDecoder()
| void eve::audio::Source::fillPendingFromDecoder | ( | ) |
Called by the Audio worker thread. Internally synchronized against concurrent decoder teardown (see decoderMutex) — safe to call even if another thread is stopping/seeking/destroying this Source.
在文件 Source.cpp 第 250 行定义.
引用了 eve::audio::PcmChunk::bytes, eve::sound::Decoder::decode(), eve::sound::Decoder::getBuffer(), n , 以及 eve::sound::Decoder::rewind().
◆ getDuration()
| double eve::audio::Source::getDuration | ( | ) | const |
Total duration in seconds (0 for live/unbounded streams).
在文件 Source.cpp 第 229 行定义.
引用了 eve::sound::Decoder::getDuration() , 以及 eve::sound::SoundData::getDuration().
◆ getPitch()
| float eve::audio::Source::getPitch | ( | ) | const |
在文件 Source.cpp 第 191 行定义.
◆ getVolume()
| float eve::audio::Source::getVolume | ( | ) | const |
在文件 Source.cpp 第 185 行定义.
◆ isLooping()
| bool eve::audio::Source::isLooping | ( | ) | const |
在文件 Source.cpp 第 198 行定义.
◆ isPlaying()
| bool eve::audio::Source::isPlaying | ( | ) | const |
◆ isStreaming()
◆ pause()
| void eve::audio::Source::pause | ( | ) |
Pauses playback, keeping the play position.
在文件 Source.cpp 第 135 行定义.
◆ play()
| void eve::audio::Source::play | ( | ) |
◆ pump()
| void eve::audio::Source::pump | ( | ) |
Main thread: queues/unqueues AL buffers for a streaming source.
在文件 Source.cpp 第 286 行定义.
引用了 b, eve::audio::PcmChunk::bytes, isPlaying() , 以及 eve::audio::Audio::notifyWorker().
◆ seek()
| bool eve::audio::Source::seek | ( | double | seconds | ) |
Seeks to a time in seconds; false when seeking is unsupported.
在文件 Source.cpp 第 200 行定义.
引用了 eve::sound::Decoder::isSeekable(), eve::audio::Audio::notifyWorker(), eve::sound::Decoder::seek() , 以及 stop().
◆ setAttenuationDistances()
| void eve::audio::Source::setAttenuationDistances | ( | float | ref, |
| float | max | ||
| ) |
Sets OpenAL reference and maximum attenuation distances.
在文件 Source.cpp 第 244 行定义.
◆ setDirection()
| void eve::audio::Source::setDirection | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
◆ setLooping()
| void eve::audio::Source::setLooping | ( | bool | l | ) |
Enables/disables looping.
在文件 Source.cpp 第 193 行定义.
◆ setPitch()
| void eve::audio::Source::setPitch | ( | float | p | ) |
◆ setPosition()
| void eve::audio::Source::setPosition | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
◆ setRelative()
| void eve::audio::Source::setRelative | ( | bool | relative | ) |
Makes the source ignore the listener position (head-relative).
在文件 Source.cpp 第 241 行定义.
◆ setVelocity()
| void eve::audio::Source::setVelocity | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
◆ setVolume()
| void eve::audio::Source::setVolume | ( | float | v | ) |
◆ stop()
| void eve::audio::Source::stop | ( | ) |
Stops playback and rewinds the play position.
在文件 Source.cpp 第 140 行定义.
引用了 b , 以及 eve::sound::Decoder::rewind().
◆ tell()
| double eve::audio::Source::tell | ( | ) | const |
Current play time in seconds.
在文件 Source.cpp 第 223 行定义.
友元及相关函数文档
◆ Audio
该类的文档由以下文件生成:
- src/modules/audio/Source.h
- src/modules/audio/Source.cpp
Public 成员函数 继承自