summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/out/ao_pcm.c')
-rw-r--r--audio/out/ao_pcm.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c
index 7d2656be49..4097aa3bd6 100644
--- a/audio/out/ao_pcm.c
+++ b/audio/out/ao_pcm.c
@@ -19,8 +19,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,8 +42,8 @@
struct priv {
char *outputfilename;
- int waveheader;
- int append;
+ bool waveheader;
+ bool append;
uint64_t data_length;
FILE *fp;
};
@@ -162,6 +160,7 @@ static int init(struct ao *ao)
if (priv->waveheader) // Reserve space for wave header
write_wave_header(ao, priv->fp, 0x7ffff000);
ao->untimed = true;
+ ao->device_buffer = 1 << 16;
return 0;
}
@@ -193,19 +192,36 @@ static void uninit(struct ao *ao)
fclose(priv->fp);
}
-static int get_space(struct ao *ao)
-{
- return 65536;
-}
-
-static int play(struct ao *ao, void **data, int samples, int flags)
+static bool audio_write(struct ao *ao, void **data, int samples)
{
struct priv *priv = ao->priv;
int len = samples * ao->sstride;
fwrite(data[0], len, 1, priv->fp);
priv->data_length += len;
- return samples;
+
+ return true;
+}
+
+static void get_state(struct ao *ao, struct mp_pcm_state *state)
+{
+ state->free_samples = ao->device_buffer;
+ state->queued_samples = 0;
+ state->delay = 0;
+}
+
+static bool set_pause(struct ao *ao, bool paused)
+{
+ return true; // signal support so common code doesn't write silence
+}
+
+static void start(struct ao *ao)
+{
+ // we use data immediately
+}
+
+static void reset(struct ao *ao)
+{
}
#define OPT_BASE_STRUCT struct priv
@@ -215,15 +231,17 @@ const struct ao_driver audio_out_pcm = {
.name = "pcm",
.init = init,
.uninit = uninit,
- .get_space = get_space,
- .play = play,
- .reports_underruns = true, // not a thing
+ .get_state = get_state,
+ .set_pause = set_pause,
+ .write = audio_write,
+ .start = start,
+ .reset = reset,
.priv_size = sizeof(struct priv),
- .priv_defaults = &(const struct priv) { .waveheader = 1 },
+ .priv_defaults = &(const struct priv) { .waveheader = true },
.options = (const struct m_option[]) {
{"file", OPT_STRING(outputfilename), .flags = M_OPT_FILE},
- {"waveheader", OPT_FLAG(waveheader)},
- {"append", OPT_FLAG(append)},
+ {"waveheader", OPT_BOOL(waveheader)},
+ {"append", OPT_BOOL(append)},
{0}
},
.options_prefix = "ao-pcm",