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
+23 -24
View File
@@ -21,6 +21,10 @@
#ifndef LOVE_AUDIO_AUDIO_H
#define LOVE_AUDIO_AUDIO_H
// STL
#include <vector>
// LOVE
#include "common/Module.h"
#include "common/StringMap.h"
#include "Source.h"
@@ -90,12 +94,24 @@ public:
**/
virtual bool play(Source *source) = 0;
/**
* Play the specified Sources.
* @param sources The Sources to play.
**/
virtual bool play(const std::vector<Source*> &sources) = 0;
/**
* Stops playback on the specified source.
* @param source The source on which to stop the playback.
**/
virtual void stop(Source *source) = 0;
/**
* Stops playback on the specified sources.
* @param sources The sources on which to stop the playback.
**/
virtual void stop(const std::vector<Source*> &sources) = 0;
/**
* Stops all playing audio.
**/
@@ -107,33 +123,16 @@ public:
**/
virtual void pause(Source *source) = 0;
/**
* Pauses playback on the specified sources.
* @param sources The sources on which to pause the playback.
**/
virtual void pause(const std::vector<Source*> &sources) = 0;
/**
* Pauses all audio.
**/
virtual void pause() = 0;
/**
* Resumes playback on the specified source.
* @param source The source on which to resume the playback.
**/
virtual void resume(Source *source) = 0;
/**
* Resumes all audio.
**/
virtual void resume() = 0;
/**
* Rewinds the specified source. Whatever is playing on this
* source gets rewound to the start.
* @param source The source to rewind.
**/
virtual void rewind(Source *source) = 0;
/**
* Rewinds all playing audio.
**/
virtual void rewind() = 0;
virtual std::vector<Source*> pause() = 0;
/**
* Sets the master volume, where 0.0f is min (off) and 1.0f is max.