Browse Source

Audio: return self-reference from all Source APIs.

So I can e.g. do

    source
        .pause()
        .setOffsetInSeconds(1.5);

to seek the track.
pull/299/head
Vladimír Vondruš 8 years ago
parent
commit
02276d122b
  1. 6
      doc/changelog.dox
  2. 24
      src/Magnum/Audio/Source.h

6
doc/changelog.dox

@ -76,6 +76,12 @@ r<Player<T, K>>>)
@subsection changelog-latest-changes Changes and improvements
@subsubsection changelog-latest-changes-audio Audio library
- @ref Audio::Source::play(), @ref Audio::Source::pause(),
@ref Audio::Source::rewind() and @ref Audio::Source::stop() now return
a self-reference like all other methods for easier method chaining
@subsubsection changelog-latest-changes-gl GL library
- New @ref GL::Context::State::BindScratchVao state to make external OpenGL

24
src/Magnum/Audio/Source.h

@ -586,39 +586,55 @@ class MAGNUM_AUDIO_EXPORT Source {
/**
* @brief Play
* @return Reference to self (for method chaining)
*
* @see @ref play(std::initializer_list<std::reference_wrapper<Source>>),
* @ref state(), @ref pause(), @ref stop(), @ref rewind(),
* @fn_al_keyword{SourcePlay}
*/
void play() { alSourcePlay(_id); }
Source& play() {
alSourcePlay(_id);
return *this;
}
/**
* @brief Pause
* @return Reference to self (for method chaining)
*
* @see @ref pause(std::initializer_list<std::reference_wrapper<Source>>),
* @ref state(), @ref play(), @ref stop(), @ref rewind(),
* @fn_al_keyword{SourcePause}
*/
void pause() { alSourcePause(_id); }
Source& pause() {
alSourcePause(_id);
return *this;
}
/**
* @brief Stop
* @return Reference to self (for method chaining)
*
* @see @ref stop(std::initializer_list<std::reference_wrapper<Source>>),
* @ref state(), @ref play(), @ref pause(), @ref rewind(),
* @fn_al_keyword{SourceStop}
*/
void stop() { alSourceStop(_id); }
Source& stop() {
alSourceStop(_id);
return *this;
}
/**
* @brief Rewind
* @return Reference to self (for method chaining)
*
* @see @ref rewind(std::initializer_list<std::reference_wrapper<Source>>),
* @ref state(), @ref play(), @ref pause(), @ref stop(),
* @fn_al_keyword{SourceRewind}
*/
void rewind() { alSourceRewind(_id); }
Source& rewind() {
alSourceRewind(_id);
return *this;
}
/**
* @brief Whether the source is looping

Loading…
Cancel
Save