summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--av_log.c1
-rw-r--r--bstr.h1
-rwxr-xr-xconfigure187
-rw-r--r--input/input.c24
-rw-r--r--libmpcodecs/ad_ffmpeg.c181
-rw-r--r--libvo/cocoa_common.h6
-rw-r--r--libvo/cocoa_common.m47
-rw-r--r--libvo/gl_common.c5
-rw-r--r--libvo/gl_common.h1
-rw-r--r--libvo/video_out.c4
-rw-r--r--libvo/vo_corevideo.h87
-rw-r--r--libvo/vo_corevideo.m1317
-rw-r--r--libvo/vo_sharedbuffer.h37
-rw-r--r--libvo/vo_sharedbuffer.m277
-rw-r--r--mplayer.c34
-rw-r--r--osdep/cocoa_events.h30
-rw-r--r--osdep/cocoa_events.m137
-rw-r--r--path.c8
-rw-r--r--stream/stream_ffmpeg.c2
-rw-r--r--sub/subassconvert.c67
21 files changed, 1204 insertions, 1256 deletions
diff --git a/Makefile b/Makefile
index 34d910687f..53cbb966ae 100644
--- a/Makefile
+++ b/Makefile
@@ -100,6 +100,9 @@ SRCS_COMMON-$(LIVE555) += libmpdemux/demux_rtp.cpp \
libmpdemux/demux_rtp_codec.cpp \
stream/stream_live555.c
SRCS_COMMON-$(MACOSX_FINDER) += osdep/macosx_finder_args.m
+SRCS_COMMON-$(COCOA) += libvo/osx_common.c \
+ libvo/cocoa_common.m \
+ osdep/cocoa_events.m
SRCS_COMMON-$(MNG) += libmpdemux/demux_mng.c
SRCS_COMMON-$(MPG123) += libmpcodecs/ad_mpg123.c
@@ -439,7 +442,8 @@ SRCS_MPLAYER-$(ARTS) += libao2/ao_arts.c
SRCS_MPLAYER-$(BL) += libvo/vo_bl.c
SRCS_MPLAYER-$(CACA) += libvo/vo_caca.c
SRCS_MPLAYER-$(COREAUDIO) += libao2/ao_coreaudio.c
-SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m libvo/osx_common.c
+SRCS_MPLAYER-$(COREVIDEO) += libvo/vo_corevideo.m
+SRCS_MPLAYER-$(SHAREDBUFFER) += libvo/vo_sharedbuffer.m
SRCS_MPLAYER-$(DGA) += libvo/vo_dga.c
SRCS_MPLAYER-$(DIRECT3D) += libvo/vo_direct3d.c libvo/w32_common.c
SRCS_MPLAYER-$(DIRECTFB) += libvo/vo_directfb2.c libvo/vo_dfbmga.c
@@ -451,7 +455,6 @@ SRCS_MPLAYER-$(GGI) += libvo/vo_ggi.c
SRCS_MPLAYER-$(GIF) += libvo/vo_gif89a.c
SRCS_MPLAYER-$(GL) += libvo/gl_common.c libvo/vo_gl.c libvo/vo_gl3.c \
pnm_loader.c
-SRCS_MPLAYER-$(GL_COCOA) += libvo/cocoa_common.m
SRCS_MPLAYER-$(GL_SDL) += libvo/sdl_common.c
SRCS_MPLAYER-$(GL_WIN32) += libvo/w32_common.c
SRCS_MPLAYER-$(GL_X11) += libvo/x11_common.c
diff --git a/av_log.c b/av_log.c
index 63f8fd7dc3..4e27e98d0f 100644
--- a/av_log.c
+++ b/av_log.c
@@ -112,6 +112,7 @@ void init_libav(void)
av_log_set_callback(mp_msg_av_log_callback);
avcodec_register_all();
av_register_all();
+ avformat_network_init();
}
#define V(x) (x)>>16, (x)>>8 & 255, (x) & 255
diff --git a/bstr.h b/bstr.h
index e8a34b4f2c..688ed41771 100644
--- a/bstr.h
+++ b/bstr.h
@@ -96,7 +96,6 @@ bool bstr_case_endswith(struct bstr s, struct bstr suffix);
struct bstr bstr_strip_ext(struct bstr str);
struct bstr bstr_get_ext(struct bstr s);
-
static inline struct bstr bstr_cut(struct bstr str, int n)
{
if (n < 0) {
diff --git a/configure b/configure
index 93f4766e39..0021665824 100755
--- a/configure
+++ b/configure
@@ -435,6 +435,7 @@ Video output:
--disable-yuv4mpeg disable yuv4mpeg video output [enable]
--disable-corevideo disable CoreVideo video output [autodetect]
--disable-cocoa disable Cocoa OpenGL backend [autodetect]
+ --disable-sharedbuffer disable OSX shared buffer video output [autodetect]
Audio output:
--disable-alsa disable ALSA audio output [autodetect]
@@ -692,6 +693,7 @@ _qtx=auto
_coreaudio=auto
_corevideo=auto
_cocoa=auto
+_sharedbuffer=auto
quicktime=auto
_macosx_finder=no
_macosx_bundle=auto
@@ -1121,6 +1123,8 @@ for ac_option do
--disable-corevideo) _corevideo=no ;;
--enable-cocoa) _cocoa=yes ;;
--disable-cocoa) _cocoa=no ;;
+ --enable-sharedbuffer) _sharedbuffer=yes ;;
+ --disable-sharedbuffer) _sharedbuffer=no ;;
--enable-macosx-finder) _macosx_finder=yes ;;
--disable-macosx-finder) _macosx_finder=no ;;
--enable-macosx-bundle) _macosx_bundle=yes ;;
@@ -2311,23 +2315,22 @@ fi # if darwin && test "$cc_vendor" = "gnu" ; then
# Checking for CFLAGS
_install_strip="-s"
if test "$_profile" != "" || test "$_debug" != "" ; then
- CFLAGS="-O2 $_march $_mcpu $_pipe $_debug $_profile"
- WARNFLAGS="-W -Wall"
_install_strip=
-elif test -z "$CFLAGS" ; then
+fi
+if test -z "$CFLAGS" ; then
if test "$cc_vendor" = "intel" ; then
- CFLAGS="-O2 $_march $_mcpu $_pipe -fomit-frame-pointer"
+ CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -fomit-frame-pointer"
WARNFLAGS="-wd167 -wd556 -wd144"
elif test "$cc_vendor" = "sun" ; then
- CFLAGS="-O2 $_march $_mcpu $_pipe -xc99 -xregs=frameptr"
+ CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -xc99 -xregs=frameptr"
elif test "$cc_vendor" = "clang"; then
- CFLAGS="-O2 $_march $_pipe"
+ CFLAGS="-O2 $_debug $_profile $_march $_pipe"
WARNFLAGS="-Wall -Wno-switch-enum -Wno-logical-op-parentheses -Wpointer-arith -Wundef -Wno-pointer-sign -Wmissing-prototypes"
ERRORFLAGS="-Werror=implicit-function-declaration"
elif test "$cc_vendor" != "gnu" ; then
- CFLAGS="-O2 $_march $_mcpu $_pipe"
+ CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe"
else
- CFLAGS="-O2 $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
+ CFLAGS="-O2 $_debug $_profile $_march $_mcpu $_pipe -ffast-math -fomit-frame-pointer"
WARNFLAGS="-Wall -Wno-switch -Wno-parentheses -Wpointer-arith -Wredundant-decls"
ERRORFLAGS="-Werror-implicit-function-declaration"
extra_ldflags="$extra_ldflags -ffast-math"
@@ -3794,6 +3797,87 @@ fi
echores "$_directfb"
+if darwin; then
+
+echocheck "QuickTime"
+if test "$quicktime" = auto ; then
+ quicktime=no
+ statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes
+fi
+if test "$quicktime" = yes ; then
+ extra_ldflags="$extra_ldflags -framework QuickTime"
+ def_quicktime='#define CONFIG_QUICKTIME 1'
+else
+ def_quicktime='#undef CONFIG_QUICKTIME'
+fi
+echores $quicktime
+
+echocheck "Cocoa"
+if test "$_cocoa" = auto ; then
+ cat > $TMPC <<EOF
+#include <CoreServices/CoreServices.h>
+#include <OpenGL/OpenGL.h>
+int main(void) {
+ NSApplicationLoad();
+}
+EOF
+ _cocoa=no
+ cc_check -framework Cocoa -framework OpenGL && _cocoa=yes
+fi
+if test "$_cocoa" = yes ; then
+ libs_mplayer="$libs_mplayer -framework Cocoa -framework OpenGL"
+ def_cocoa='#define CONFIG_COCOA 1'
+else
+ def_cocoa='#undef CONFIG_COCOA'
+fi
+echores "$_cocoa"
+
+echocheck "CoreVideo"
+if test "$_cocoa" = yes && test "$_corevideo" = auto ; then
+ cat > $TMPC <<EOF
+#include <QuartzCore/CoreVideo.h>
+int main(void) { return 0; }
+EOF
+ _corevideo=no
+ cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes
+fi
+if test "$_corevideo" = yes ; then
+ vomodules="corevideo $vomodules"
+ libs_mplayer="$libs_mplayer -framework QuartzCore"
+ def_corevideo='#define CONFIG_COREVIDEO 1'
+else
+ novomodules="corevideo $novomodules"
+ def_corevideo='#undef CONFIG_COREVIDEO'
+fi
+echores "$_corevideo"
+
+echocheck "SharedBuffer"
+if test "$_sharedbuffer" = auto ; then
+ cat > $TMPC <<EOF
+int main(void) {
+ NSApplicationLoad();
+}
+EOF
+ _sharedbuffer=no
+ cc_check -framework Cocoa && _sharedbuffer=yes
+fi
+if test "$_sharedbuffer" = yes ; then
+ vomodules="sharedbuffer $vomodules"
+ libs_mplayer="$libs_mplayer -framework Cocoa"
+ def_sharedbuffer='#define CONFIG_SHAREDBUFFER 1'
+else
+ novomodules="sharedbuffer $novomodules"
+ def_sharedbuffer='#undef CONFIG_SHAREDBUFFER'
+fi
+echores "$_sharedbuffer"
+
+depends_on_application_services(){
+ test "$_corevideo" = yes
+}
+
+fi #if darwin
+
+
echocheck "X11 headers presence"
_x11_headers="no"
res_comment="check if the dev(el) packages are installed"
@@ -3829,7 +3913,20 @@ if test "$_x11" = auto && test "$_x11_headers" = yes ; then
_ld_tmp="$I -lXext -lX11 $_ld_pthread"
fi
statement_check X11/Xutil.h 'XCreateWindow(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)' $_ld_tmp &&
- libs_mplayer="$libs_mplayer $_ld_tmp" && _x11=yes && break
+ _x11=yes
+ # Check that there aren't conflicting headers between ApplicationServices
+ # and X11. On versions of Mac OSX prior to 10.7 the deprecated QuickDraw API
+ # is included by -framework ApplicationServices and clashes with the X11
+ # definition of the "Cursor" type.
+ if darwin && depends_on_application_services && test "$_x11" = yes ; then
+ _x11=no
+ header_check_broken ApplicationServices/ApplicationServices.h \
+ X11/Xutil.h $_ld_tmp && _x11=yes
+ fi
+ if test "$_x11" = yes ; then
+ libs_mplayer="$libs_mplayer $_ld_tmp"
+ break
+ fi
done
fi
if test "$_x11" = yes ; then
@@ -4174,66 +4271,6 @@ else
fi
-if darwin; then
-
-echocheck "QuickTime"
-if test "$quicktime" = auto ; then
- quicktime=no
- statement_check QuickTime/QuickTime.h 'ImageDescription *desc; EnterMovies(); ExitMovies()' -framework QuickTime && quicktime=yes
-fi
-if test "$quicktime" = yes ; then
- extra_ldflags="$extra_ldflags -framework QuickTime"
- def_quicktime='#define CONFIG_QUICKTIME 1'
-else
- def_quicktime='#undef CONFIG_QUICKTIME'
-fi
-echores $quicktime
-
-echocheck "CoreVideo"
-if test "$_corevideo" = auto ; then
- cat > $TMPC <<EOF
-#include <Carbon/Carbon.h>
-#include <CoreServices/CoreServices.h>
-#include <OpenGL/OpenGL.h>
-#include <QuartzCore/CoreVideo.h>
-int main(void) { return 0; }
-EOF
- _corevideo=no
- cc_check -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL && _corevideo=yes
-fi
-if test "$_corevideo" = yes ; then
- vomodules="corevideo $vomodules"
- libs_mplayer="$libs_mplayer -framework Carbon -framework Cocoa -framework QuartzCore -framework OpenGL"
- def_corevideo='#define CONFIG_COREVIDEO 1'
-else
- novomodules="corevideo $novomodules"
- def_corevideo='#undef CONFIG_COREVIDEO'
-fi
-echores "$_corevideo"
-
-echocheck "Cocoa"
-if test "$_gl" = no ; then
- # if _gl is not enabled there is no point to add potentially unused linker flags
- _cocoa=no
-fi
-if test "$_cocoa" = auto ; then
- cat > $TMPC <<EOF
-#include <CoreServices/CoreServices.h>
-#include <OpenGL/OpenGL.h>
-#include <QuartzCore/CoreVideo.h>
-int main(void) { return 0; }
-EOF
- _cocoa=no
- cc_check -framework Cocoa -framework QuartzCore -framework OpenGL && _cocoa=yes
-fi
-if test "$_cocoa" = yes ; then
- libs_mplayer="$libs_mplayer -framework Cocoa -framework QuartzCore -framework OpenGL"
-fi
-echores "$_cocoa"
-
-fi #if darwin
-
-
echocheck "PNG support"
if test "$_png" = auto ; then
_png=no
@@ -4525,7 +4562,7 @@ int main(int argc, char *argv[]) {
EOF
_gl=no
for _ld_tmp in "" -lGL "-lGL -lXdamage" "-lGL $_ld_pthread" ; do
- if test "$_cocoa" != yes && cc_check $_ld_tmp $_ld_lm ; then
+ if cc_check $_ld_tmp $_ld_lm ; then
_gl=yes
_gl_x11=yes
libs_mplayer="$libs_mplayer $_ld_tmp $_ld_dl"
@@ -6349,8 +6386,10 @@ BL = $_bl
CACA = $_caca
CDDA = $_cdda
CDDB = $_cddb
+COCOA = $_cocoa
COREAUDIO = $_coreaudio
COREVIDEO = $_corevideo
+SHAREDBUFFER = $_sharedbuffer
DGA = $_dga
DIRECT3D = $_direct3d
DIRECTFB = $_directfb
@@ -6752,6 +6791,8 @@ $def_aa
$def_bl
$def_caca
$def_corevideo
+$def_cocoa
+$def_sharedbuffer
$def_dga
$def_dga1
$def_dga2
@@ -6829,12 +6870,8 @@ $def_yasm
#define HAVE_INLINE_ASM 1
-/* Use these registers in FFmpeg x86 inline asm. No proper detection yet. */
-#ifndef MP_DEBUG
+/* Use these registers in x86 inline asm. No proper detection yet. */
#define HAVE_EBP_AVAILABLE 1
-#else
-#define HAVE_EBP_AVAILABLE 0
-#endif
#endif /* MPLAYER_CONFIG_H */
EOF
diff --git a/input/input.c b/input/input.c
index 57b2d21f9d..ffa69043f8 100644
--- a/input/input.c
+++ b/input/input.c
@@ -59,6 +59,10 @@
#include "ar.h"
+#ifdef CONFIG_COCOA
+#include "osdep/cocoa_events.h"
+#endif
+
#define MP_MAX_KEY_DOWN 32
struct cmd_bind {
@@ -1454,7 +1458,7 @@ static void read_events(struct input_ctx *ictx, int time)
* every source until it's known to be empty. Instead we use this wrapper
* to run select() again.
*/
-static void read_all_events(struct input_ctx *ictx, int time)
+static void read_all_fd_events(struct input_ctx *ictx, int time)
{
while (1) {
read_events(ictx, time);
@@ -1464,6 +1468,15 @@ static void read_all_events(struct input_ctx *ictx, int time)
}
}
+static void read_all_events(struct input_ctx *ictx, int time)
+{
+#ifdef CONFIG_COCOA
+ cocoa_events_read_all_events(ictx, time);
+#else
+ read_all_fd_events(ictx, time);
+#endif
+}
+
int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd)
{
ictx->got_new_events = true;
@@ -1761,6 +1774,10 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf)
.wakeup_pipe = {-1, -1},
};
+#ifdef CONFIG_COCOA
+ cocoa_events_init(ictx, read_all_fd_events);
+#endif
+
#ifndef __MINGW32__
long ret = pipe(ictx->wakeup_pipe);
for (int i = 0; i < 2 && ret >= 0; i++) {
@@ -1866,11 +1883,16 @@ struct input_ctx *mp_input_init(struct input_conf *input_conf)
mp_tmsg(MSGT_INPUT, MSGL_ERR, "Can't open %s: %s\n",
input_conf->in_file, strerror(errno));
}
+
return ictx;
}
void mp_input_uninit(struct input_ctx *ictx)
{
+#ifdef CONFIG_COCOA
+ cocoa_events_uninit();
+#endif
+
if (!ictx)
return;
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index 4a5062ba00..0bfc5e5f0a 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -49,12 +49,15 @@ LIBAD_EXTERN(ffmpeg)
struct priv {
AVCodecContext *avctx;
- int previous_data_left;
+ AVFrame *avframe;
+ char *output;
+ int output_left;
+ int unitsize;
+ int previous_data_left; // input demuxer packet data
};
static int preinit(sh_audio_t *sh)
{
- sh->audio_out_minsize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
return 1;
}
@@ -74,6 +77,7 @@ static int setup_format(sh_audio_t *sh_audio,
case AV_SAMPLE_FMT_FLT: sample_format = AF_FORMAT_FLOAT_NE; break;
default:
mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Unsupported sample format\n");
+ sample_format = AF_FORMAT_UNKNOWN;
}
bool broken_srate = false;
@@ -122,6 +126,7 @@ static int init(sh_audio_t *sh_audio)
sh_audio->context = ctx;
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
+ ctx->avframe = avcodec_alloc_frame();
// Always try to set - option only exists for AC3 at the moment
av_opt_set_double(lavc_context, "drc_scale", opts->drc_level,
@@ -223,6 +228,7 @@ static void uninit(sh_audio_t *sh)
av_freep(&lavc_context->extradata);
av_freep(&lavc_context);
}
+ av_free(ctx->avframe);
talloc_free(ctx);
sh->context = NULL;
}
@@ -235,86 +241,123 @@ static int control(sh_audio_t *sh, int cmd, void *arg, ...)
avcodec_flush_buffers(ctx->avctx);
ds_clear_parser(sh->ds);
ctx->previous_data_left = 0;
+ ctx->output_left = 0;
return CONTROL_TRUE;
}
return CONTROL_UNKNOWN;
}
+static int decode_new_packet(struct sh_audio *sh)
+{
+ struct priv *priv = sh->context;
+ AVCodecContext *avctx = priv->avctx;
+ double pts = MP_NOPTS_VALUE;
+ int insize;
+ bool packet_already_used = priv->previous_data_left;
+ struct demux_packet *mpkt = ds_get_packet2(sh->ds,
+ priv->previous_data_left);
+ unsigned char *start;
+ if (!mpkt) {
+ assert(!priv->previous_data_left);
+ start = NULL;
+ insize = 0;
+ ds_parse(sh->ds, &start, &insize, pts, 0);
+ if (insize <= 0)
+ return -1; // error or EOF
+ } else {
+ assert(mpkt->len >= priv->previous_data_left);
+ if (!priv->previous_data_left) {
+ priv->previous_data_left = mpkt->len;
+ pts = mpkt->pts;
+ }
+ insize = priv->previous_data_left;
+ start = mpkt->buffer + mpkt->len - priv->previous_data_left;
+ int consumed = ds_parse(sh->ds, &start, &insize, pts, 0);
+ priv->previous_data_left -= consumed;
+ }
+
+ AVPacket pkt;
+ av_init_packet(&pkt);
+ pkt.data = start;
+ pkt.size = insize;
+ if (mpkt && mpkt->avpacket) {
+ pkt.side_data = mpkt->avpacket->side_data;
+ pkt.side_data_elems = mpkt->avpacket->side_data_elems;
+ }
+ if (pts != MP_NOPTS_VALUE && !packet_already_used) {
+ sh->pts = pts;
+ sh->pts_bytes = 0;
+ }
+ int got_frame = 0;
+ int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
+ // LATM may need many packets to find mux info
+ if (ret == AVERROR(EAGAIN))
+ return 0;
+ if (ret < 0) {
+ mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n");
+ return -1;
+ }
+ if (!sh->parser)
+ priv->previous_data_left += insize - ret;
+ if (!got_frame)
+ return 0;
+ /* An error is reported later from output format checking, but make
+ * sure we don't crash by overreading first plane. */
+ if (av_sample_fmt_is_planar(avctx->sample_fmt) && avctx->channels > 1)
+ return 0;
+ uint64_t unitsize = (uint64_t)av_get_bytes_per_sample(avctx->sample_fmt) *
+ avctx->channels;
+ if (unitsize > 100000)
+ abort();
+ priv->unitsize = unitsize;
+ uint64_t output_left = unitsize * priv->avframe->nb_samples;
+ if (output_left > 500000000)
+ abort();
+ priv->output_left = output_left;
+ priv->output = priv->avframe->data[0];
+ mp_dbg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d \n", insize,
+ priv->output_left);
+ return 0;
+}
+
+
static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen,
int maxlen)
{
- struct priv *ctx = sh_audio->context;
- AVCodecContext *avctx = ctx->avctx;
+ struct priv *priv = sh_audio->context;
+ AVCodecContext *avctx = priv->avctx;
- unsigned char *start = NULL;
- int y, len = -1;
+ int len = -1;
while (len < minlen) {
- AVPacket pkt;
- int len2 = maxlen;
- double pts = MP_NOPTS_VALUE;
- int x;
- bool packet_already_used = ctx->previous_data_left;
- struct demux_packet *mpkt = ds_get_packet2(sh_audio->ds,
- ctx->previous_data_left);
- if (!mpkt) {
- assert(!ctx->previous_data_left);
- start = NULL;
- x = 0;
- ds_parse(sh_audio->ds, &start, &x, pts, 0);
- if (x <= 0)
- break; // error
- } else {
- assert(mpkt->len >= ctx->previous_data_left);
- if (!ctx->previous_data_left) {
- ctx->previous_data_left = mpkt->len;
- pts = mpkt->pts;
- }
- x = ctx->previous_data_left;
- start = mpkt->buffer + mpkt->len - ctx->previous_data_left;
- int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0);
- ctx->previous_data_left -= consumed;
- }
- av_init_packet(&pkt);
- pkt.data = start;
- pkt.size = x;
- if (mpkt && mpkt->avpacket) {
- pkt.side_data = mpkt->avpacket->side_data;
- pkt.side_data_elems = mpkt->avpacket->side_data_elems;
- }
- if (pts != MP_NOPTS_VALUE && !packet_already_used) {
- sh_audio->pts = pts;
- sh_audio->pts_bytes = 0;
- }
- y = avcodec_decode_audio3(avctx, (int16_t *)buf, &len2, &pkt);
- // LATM may need many packets to find mux info
- if (y == AVERROR(EAGAIN))
+ if (!priv->output_left) {
+ if (decode_new_packet(sh_audio) < 0)
+ break;
continue;
- if (y < 0) {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "lavc_audio: error\n");
- break;
- }
- if (!sh_audio->parser)
- ctx->previous_data_left += x - y;
- if (len2 > 0) {
- if (avctx->channels >= 5) {
- int samplesize = av_get_bytes_per_sample(avctx->sample_fmt);
- reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
- AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
- avctx->channels,
- len2 / samplesize, samplesize);
- }
- if (len < 0)
- len = len2;
- else
- len += len2;
- buf += len2;
- maxlen -= len2;
- sh_audio->pts_bytes += len2;
}
- mp_dbg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d \n", y, len2);
-
if (setup_format(sh_audio, avctx))
- break;
+ return len;
+ int size = (minlen - len + priv->unitsize - 1);
+ size -= size % priv->unitsize;
+ size = FFMIN(size, priv->output_left);
+ if (size > maxlen)
+ abort();
+ memcpy(buf, priv->output, size);
+ priv->output += size;
+ priv->output_left -= size;
+ if (avctx->channels >= 5) {
+ int samplesize = av_get_bytes_per_sample(avctx->sample_fmt);
+ reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
+ AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
+ avctx->channels,
+ size / samplesize, samplesize);
+ }
+ if (len < 0)
+ len = size;
+ else
+ len += size;
+ buf += size;
+ maxlen -= size;
+ sh_audio->pts_bytes += size;
}
return len;
}
diff --git a/libvo/cocoa_common.h b/libvo/cocoa_common.h
index d47ac51500..1a2ec7bd75 100644
--- a/libvo/cocoa_common.h
+++ b/libvo/cocoa_common.h
@@ -22,6 +22,9 @@
#include "video_out.h"
+bool vo_cocoa_gui_running(void);
+void *vo_cocoa_glgetaddr(const char *s);
+
int vo_cocoa_init(struct vo *vo);
void vo_cocoa_uninit(struct vo *vo);
@@ -40,4 +43,7 @@ void vo_cocoa_ontop(struct vo *vo);
// returns an int to conform to the gl extensions from other platforms
int vo_cocoa_swap_interval(int enabled);
+void *vo_cocoa_cgl_context(void);
+void *vo_cocoa_cgl_pixel_format(void);
+
#endif /* MPLAYER_COCOA_COMMON_H */
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m
index e8ef278b1e..66f4cd3937 100644
--- a/libvo/cocoa_common.m
+++ b/libvo/cocoa_common.m
@@ -21,6 +21,8 @@
#import <OpenGL/OpenGL.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreServices/CoreServices.h> // for CGDisplayHideCursor and Gestalt
+#include <dlfcn.h>
+
#include "cocoa_common.h"
#include "options.h"
@@ -66,6 +68,7 @@ struct vo_cocoa_state {
NSAutoreleasePool *pool;
GLMPlayerWindow *window;
NSOpenGLContext *glContext;
+ NSOpenGLPixelFormat *pixelFormat;
NSSize current_video_size;
NSSize previous_video_size;
@@ -125,6 +128,24 @@ struct vo_cocoa_state *vo_cocoa_init_state(void)
return s;
}
+bool vo_cocoa_gui_running(void)
+{
+ return !!s;
+}
+
+void *vo_cocoa_glgetaddr(const char *s)
+{
+ void *ret = NULL;
+ void *handle = dlopen(
+ "/System/Library/Frameworks/OpenGL.framework/OpenGL",
+ RTLD_LAZY | RTLD_LOCAL);
+ if (!handle)
+ return NULL;
+ ret = dlsym(handle, s);
+ dlclose(handle);
+ return ret;
+}
+
int vo_cocoa_init(struct vo *vo)
{
s = vo_cocoa_init_state();
@@ -140,6 +161,8 @@ int vo_cocoa_init(struct vo *vo)
void vo_cocoa_uninit(struct vo *vo)
{
CGDisplayShowCursor(kCGDirectMainDisplay);
+ [NSApp setPresentationOptions:NSApplicationPresentationDefault];
+
[s->window release];
s->window = nil;
[s->glContext release];
@@ -148,6 +171,7 @@ void vo_cocoa_uninit(struct vo *vo)
s->pool = nil;
talloc_free(s);
+ s = nil;
}
void update_screen_info(void)
@@ -232,8 +256,8 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width,
attr[i++] = (NSOpenGLPixelFormatAttribute)16; // 16 bit depth buffer
attr[i] = (NSOpenGLPixelFormatAttribute)0;
- NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
- s->glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+ s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
+ s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil];
create_menu();
@@ -365,6 +389,16 @@ int vo_cocoa_swap_interval(int enabled)
return 0;
}
+void *vo_cocoa_cgl_context(void)
+{
+ return [s->glContext CGLContextObj];
+}
+
+void *vo_cocoa_cgl_pixel_format(void)
+{
+ return [s->pixelFormat CGLPixelFormatObj];
+}
+
void create_menu()
{
NSMenu *menu;
@@ -565,18 +599,19 @@ bool is_lion_or_better(void)
- (void) applicationWillBecomeActive:(NSNotification *)aNotification
{
if (vo_fs) {
+ [s->window makeKeyAndOrderFront:s->window];
[s->window setLevel:s->fullscreen_window_level];
- [NSApp setPresentationOptions:NSApplicationPresentationHideDock|NSApplicationPresentationHideMenuBar];
- [s->window makeKeyAndOrderFront:nil];
- [NSApp activateIgnoringOtherApps: YES];
+ [NSApp setPresentationOptions:NSApplicationPresentationHideDock|
+ NSApplicationPresentationHideMenuBar];
}
}
- (void) applicationWillResignActive:(NSNotification *)aNotification
{
if (vo_fs) {
- [s->window setLevel:s->windowed_window_level];
[NSApp setPresentationOptions:NSApplicationPresentationDefault];
+ [s->window setLevel:s->windowed_window_level];
+ [s->window orderBack:s->window];
}
}
diff --git a/libvo/gl_common.c b/libvo/gl_common.c
index 9a8de977b2..cd618b443c 100644
--- a/libvo/gl_common.c
+++ b/libvo/gl_common.c
@@ -330,6 +330,7 @@ static const extfunc_desc_t extfuncs[] = {
DEF_FUNC_DESC(Color4ub),
DEF_FUNC_DESC(Color4f),
DEF_FUNC_DESC(TexCoord2f),
+ DEF_FUNC_DESC(TexCoord2fv),
DEF_FUNC_DESC(Vertex2f),
DEF_FUNC_DESC(VertexPointer),
DEF_FUNC_DESC(ColorPointer),
@@ -1725,14 +1726,14 @@ static int create_window_cocoa_gl3(struct MPGLContext *ctx, int gl_flags,
uint32_t d_height, uint32_t flags)
{
int rv = vo_cocoa_create_window(ctx->vo, d_width, d_height, flags, 1);
- getFunctions(ctx->gl, (void *)getdladdr, NULL, true);
+ getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL, true);
return rv;
}
static int setGlWindow_cocoa(MPGLContext *ctx)
{
vo_cocoa_change_attributes(ctx->vo);
- getFunctions(ctx->gl, (void *)getdladdr, NULL, false);
+ getFunctions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL, false);
if (!ctx->gl->SwapInterval)
ctx->gl->SwapInterval = vo_cocoa_swap_interval;
return SET_WINDOW_OK;
diff --git a/libvo/gl_common.h b/libvo/gl_common.h
index 8091886b1f..f0e5912dd9 100644
--- a/libvo/gl_common.h
+++ b/libvo/gl_common.h
@@ -260,6 +260,7 @@ struct GL {
void (GLAPIENTRY *TexParameterf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY *TexParameterfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY *TexCoord2f)(GLfloat, GLfloat);
+ void (GLAPIENTRY *TexCoord2fv)(const GLfloat *);
void (GLAPIENTRY *Vertex2f)(GLfloat, GLfloat);
void (GLAPIENTRY *GetIntegerv)(GLenum, GLint *);
void (GLAPIENTRY *GetBooleanv)(GLenum, GLboolean *);
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 9b06794c61..aea62ce0ab 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -118,6 +118,7 @@ extern struct vo_driver video_out_tdfx_vid;
extern struct vo_driver video_out_xvr100;
extern struct vo_driver video_out_tga;
extern struct vo_driver video_out_corevideo;
+extern struct vo_driver video_out_sharedbuffer;
extern struct vo_driver video_out_pnm;
extern struct vo_driver video_out_md5sum;
@@ -221,6 +222,9 @@ const struct vo_driver *video_out_drivers[] =
#endif
&video_out_null,
// should not be auto-selected
+#ifdef CONFIG_SHAREDBUFFER
+ &video_out_sharedbuffer,
+#endif
#ifdef CONFIG_DIRECTFB
// vo directfb can call exit() if initialization fails
&video_out_directfb,
diff --git a/libvo/vo_corevideo.h b/libvo/vo_corevideo.h
index 926399053f..cfb86621bc 100644
--- a/libvo/vo_corevideo.h
+++ b/libvo/vo_corevideo.h
@@ -23,93 +23,6 @@
#ifndef MPLAYER_VO_COREVIDEO_H
#define MPLAYER_VO_COREVIDEO_H
-#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
-#import <Carbon/Carbon.h>
-
-// MPlayer OS X VO Protocol
-@protocol MPlayerOSXVOProto
-- (int) startWithWidth: (bycopy int)width
- withHeight: (bycopy int)height
- withBytes: (bycopy int)bytes
- withAspect: (bycopy int)aspect;
-- (void) stop;
-- (void) render;
-- (void) toggleFullscreen;
-- (void) ontop;
-@end
-
-@interface MPlayerOpenGLView : NSOpenGLView
-{
- //Cocoa
- NSWindow *window;
-
- //CoreVideo
- CVPixelBufferRef frameBuffers[2];
- CVOpenGLTextureCacheRef textureCache;
- CVOpenGLTextureRef texture;
- NSRect textureFrame;
-
- GLfloat lowerLeft[2];
- GLfloat lowerRight[2];
- GLfloat upperRight[2];
- GLfloat upperLeft[2];
-
- BOOL mouseHide;
-
- //menu command id
- NSMenuItem *kHalfScreenCmd;
- NSMenuItem *kNormalScreenCmd;
- NSMenuItem *kDoubleScreenCmd;
- NSMenuItem *kFullScreenCmd;
- NSMenuItem *kKeepAspectCmd;
- NSMenuItem *kAspectOrgCmd;
- NSMenuItem *kAspectFullCmd;
- NSMenuItem *kAspectWideCmd;
- NSMenuItem *kPanScanCmd;
-
- //timestamps for disabling screensaver and mouse hiding
- int lastMouseHide;
- int lastScreensaverUpdate;
-@public
- float winSizeMult;
-}
-