New audio playback API

Instead of having three states, stopped, paused and playing, now there's only
two states: paused and playing.

This means resume() is gone, as is isStopped(), and isPaused() has become
isPlaying(). stop() now pauses and rewinds, whereas pause() only pauses.
rewind() has been removed, and should either be replaced with stop() or
seek(0).

The same has been applied to the functions in the love.audio module, except they
get some extra magic:

- love.audio.pause() now returns a table/list of Source objects, which contains
  only the sources it has just paused. This means you can then later restart
  only them, instead of everything (as before).
- love.audio.play/pause/stop now have variants that take a list of Source
  objects, and it starts or stops them all at the same time, this means calling
  play(srcA, srcB) should mean srcA and srcB are much more (but possibly not
  exactly) synchronised than they were with play(srcA); play(srcB).

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2016-04-02 17:38:19 +02:00
parent 2e51a976db
commit f76879c6b7
15 changed files with 356 additions and 375 deletions
+12 -7
View File
@@ -28,6 +28,9 @@
#include "sound/SoundData.h"
#include "sound/Decoder.h"
// STL
#include <vector>
// OpenAL
#ifdef LOVE_APPLE_USE_FRAMEWORKS
#ifdef LOVE_IOS
@@ -90,10 +93,7 @@ public:
virtual bool play();
virtual void stop();
virtual void pause();
virtual void resume();
virtual void rewind();
virtual bool isStopped() const;
virtual bool isPaused() const;
virtual bool isPlaying() const;
virtual bool isFinished() const;
virtual bool update();
virtual void setPitch(float pitch);
@@ -130,11 +130,17 @@ public:
virtual float getMaxDistance() const;
virtual int getChannels() const;
bool playAtomic();
void prepareAtomic();
void teardownAtomic();
bool playAtomic(ALuint source);
void stopAtomic();
void pauseAtomic();
void resumeAtomic();
void rewindAtomic();
static bool playAtomic(const std::vector<love::audio::Source*> &sources, const std::vector<ALuint> &ids, const std::vector<char> &wasPlaying);
static void stopAtomic(const std::vector<love::audio::Source*> &sources);
static void pauseAtomic(const std::vector<love::audio::Source*> &sources);
private:
@@ -169,7 +175,6 @@ private:
float direction[3];
bool relative;
bool looping;
bool paused;
float minVolume;
float maxVolume;
float referenceDistance;