summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad.h2
-rw-r--r--audio/decode/ad_internal.h2
-rw-r--r--audio/decode/ad_lavc.c2
-rw-r--r--audio/decode/ad_mpg123.c2
-rw-r--r--audio/decode/ad_spdif.c2
-rw-r--r--audio/out/ao_coreaudio.c5
-rw-r--r--audio/out/ao_lavc.c34
7 files changed, 28 insertions, 21 deletions
diff --git a/audio/decode/ad.h b/audio/decode/ad.h
index de1bc33aba..ff51ecbe35 100644
--- a/audio/decode/ad.h
+++ b/audio/decode/ad.h
@@ -34,7 +34,7 @@ typedef struct ad_functions
int (*preinit)(sh_audio_t *sh);
int (*init)(sh_audio_t *sh, const char *decoder);
void (*uninit)(sh_audio_t *sh);
- int (*control)(sh_audio_t *sh,int cmd,void* arg, ...);
+ int (*control)(sh_audio_t *sh, int cmd, void *arg);
int (*decode_audio)(sh_audio_t *sh, unsigned char *buffer, int minlen,
int maxlen);
} ad_functions_t;
diff --git a/audio/decode/ad_internal.h b/audio/decode/ad_internal.h
index 7eca629fca..61bf306a5e 100644
--- a/audio/decode/ad_internal.h
+++ b/audio/decode/ad_internal.h
@@ -32,7 +32,7 @@ static void add_decoders(struct mp_decoder_list *list);
static int init(sh_audio_t *sh, const char *decoder);
static int preinit(sh_audio_t *sh);
static void uninit(sh_audio_t *sh);
-static int control(sh_audio_t *sh,int cmd,void* arg, ...);
+static int control(sh_audio_t *sh, int cmd, void *arg);
static int decode_audio(sh_audio_t *sh,unsigned char *buffer,int minlen,int maxlen);
#define LIBAD_EXTERN(x) const ad_functions_t mpcodecs_ad_##x = {\
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index e8960c4941..8abc0a6035 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -338,7 +338,7 @@ static void uninit(sh_audio_t *sh)
sh->context = NULL;
}
-static int control(sh_audio_t *sh, int cmd, void *arg, ...)
+static int control(sh_audio_t *sh, int cmd, void *arg)
{
struct priv *ctx = sh->context;
switch (cmd) {
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 45538f42f6..8699013acf 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -455,7 +455,7 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, int minlen,
return bytes;
}
-static int control(sh_audio_t *sh, int cmd, void *arg, ...)
+static int control(sh_audio_t *sh, int cmd, void *arg)
{
switch (cmd) {
case ADCTRL_RESYNC_STREAM:
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index a6f41932e9..1314110062 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -273,7 +273,7 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf,
return spdif_ctx->out_buffer_len;
}
-static int control(sh_audio_t *sh, int cmd, void* arg, ...)
+static int control(sh_audio_t *sh, int cmd, void *arg)
{
unsigned char *start;
double pts;
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 6a15690074..54ff1b4915 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -1080,7 +1080,6 @@ static OSStatus RenderCallbackSPDIF( AudioDeviceID inDevice,
static int play(void* output_samples,int num_bytes,int flags)
{
int wrote, b_digital;
- SInt32 exit_reason;
// Check whether we need to reset the digital output stream.
if (ao->b_digital && ao->b_stream_format_changed)
@@ -1110,10 +1109,6 @@ static int play(void* output_samples,int num_bytes,int flags)
wrote=write_buffer(output_samples, num_bytes);
audio_resume();
- do {
- exit_reason = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
- } while (exit_reason == kCFRunLoopRunHandledSource);
-
return wrote;
}
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 0fda9a2b3a..d8185a8dca 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -309,6 +309,7 @@ static void fill_with_padding(void *buf, int cnt, int sz, const void *padding)
// close audio device
static int encode(struct ao *ao, double apts, void *data);
+static int play(struct ao *ao, void *data, int len, int flags);
static void uninit(struct ao *ao, bool cut_audio)
{
struct priv *ac = ao->priv;
@@ -321,21 +322,31 @@ static void uninit(struct ao *ao, bool cut_audio)
}
if (ac->buffer) {
- double pts = ao->pts + ac->offset / (double) ao->samplerate;
if (ao->buffer.len > 0) {
- void *paddingbuf = talloc_size(ao,
- ac->aframesize * ao->channels.num * ac->sample_size);
+ // TRICK: append aframesize-1 samples to the end, then play() will
+ // encode all it can
+ size_t extralen =
+ (ac->aframesize - 1) * ao->channels.num * ac->sample_size;
+ void *paddingbuf = talloc_size(ao, ao->buffer.len + extralen);
memcpy(paddingbuf, ao->buffer.start, ao->buffer.len);
fill_with_padding((char *) paddingbuf + ao->buffer.len,
- (ac->aframesize * ao->channels.num * ac->sample_size -
- ao->buffer.len) / ac->sample_size,
- ac->sample_size, ac->sample_padding);
- encode(ao, pts, paddingbuf);
- pts += ac->aframesize / (double) ao->samplerate;
+ extralen / ac->sample_size,
+ ac->sample_size, ac->sample_padding);
+ int written = play(ao, paddingbuf, ao->buffer.len + extralen, 0);
+ if (written < ao->buffer.len) {
+ mp_msg(MSGT_ENCODE, MSGL_ERR,
+ "ao-lavc: did not write enough data at the end\n");
+ }
talloc_free(paddingbuf);
ao->buffer.len = 0;
}
- while (encode(ao, pts, NULL) > 0) ;
+
+ double outpts = ac->expected_next_pts;
+ if (!ectx->options->rawts && ectx->options->copyts)
+ outpts += ectx->discontinuity_pts_offset;
+ outpts += encode_lavc_getoffset(ectx, ac->stream);
+
+ while (encode(ao, outpts, NULL) > 0) ;
}
ao->priv = NULL;
@@ -494,11 +505,12 @@ static int play(struct ao *ao, void *data, int len, int flags)
if (!encode_lavc_start(ectx)) {
mp_msg(MSGT_ENCODE, MSGL_WARN,
- "ao-lavc: not ready yet for encoding audio\n");
+ "ao-lavc: not ready yet for encoding audio\n");
return 0;
}
if (pts == MP_NOPTS_VALUE) {
- mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: frame without pts, please report; synthesizing pts instead\n");
+ mp_msg(MSGT_ENCODE, MSGL_WARN,
+ "ao-lavc: frame without pts, please report; synthesizing pts instead\n");
// synthesize pts from previous expected next pts
pts = ac->expected_next_pts;
}