summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_alsa.c2
-rw-r--r--libao2/ao_coreaudio.c2
-rw-r--r--libao2/ao_dsound.c2
-rw-r--r--libao2/ao_jack.c6
-rw-r--r--libao2/ao_lavc.c68
-rw-r--r--libao2/ao_openal.c2
-rw-r--r--libao2/ao_oss.c2
-rw-r--r--libao2/ao_portaudio.c2
-rw-r--r--libao2/ao_pulse.c2
-rw-r--r--libao2/audio_out.c12
10 files changed, 62 insertions, 38 deletions
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index ba665d9b73..e0322c70d5 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -269,7 +269,7 @@ static void print_help (void)
{
mp_tmsg (MSGT_AO, MSGL_FATAL,
"\n[AO_ALSA] -ao alsa commandline help:\n"\
- "[AO_ALSA] Example: mplayer -ao alsa:device=hw=0.3\n"\
+ "[AO_ALSA] Example: mpv -ao alsa:device=hw=0.3\n"\
"[AO_ALSA] Sets first card fourth hardware device.\n\n"\
"[AO_ALSA] Options:\n"\
"[AO_ALSA] noblock\n"\
diff --git a/libao2/ao_coreaudio.c b/libao2/ao_coreaudio.c
index e78973ec04..e0d2d6d26c 100644
--- a/libao2/ao_coreaudio.c
+++ b/libao2/ao_coreaudio.c
@@ -378,7 +378,7 @@ static void print_help(void)
mp_msg(MSGT_AO, MSGL_FATAL,
"\n-ao coreaudio commandline help:\n"
- "Example: mplayer -ao coreaudio:device_id=266\n"
+ "Example: mpv -ao coreaudio:device_id=266\n"
" open Core Audio with output device ID 266.\n"
"\nOptions:\n"
" device_id\n"
diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c
index a72ed32022..4ef7029c29 100644
--- a/libao2/ao_dsound.c
+++ b/libao2/ao_dsound.c
@@ -184,7 +184,7 @@ static void print_help(void)
{
mp_msg(MSGT_AO, MSGL_FATAL,
"\n-ao dsound commandline help:\n"
- "Example: mplayer -ao dsound:device=1\n"
+ "Example: mpv -ao dsound:device=1\n"
" sets 1st device\n"
"\nOptions:\n"
" device=<device-number>\n"
diff --git a/libao2/ao_jack.c b/libao2/ao_jack.c
index 5a80bb34bb..b30f99a14e 100644
--- a/libao2/ao_jack.c
+++ b/libao2/ao_jack.c
@@ -188,8 +188,8 @@ static void print_help (void)
{
mp_msg (MSGT_AO, MSGL_FATAL,
"\n-ao jack commandline help:\n"
- "Example: mplayer -ao jack:port=myout\n"
- " connects MPlayer to the jack ports named myout\n"
+ "Example: mpv -ao jack:port=myout\n"
+ " connects mpv to the jack ports named myout\n"
"\nOptions:\n"
" port=<port name>\n"
" Connects to the given ports instead of the default physical ones\n"
@@ -228,7 +228,7 @@ static int init(int rate, int channels, int format, int flags) {
}
if (!client_name) {
client_name = malloc(40);
- sprintf(client_name, "MPlayer [%d]", getpid());
+ sprintf(client_name, "mpv [%d]", getpid());
}
if (!autostart)
open_options |= JackNoStartServer;
diff --git a/libao2/ao_lavc.c b/libao2/ao_lavc.c
index b22cd325dc..d4523f0d54 100644
--- a/libao2/ao_lavc.c
+++ b/libao2/ao_lavc.c
@@ -56,6 +56,7 @@ struct priv {
int64_t lastpts;
int sample_size;
const void *sample_padding;
+ double expected_next_pts;
AVRational worst_time_base;
int worst_time_base_is_stream;
@@ -288,7 +289,7 @@ static void fill_with_padding(void *buf, int cnt, int sz, const void *padding)
}
// close audio device
-static int encode(struct ao *ao, int ptsvalid, double apts, void *data);
+static int encode(struct ao *ao, double apts, void *data);
static void uninit(struct ao *ao, bool cut_audio)
{
struct priv *ac = ao->priv;
@@ -302,12 +303,12 @@ static void uninit(struct ao *ao, bool cut_audio)
(ac->aframesize * ao->channels * ac->sample_size
- ao->buffer.len) / ac->sample_size,
ac->sample_size, ac->sample_padding);
- encode(ao, ao->pts != MP_NOPTS_VALUE, pts, paddingbuf);
+ encode(ao, pts, paddingbuf);
pts += ac->aframesize / (double) ao->samplerate;
talloc_free(paddingbuf);
ao->buffer.len = 0;
}
- while (encode(ao, true, pts, NULL) > 0) ;
+ while (encode(ao, pts, NULL) > 0) ;
}
ao->priv = NULL;
@@ -320,7 +321,7 @@ static int get_space(struct ao *ao)
}
// must get exactly ac->aframesize amount of data
-static int encode(struct ao *ao, int ptsvalid, double apts, void *data)
+static int encode(struct ao *ao, double apts, void *data)
{
AVFrame *frame;
AVPacket packet;
@@ -338,7 +339,7 @@ static int encode(struct ao *ao, int ptsvalid, double apts, void *data)
ac->aframesize * ao->channels, ac->sample_size);
}
- if (data && ptsvalid)
+ if (data)
ectx->audio_pts_offset = realapts - apts;
av_init_packet(&packet);
@@ -354,12 +355,9 @@ static int encode(struct ao *ao, int ptsvalid, double apts, void *data)
return -1;
}
- if (ao->encode_lavc_ctx->options->rawts) {
- // raw audio pts
- frame->pts = floor(apts * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
- } else if (ectx->options->copyts) {
+ if (ectx->options->rawts || ectx->options->copyts) {
// real audio pts
- frame->pts = floor((apts + ectx->discontinuity_pts_offset) * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
+ frame->pts = floor(apts * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
} else {
// audio playback time
frame->pts = floor(realapts * ac->stream->codec->time_base.den / ac->stream->codec->time_base.num + 0.5);
@@ -385,7 +383,7 @@ static int encode(struct ao *ao, int ptsvalid, double apts, void *data)
ac->savepts = frame->pts;
}
- av_free(frame);
+ av_free(frame);
}
else
{
@@ -407,6 +405,8 @@ static int encode(struct ao *ao, int ptsvalid, double apts, void *data)
encode_lavc_write_stats(ao->encode_lavc_ctx, ac->stream);
+ packet.stream_index = ac->stream->index;
+
// Do we need this at all? Better be safe than sorry...
if (packet.pts == AV_NOPTS_VALUE) {
mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: encoder lost pts, why?\n");
@@ -449,6 +449,8 @@ static int play(struct ao *ao, void *data, int len, int flags)
int64_t ptsoffset;
void *paddingbuf = NULL;
double nextpts;
+ double pts = ao->pts;
+ double outpts;
len /= ac->sample_size * ao->channels;
@@ -456,6 +458,11 @@ static int play(struct ao *ao, void *data, int len, int flags)
mp_msg(MSGT_ENCODE, MSGL_WARN, "ao-lavc: NOTE: deferred initial audio frame (probably because video is not there yet)\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");
+ // synthesize pts from previous expected next pts
+ pts = ac->expected_next_pts;
+ }
if (ac->worst_time_base.den == 0) {
//if (ac->stream->codec->time_base.num / ac->stream->codec->time_base.den >= ac->stream->time_base.num / ac->stream->time_base.den)
@@ -549,26 +556,43 @@ static int play(struct ao *ao, void *data, int len, int flags)
}
}
- // fix the discontinuity pts offset
- if (ectx->discontinuity_pts_offset == MP_NOPTS_VALUE) {
- nextpts = ao->pts + ptsoffset / (double) ao->samplerate;
- ectx->discontinuity_pts_offset = ectx->next_in_pts - nextpts;
+ if (!ectx->options->rawts && ectx->options->copyts) {
+ // fix the discontinuity pts offset
+ nextpts = pts + ptsoffset / (double) ao->samplerate;
+ if (ectx->discontinuity_pts_offset == MP_NOPTS_VALUE) {
+ ectx->discontinuity_pts_offset = ectx->next_in_pts - nextpts;
+ }
+ else if (fabs(nextpts + ectx->discontinuity_pts_offset - ectx->next_in_pts) > 30) {
+ mp_msg(MSGT_ENCODE, MSGL_WARN,
+ "ao-lavc: detected an unexpected discontinuity (pts jumped by "
+ "%f seconds)\n",
+ nextpts + ectx->discontinuity_pts_offset - ectx->next_in_pts);
+ ectx->discontinuity_pts_offset = ectx->next_in_pts - nextpts;
+ }
+
+ outpts = pts + ectx->discontinuity_pts_offset;
}
+ else
+ outpts = pts;
while (len - bufpos >= ac->aframesize) {
- encode(ao, ao->pts != MP_NOPTS_VALUE,
- ao->pts + (bufpos + ptsoffset) / (double) ao->samplerate +
- encode_lavc_getoffset(ectx, ac->stream),
+ encode(ao,
+ outpts + (bufpos + ptsoffset) / (double) ao->samplerate + encode_lavc_getoffset(ectx, ac->stream),
(char *) data + ac->sample_size * bufpos * ao->channels);
bufpos += ac->aframesize;
}
talloc_free(paddingbuf);
- // set next allowed output pts value
- nextpts = ao->pts + ectx->discontinuity_pts_offset + (bufpos + ptsoffset) / (double) ao->samplerate;
- if (nextpts > ectx->next_in_pts)
- ectx->next_in_pts = nextpts;
+ // calculate expected pts of next audio frame
+ ac->expected_next_pts = pts + (bufpos + ptsoffset) / (double) ao->samplerate;
+
+ if (!ectx->options->rawts && ectx->options->copyts) {
+ // set next allowed output pts value
+ nextpts = ac->expected_next_pts + ectx->discontinuity_pts_offset;
+ if (nextpts > ectx->next_in_pts)
+ ectx->next_in_pts = nextpts;
+ }
return bufpos * ac->sample_size * ao->channels;
}
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index 8245f4f1d7..e5a40a769d 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -88,7 +88,7 @@ static int control(int cmd, void *arg) {
static void print_help(void) {
mp_msg(MSGT_AO, MSGL_FATAL,
"\n-ao openal commandline help:\n"
- "Example: mplayer -ao openal:device=subdevice\n"
+ "Example: mpv -ao openal:device=subdevice\n"
"\nOptions:\n"
" device=subdevice\n"
" Audio device OpenAL should use. Devices can be listed\n"
diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c
index a8d06aee00..a79361a6a8 100644
--- a/libao2/ao_oss.c
+++ b/libao2/ao_oss.c
@@ -403,7 +403,7 @@ ac3_retry:
}
free(data);
if(ao_data.buffersize==0){
- mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS]\n *** Your audio driver DOES NOT support select() ***\n Recompile MPlayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
+ mp_tmsg(MSGT_AO,MSGL_ERR,"[AO OSS]\n *** Your audio driver DOES NOT support select() ***\n Recompile mpv with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
return 0;
}
#endif
diff --git a/libao2/ao_portaudio.c b/libao2/ao_portaudio.c
index 00016ac3f3..36b08f8288 100644
--- a/libao2/ao_portaudio.c
+++ b/libao2/ao_portaudio.c
@@ -68,7 +68,7 @@ static void print_help(void)
{
mp_msg(MSGT_AO, MSGL_FATAL,
"\n-ao portaudio commandline help:\n"
- "Example: mplayer -ao portaudio:device=subdevice\n"
+ "Example: mpv -ao portaudio:device=subdevice\n"
"\nOptions:\n"
" device=subdevice\n"
" Audio device PortAudio should use. Devices can be listed\n"
diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c
index b8e4f1cbdd..1d2ebc5281 100644
--- a/libao2/ao_pulse.c
+++ b/libao2/ao_pulse.c
@@ -32,7 +32,7 @@
#include "audio_out.h"
#include "input/input.h"
-#define PULSE_CLIENT_NAME "mplayer2"
+#define PULSE_CLIENT_NAME "mpv"
#define VOL_PA2MP(v) ((v) * 100 / PA_VOLUME_UI_MAX)
#define VOL_MP2PA(v) ((v) * PA_VOLUME_UI_MAX / 100)
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index 47c18655f3..ab8e60b753 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -48,9 +48,6 @@ extern const struct ao_driver audio_out_portaudio;
static const struct ao_driver * const audio_out_drivers[] = {
// native:
-#ifdef CONFIG_DIRECTX
- &audio_out_dsound,
-#endif
#ifdef CONFIG_COREAUDIO
&audio_out_coreaudio,
#endif
@@ -66,6 +63,9 @@ static const struct ao_driver * const audio_out_drivers[] = {
#ifdef CONFIG_PORTAUDIO
&audio_out_portaudio,
#endif
+#ifdef CONFIG_DSOUND
+ &audio_out_dsound,
+#endif
// wrappers:
#ifdef CONFIG_JACK
&audio_out_jack,
@@ -73,12 +73,12 @@ static const struct ao_driver * const audio_out_drivers[] = {
#ifdef CONFIG_OPENAL
&audio_out_openal,
#endif
-#ifdef CONFIG_ENCODING
- &audio_out_lavc,
-#endif
&audio_out_null,
// should not be auto-selected:
&audio_out_pcm,
+#ifdef CONFIG_ENCODING
+ &audio_out_lavc,
+#endif
#ifdef CONFIG_RSOUND
&audio_out_rsound,
#endif