mpv: Update from 0.29.1 to 0.30.0

This commit is contained in:
Tom Yan 2019-10-30 02:05:31 +08:00
parent a60fb05042
commit 744cb1d056
6 changed files with 24 additions and 324 deletions

View File

@ -1,123 +0,0 @@
diff --git a/options/options.c b/options/options.c
index 1f9f1ee2c0..a98f03a7da 100644
--- a/options/options.c
+++ b/options/options.c
@@ -740,7 +740,7 @@ const m_option_t mp_opts[] = {
OPT_SUBSTRUCT("", macos_opts, macos_conf, 0),
#endif
-#if HAVE_ANDROID
+#if HAVE_EGL_ANDROID
OPT_SUBSTRUCT("", android_opts, android_conf, 0),
#endif
diff --git a/osdep/io.h b/osdep/io.h
index e0d6284baa..7e8a267541 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -33,7 +33,7 @@
#include <glob.h>
#endif
-#ifdef __ANDROID__
+#if HAVE_ANDROID
# include <unistd.h>
# include <stdio.h>
@@ -58,7 +58,7 @@ static inline int mp_fseeko(FILE* fp, off64_t offset, int whence) {
}
#define fseeko(f,p,w) mp_fseeko((f), (p), (w))
-#endif // __ANDROID__
+#endif // HAVE_ANDROID
#ifndef O_BINARY
#define O_BINARY 0
diff --git a/osdep/posix-spawn.h b/osdep/posix-spawn.h
index d8bf874c98..fdba50149c 100644
--- a/osdep/posix-spawn.h
+++ b/osdep/posix-spawn.h
@@ -19,7 +19,9 @@
#pragma once
-#ifdef __ANDROID__
+#include "config.h"
+
+#if HAVE_ANDROID
// posix_spawn(p) does not exist at all on Android
#include "osdep/android/posix-spawn.h"
#else
diff --git a/osdep/strnlen.h b/osdep/strnlen.h
index 0a971d0ab0..e66932a89a 100644
--- a/osdep/strnlen.h
+++ b/osdep/strnlen.h
@@ -20,7 +20,9 @@
#ifndef MP_OSDEP_STRNLEN
#define MP_OSDEP_STRNLEN
-#ifdef __ANDROID__
+#include "config.h"
+
+#if HAVE_ANDROID
// strnlen is broken on current android ndk, see https://code.google.com/p/android/issues/detail?id=74741
#include "osdep/android/strnlen.h"
#define strnlen freebsd_strnlen
diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
index 36f9c2dad5..7964e12623 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -62,7 +62,7 @@ static const struct ra_ctx_fns *contexts[] = {
#endif
// OpenGL contexts:
-#if HAVE_ANDROID
+#if HAVE_EGL_ANDROID
&ra_ctx_android,
#endif
#if HAVE_RPI
diff --git a/wscript b/wscript
index e0dbeab322..eaeb091a52 100644
--- a/wscript
+++ b/wscript
@@ -155,11 +155,13 @@ main_dependencies = [
}, {
'name': '--android',
'desc': 'Android environment',
- 'func': compose_checks(
- check_statement('android/api-level.h', '(void)__ANDROID__'), # arbitrary android-specific header
- check_cc(lib="android"),
- check_cc(lib="EGL"),
- )
+ 'func': check_statement('android/api-level.h', '(void)__ANDROID__'), # arbitrary android-specific header
+ }, {
+ 'name': '--egl-android',
+ 'desc': 'Android EGL support',
+ 'deps': 'android',
+ 'groups': [ 'gl' ],
+ 'func': check_cc(lib=['android', 'EGL']),
}, {
'name': 'posix-or-mingw',
'desc': 'development environment',
@@ -804,7 +806,7 @@ video_output_features = [
'name': 'egl-helpers',
'desc': 'EGL helper functions',
'deps': 'egl-x11 || mali-fbdev || rpi || gl-wayland || egl-drm || ' +
- 'egl-angle-win32 || android',
+ 'egl-angle-win32 || egl-android',
'func': check_true
}
]
diff --git a/wscript_build.py b/wscript_build.py
index 4d974fd9c3..35b16856ea 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -442,7 +442,7 @@ def build(ctx):
( "video/out/opengl/angle_dynamic.c", "egl-angle" ),
( "video/out/opengl/common.c", "gl" ),
( "video/out/opengl/context.c", "gl" ),
- ( "video/out/opengl/context_android.c", "android" ),
+ ( "video/out/opengl/context_android.c", "egl-android" ),
( "video/out/opengl/context_angle.c", "egl-angle-win32" ),
( "video/out/opengl/context_cocoa.c", "gl-cocoa" ),
( "video/out/opengl/context_drm_egl.c", "egl-drm" ),

View File

@ -1,10 +1,9 @@
TERMUX_PKG_HOMEPAGE=https://mpv.io/
TERMUX_PKG_DESCRIPTION="Command-line media player"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_VERSION=0.29.1
TERMUX_PKG_REVISION=11
TERMUX_PKG_VERSION=0.30.0
TERMUX_PKG_SRCURL=https://github.com/mpv-player/mpv/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=f9f9d461d1990f9728660b4ccb0e8cb5dce29ccaa6af567bec481b79291ca623
TERMUX_PKG_SHA256=33a1bcb7e74ff17f070e754c15c52228cf44f2cefbfd8f34886ae81df214ca35
TERMUX_PKG_DEPENDS="ffmpeg, libandroid-glob, libandroid-support, libarchive, libcaca, libiconv, liblua52, pulseaudio, openal-soft, zlib"
TERMUX_PKG_RM_AFTER_INSTALL="share/icons share/applications"

View File

@ -1,115 +0,0 @@
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index ea48de892e..9f984bed52 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -35,12 +35,13 @@ struct priv {
SLBufferQueueItf buffer_queue;
SLEngineItf engine;
SLPlayItf play;
- char *buf;
- size_t buffer_size;
+ void *buf;
+ int bytes_per_enqueue;
pthread_mutex_t buffer_lock;
double audio_latency;
- int cfg_frames_per_buffer;
+ int frames_per_enqueue;
+ int buffer_size_in_ms;
};
static const int fmtmap[][2] = {
@@ -71,7 +72,6 @@ static void uninit(struct ao *ao)
free(p->buf);
p->buf = NULL;
- p->buffer_size = 0;
}
#undef DESTROY
@@ -81,26 +81,22 @@ static void buffer_callback(SLBufferQueueItf buffer_queue, void *context)
struct ao *ao = context;
struct priv *p = ao->priv;
SLresult res;
- void *data[1];
double delay;
pthread_mutex_lock(&p->buffer_lock);
- data[0] = p->buf;
- delay = 2 * p->buffer_size / (double)ao->bps;
+ delay = 2 * p->frames_per_enqueue / (double)ao->samplerate;
delay += p->audio_latency;
- ao_read_data(ao, data, p->buffer_size / ao->sstride,
+ ao_read_data(ao, &p->buf, p->frames_per_enqueue,
mp_time_us() + 1000000LL * delay);
- res = (*buffer_queue)->Enqueue(buffer_queue, p->buf, p->buffer_size);
+ res = (*buffer_queue)->Enqueue(buffer_queue, p->buf, p->bytes_per_enqueue);
if (res != SL_RESULT_SUCCESS)
MP_ERR(ao, "Failed to Enqueue: %d\n", res);
pthread_mutex_unlock(&p->buffer_lock);
}
-#define DEFAULT_BUFFER_SIZE_MS 250
-
#define CHK(stmt) \
{ \
SLresult res = stmt; \
@@ -155,17 +151,35 @@ static int init(struct ao *ao)
// samplesPerSec is misnamed, actually it's samples per ms
pcm.samplesPerSec = ao->samplerate * 1000;
- if (p->cfg_frames_per_buffer)
- ao->device_buffer = p->cfg_frames_per_buffer;
- else
- ao->device_buffer = ao->samplerate * DEFAULT_BUFFER_SIZE_MS / 1000;
- p->buffer_size = ao->device_buffer * ao->channels.num *
+ if (p->buffer_size_in_ms) {
+ ao->device_buffer = ao->samplerate * p->buffer_size_in_ms / 1000;
+ // As the purpose of buffer_size_in_ms is to request a specific
+ // soft buffer size:
+ ao->def_buffer = 0;
+ }
+
+ // But it does not make sense if it is smaller than the enqueue size:
+ if (p->frames_per_enqueue) {
+ ao->device_buffer = MPMAX(ao->device_buffer, p->frames_per_enqueue);
+ } else {
+ if (ao->device_buffer) {
+ p->frames_per_enqueue = ao->device_buffer;
+ } else if (ao->def_buffer) {
+ p->frames_per_enqueue = ao->def_buffer * ao->samplerate;
+ } else {
+ MP_ERR(ao, "Enqueue size is not set and can neither be derived\n");
+ goto error;
+ }
+ }
+
+ p->bytes_per_enqueue = p->frames_per_enqueue * ao->channels.num *
af_fmt_to_bytes(ao->format);
- p->buf = calloc(1, p->buffer_size);
+ p->buf = calloc(1, p->bytes_per_enqueue);
if (!p->buf) {
MP_ERR(ao, "Failed to allocate device buffer\n");
goto error;
}
+
int r = pthread_mutex_init(&p->buffer_lock, NULL);
if (r) {
MP_ERR(ao, "Failed to initialize the mutex: %d\n", r);
@@ -248,8 +262,12 @@ const struct ao_driver audio_out_opensles = {
.resume = resume,
.priv_size = sizeof(struct priv),
+ .priv_defaults = &(const struct priv) {
+ .buffer_size_in_ms = 250,
+ },
.options = (const struct m_option[]) {
- OPT_INTRANGE("frames-per-buffer", cfg_frames_per_buffer, 0, 1, 96000),
+ OPT_INTRANGE("frames-per-enqueue", frames_per_enqueue, 0, 1, 96000),
+ OPT_INTRANGE("buffer-size-in-ms", buffer_size_in_ms, 0, 0, 500),
{0}
},
.options_prefix = "opensles",

View File

@ -1,70 +0,0 @@
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index ea48de892e..f3082a9aa6 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -43,12 +43,6 @@ struct priv {
int cfg_frames_per_buffer;
};
-static const int fmtmap[][2] = {
- { AF_FORMAT_U8, SL_PCMSAMPLEFORMAT_FIXED_8 },
- { AF_FORMAT_S16, SL_PCMSAMPLEFORMAT_FIXED_16 },
- { 0 }
-};
-
#define DESTROY(thing) \
if (p->thing) { \
(*p->thing)->Destroy(p->thing); \
@@ -115,7 +109,7 @@ static int init(struct ao *ao)
struct priv *p = ao->priv;
SLDataLocator_BufferQueue locator_buffer_queue;
SLDataLocator_OutputMix locator_output_mix;
- SLDataFormat_PCM pcm;
+ SLAndroidDataFormat_PCM_EX pcm;
SLDataSource audio_source;
SLDataSink audio_sink;
@@ -131,29 +125,23 @@ static int init(struct ao *ao)
locator_buffer_queue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
locator_buffer_queue.numBuffers = 1;
- pcm.formatType = SL_DATAFORMAT_PCM;
- pcm.numChannels = 2;
-
- int compatible_formats[AF_FORMAT_COUNT + 1];
- af_get_best_sample_formats(ao->format, compatible_formats);
- pcm.bitsPerSample = 0;
- for (int i = 0; compatible_formats[i] && !pcm.bitsPerSample; ++i)
- for (int j = 0; fmtmap[j][0]; ++j)
- if (compatible_formats[i] == fmtmap[j][0]) {
- ao->format = fmtmap[j][0];
- pcm.bitsPerSample = fmtmap[j][1];
- break;
- }
- if (!pcm.bitsPerSample) {
- MP_ERR(ao, "Cannot find compatible audio format\n");
- goto error;
+ if (af_fmt_is_int(ao->format)) {
+ // Be future-proof
+ if (af_fmt_to_bytes(ao->format) > 2)
+ ao->format = AF_FORMAT_S32;
+ else
+ ao->format = af_fmt_from_planar(ao->format);
+ pcm.formatType = SL_DATAFORMAT_PCM;
+ } else {
+ ao->format = AF_FORMAT_FLOAT;
+ pcm.formatType = SL_ANDROID_DATAFORMAT_PCM_EX;
+ pcm.representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
}
- pcm.containerSize = 8 * af_fmt_to_bytes(ao->format);
+ pcm.numChannels = ao->channels.num;
+ pcm.containerSize = pcm.bitsPerSample = 8 * af_fmt_to_bytes(ao->format);
pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
pcm.endianness = SL_BYTEORDER_LITTLEENDIAN;
-
- // samplesPerSec is misnamed, actually it's samples per ms
- pcm.samplesPerSec = ao->samplerate * 1000;
+ pcm.sampleRate = ao->samplerate * 1000;
if (p->cfg_frames_per_buffer)
ao->device_buffer = p->cfg_frames_per_buffer;

View File

@ -1,13 +0,0 @@
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index ea48de892e..2e637adf82 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -129,7 +129,7 @@ static int init(struct ao *ao)
CHK((*p->output_mix)->Realize(p->output_mix, SL_BOOLEAN_FALSE));
locator_buffer_queue.locatorType = SL_DATALOCATOR_BUFFERQUEUE;
- locator_buffer_queue.numBuffers = 1;
+ locator_buffer_queue.numBuffers = 8;
pcm.formatType = SL_DATAFORMAT_PCM;
pcm.numChannels = 2;

View File

@ -0,0 +1,22 @@
diff --git a/wscript b/wscript
index 830201a6bd..543a30feea 100644
--- a/wscript
+++ b/wscript
@@ -154,7 +154,7 @@ main_dependencies = [
}, {
'name': '--android',
'desc': 'Android environment',
- 'func': check_statement('android/api-level.h', '(void)__ANDROID__'), # arbitrary android-specific header
+ 'func': check_cc(lib=['android']),
}, {
'name': '--tvos',
'desc': 'tvOS environment',
@@ -167,7 +167,7 @@ main_dependencies = [
'desc': 'Android EGL support',
'deps': 'android',
'groups': [ 'gl' ],
- 'func': check_cc(lib=['android', 'EGL']),
+ 'func': check_cc(lib=['EGL']),
}, {
'name': 'posix-or-mingw',
'desc': 'development environment',