summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/out/ao_wasapi0.c33
-rw-r--r--core/m_option.h9
-rw-r--r--core/mp_msg.c2
-rw-r--r--demux/demux_mkv.c4
-rw-r--r--stream/cache.c2
-rw-r--r--sub/sd_ass.c2
-rw-r--r--video/out/cocoa_common.m128
-rw-r--r--video/out/vo_direct3d.c3
8 files changed, 117 insertions, 66 deletions
diff --git a/audio/out/ao_wasapi0.c b/audio/out/ao_wasapi0.c
index a45ca829e5..11303ddde1 100644
--- a/audio/out/ao_wasapi0.c
+++ b/audio/out/ao_wasapi0.c
@@ -19,6 +19,7 @@
#define _WIN32_WINNT 0x600
#include <stdlib.h>
+#include <inttypes.h>
#include <process.h>
#include <initguid.h>
#include <audioclient.h>
@@ -33,6 +34,10 @@
#include "core/mp_ring.h"
#include "ao.h"
+#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
+#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001
+#endif
+
#define RING_BUFFER_COUNT 64
/* 20 millisecond buffer? */
@@ -236,7 +241,7 @@ static HRESULT check_support(struct wasapi0_state *state,
EnterCriticalSection(&state->print_lock);
mp_msg(
MSGT_AO, MSGL_ERR,
- "IAudioClient::IsFormatSupported failed with %s (%d at %ldHz %dchannels, channelmask = %lx)\n",
+ "IAudioClient::IsFormatSupported failed with %s (%d at %"PRId32"Hz %dchannels, channelmask = %"PRIx32")\n",
explain_err(
hr), wformat->Format.wBitsPerSample,
wformat->Format.nSamplesPerSec,
@@ -366,7 +371,7 @@ reinit:
EnterCriticalSection(&state->print_lock);
mp_msg(MSGT_AO, MSGL_V,
"ao-wasapi: fix_format OK, using %lld byte buffer block size!\n",
- state->buffer_block_size);
+ (long long) state->buffer_block_size);
LeaveCriticalSection(&state->print_lock);
return 0;
exit_label:
@@ -425,15 +430,10 @@ exit_label:
static void thread_pause(wasapi0_state *state)
{
+ state->is_playing = 0;
IAudioClient_Stop(state->pAudioClient);
}
-static void thread_reset(wasapi0_state *state)
-{
- IAudioClient_Stop(state->pAudioClient);
- IAudioClient_Reset(state->pAudioClient);
-}
-
/* force_feed - feed in even if available data is smaller than required buffer, to clear the buffer */
static void thread_feed(wasapi0_state *state,int force_feed)
{
@@ -456,6 +456,7 @@ static void thread_feed(wasapi0_state *state,int force_feed)
state->bufferFrameCount,
AUDCLNT_BUFFERFLAGS_SILENT);
EXIT_ON_ERROR(hr)
+ return;
}
hr = IAudioRenderClient_ReleaseBuffer(state->pRenderClient,
state->bufferFrameCount, 0);
@@ -463,7 +464,7 @@ static void thread_feed(wasapi0_state *state,int force_feed)
return;
exit_label:
EnterCriticalSection(&state->print_lock);
- mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: thread_feed fails with %lx!\n", hr);
+ mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: thread_feed fails with %"PRIx32"!\n", hr);
LeaveCriticalSection(&state->print_lock);
return;
}
@@ -471,10 +472,20 @@ exit_label:
static void thread_play(wasapi0_state *state)
{
thread_feed(state, 0);
+ state->is_playing = 1;
IAudioClient_Start(state->pAudioClient);
return;
}
+static void thread_reset(wasapi0_state *state)
+{
+ IAudioClient_Stop(state->pAudioClient);
+ IAudioClient_Reset(state->pAudioClient);
+ if (state->is_playing) {
+ thread_play(state);
+ }
+}
+
static void thread_getVol(wasapi0_state *state)
{
IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolume,
@@ -515,7 +526,7 @@ static void thread_uninit(wasapi0_state *state)
if (state->hTask)
state->VistaBlob.pAvRevertMmThreadCharacteristics(state->hTask);
CoUninitialize();
- _endthreadex(0);
+ ExitThread(0);
}
static unsigned int __stdcall ThreadLoop(void *lpParameter)
@@ -670,7 +681,7 @@ static int init(struct ao *ao, char *params)
return -1;
}
state->init_ret = -1;
- state->threadLoop = (HANDLE)_beginthreadex(NULL, 0, &ThreadLoop, ao, 0, NULL);
+ state->threadLoop = (HANDLE)CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL);
if (!state->threadLoop) {
/* failed to init thread */
mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi0: fail to create thread!\n");
diff --git a/core/m_option.h b/core/m_option.h
index 6a8bcfbf1a..c1aac93a82 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -129,14 +129,6 @@ extern const m_option_type_t m_option_type_obj_settings_list;
*/
extern const m_option_type_t m_option_type_custom_url;
-// Extra definition needed for \ref m_option_type_obj_params options.
-typedef struct {
- // Field descriptions.
- const struct m_struct_st *desc;
- // Field separator to use.
- char separator;
-} m_obj_params_t;
-
struct m_opt_choice_alternatives {
char *name;
int value;
@@ -170,7 +162,6 @@ struct m_sub_options {
#define CONF_TYPE_AFMT (&m_option_type_afmt)
#define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list)
#define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url)
-#define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params)
#define CONF_TYPE_TIME (&m_option_type_time)
#define CONF_TYPE_CHOICE (&m_option_type_choice)
#define CONF_TYPE_INT_PAIR (&m_option_type_intpair)
diff --git a/core/mp_msg.c b/core/mp_msg.c
index 1f5847e97c..ac59169fc2 100644
--- a/core/mp_msg.c
+++ b/core/mp_msg.c
@@ -77,7 +77,7 @@ static int mp_msg_docolor(void) {
void mp_msg_init(void){
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO cinfo;
- long cmode = 0;
+ DWORD cmode = 0;
GetConsoleMode(hSTDOUT, &cmode);
cmode |= (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
SetConsoleMode(hSTDOUT, cmode);
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index a73c594371..408e69390a 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -2044,7 +2044,7 @@ static void handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
apk_usize);
/* Put timestamp only on packets that correspond to original
* audio packets in file */
- dp->pts = (x * apk_usize % w) ? 0 :
+ dp->pts = (x * apk_usize % w) ? MP_NOPTS_VALUE :
track->audio_timestamp[x * apk_usize / w];
dp->pos = track->audio_filepos; // all equal
dp->keyframe = !x; // Mark first packet as keyframe
@@ -2054,7 +2054,7 @@ static void handle_realaudio(demuxer_t *demuxer, mkv_track_t *track,
} else { // Not a codec that requires reordering
dp = new_demux_packet_from(buffer, size);
if (track->ra_pts == mkv_d->last_pts && !mkv_d->a_skip_to_keyframe)
- dp->pts = 0;
+ dp->pts = MP_NOPTS_VALUE;
else
dp->pts = mkv_d->last_pts;
track->ra_pts = mkv_d->last_pts;
diff --git a/stream/cache.c b/stream/cache.c
index 364ef68891..a60b8dd9ef 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -163,7 +163,7 @@ static int cache_wakeup_and_wait(struct priv *s, double *retry_time)
return CACHE_INTERRUPTED;
// Print a "more severe" warning after waiting 1 second and no new data
- if ((*retry_time) * CACHE_WAIT_TIME >= 1.0) {
+ if ((*retry_time) >= 1.0) {
mp_msg(MSGT_CACHE, MSGL_ERR, "Cache keeps not responding.\n");
} else if (*retry_time > 0.1) {
mp_msg(MSGT_CACHE, MSGL_WARN,
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 464a995e23..7395f1bea6 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -373,13 +373,13 @@ static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts)
{
struct MPOpts *opts = sd->opts;
struct sd_ass_priv *ctx = sd->priv;
- ASS_Track *track = ctx->ass_track;
enum mp_csp csp = 0;
enum mp_csp_levels levels = 0;
if (opts->ass_vsfilter_color_compat == 0) // "no"
return;
bool force_601 = opts->ass_vsfilter_color_compat == 3;
#if LIBASS_VERSION >= 0x01020000
+ ASS_Track *track = ctx->ass_track;
static const int ass_csp[] = {
[YCBCR_BT601_TV] = MP_CSP_BT_601,
[YCBCR_BT601_PC] = MP_CSP_BT_601,
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index bfa5c768b2..4679eaf4a5 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -31,6 +31,7 @@
#include "vo.h"
#include "aspect.h"
+#include "core/input/input.h"
#include "talloc.h"
#include "core/mp_msg.h"
@@ -51,8 +52,10 @@
@end
@interface GLMPlayerOpenGLView : NSView
+@property(nonatomic, retain) NSTrackingArea *tracker;
@property(nonatomic, assign) struct vo *videoOutput;
-- (BOOL)containsCurrentMouseLocation;
+- (BOOL)containsMouseLocation;
+- (void)recalcDraggableState;
- (void)mouseEvent:(NSEvent *)theEvent;
@property(nonatomic, assign, getter=hasMouseDown) BOOL mouseDown;
@end
@@ -160,13 +163,9 @@ static void vo_cocoa_set_cursor_visibility(struct vo *vo, bool visible)
struct vo_cocoa_state *s = vo->cocoa;
if (visible) {
- // show cursor unconditionally
CGDisplayShowCursor(kCGDirectMainDisplay);
- } else if (vo->opts->fullscreen &&
- [s->view containsCurrentMouseLocation] &&
- ![s->view hasMouseDown]) {
- // only hide cursor if in fullscreen and the video view contains the
- // mouse location
+ } else if (vo->opts->fullscreen && ![s->view hasMouseDown] &&
+ [s->view containsMouseLocation]) {
CGDisplayHideCursor(kCGDirectMainDisplay);
}
}
@@ -320,7 +319,6 @@ static void create_window(struct vo *vo, uint32_t d_width, uint32_t d_height,
[s->window setRestorable:NO];
[s->window setContentView:s->view];
[s->view release];
- [s->window setAcceptsMouseMovedEvents:YES];
[s->glContext setView:s->view];
s->window.videoOutput = vo;
s->view.videoOutput = vo;
@@ -399,6 +397,7 @@ static void update_window(struct vo *vo)
}
}
+ [s->view recalcDraggableState];
cocoa_set_window_title(vo, vo_get_window_title(vo));
vo_cocoa_fullscreen(vo);
@@ -622,23 +621,32 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
}
}
+- (BOOL)isInFullScreenMode
+{
+ return (([self styleMask] & NSFullScreenWindowMask) ==
+ NSFullScreenWindowMask);
+}
+
- (void)toggleMissionControlFullScreen:(BOOL)willBeFullscreen
{
struct vo_cocoa_state *s = self.videoOutput->cocoa;
- if (willBeFullscreen) {
+ if (willBeFullscreen && ![self isInFullScreenMode]) {
[self setContentResizeIncrements:NSMakeSize(1, 1)];
- } else {
+ [self toggleFullScreen:nil];
+ }
+
+ if (!willBeFullscreen && [self isInFullScreenMode]) {
[self setContentAspectRatio:s->current_video_size];
+ [self toggleFullScreen:nil];
}
- [self toggleFullScreen:nil];
}
- (void)toggleViewFullscreen:(BOOL)willBeFullscreen
{
struct vo_cocoa_state *s = self.videoOutput->cocoa;
- if (willBeFullscreen) {
+ if (willBeFullscreen && ![s->view isInFullScreenMode]) {
NSApplicationPresentationOptions popts =
NSApplicationPresentationDefault;
@@ -660,7 +668,9 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
// sending the View fullscreen to another screen. Make it go away
// manually.
[s->window orderOut:self];
- } else {
+ }
+
+ if (!willBeFullscreen && [s->view isInFullScreenMode]) {
[s->view exitFullScreenModeWithOptions:nil];
// Show the "windowed" window again.
@@ -691,6 +701,8 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
vo_cocoa_set_cursor_visibility(self.videoOutput, true);
}
+ [s->view recalcDraggableState];
+
// Change window size if the core attempted to change it while we were in
// fullscreen. For example config() might have been called as a result of
// a new file changing the window size.
@@ -714,15 +726,6 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
return NO;
}
-- (BOOL)isMovableByWindowBackground
-{
- if (self.videoOutput) {
- return !self.videoOutput->opts->fullscreen;
- } else {
- return YES;
- }
-}
-
- (void)normalSize { [self mulSize:1.0f]; }
- (void)halfSize { [self mulSize:0.5f];}
@@ -802,44 +805,89 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
[self setContentSize:ns];
}
}
+
@end
@implementation GLMPlayerOpenGLView
+@synthesize tracker = _tracker;
@synthesize videoOutput = _video_output;
@synthesize mouseDown = _mouse_down;
-- (BOOL)acceptsFirstResponder { return YES; }
-- (BOOL)becomeFirstResponder { return YES; }
-- (BOOL)resignFirstResponder { return YES; }
+// mpv uses flipped coordinates, because X11 uses those. So let's just use them
+// as well without having to do any coordinate conversion of mouse positions.
+- (BOOL) isFlipped { return YES; }
+
+- (id)initWithFrame:(NSRect)frame {
+ if (self = [super initWithFrame:frame]) {
+ NSTrackingAreaOptions trackingOptions =
+ NSTrackingEnabledDuringMouseDrag |
+ NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
+ NSTrackingActiveInActiveApp;
+
+ self.tracker =
+ [[[NSTrackingArea alloc] initWithRect:[self bounds]
+ options:trackingOptions
+ owner:self
+ userInfo:nil] autorelease];
-- (NSPoint) mouseLocation
+ [self addTrackingArea:self.tracker];
+ }
+
+ return self;
+}
+
+- (NSPoint)mouseLocation
{
- NSPoint mLoc = [NSEvent mouseLocation];
- NSPoint wLoc = [self.window convertScreenToBase:mLoc];
+ NSPoint wLoc = [self.window mouseLocationOutsideOfEventStream];
return [self convertPoint:wLoc fromView:nil];
}
-- (BOOL)containsCurrentMouseLocation
+- (BOOL)containsMouseLocation
{
- NSRect vF = [[self.window screen] visibleFrame];
- NSRect vFR = [self.window convertRectFromScreen:vF];
- NSRect vFRV = [self convertRect:vFR fromView:nil];
+ NSRect vF = [[self.window screen] visibleFrame];
+ NSRect vFW = [self.window convertRectFromScreen:vF];
+ NSRect vFV = [self convertRect:vFW fromView:nil];
// clip bounds to current visibleFrame
- NSRect clippedBounds = CGRectIntersection([self bounds], vFRV);
+ NSRect clippedBounds = CGRectIntersection([self bounds], vFV);
return CGRectContainsPoint(clippedBounds, [self mouseLocation]);
}
-- (void)signalMouseMovement:(NSEvent *)event
+- (BOOL)acceptsFirstResponder { return YES; }
+- (BOOL)becomeFirstResponder { return YES; }
+- (BOOL)resignFirstResponder { return YES; }
+
+- (void)recalcDraggableState
{
- if ([self containsCurrentMouseLocation]) {
+ struct vo *vo = self.videoOutput;
+ BOOL movable = NO;
+
+ if (!vo->opts->fullscreen) {
NSPoint loc = [self mouseLocation];
- loc.y = - loc.y + [self bounds].size.height;
- vo_mouse_movement(self.videoOutput, loc.x, loc.y);
+ movable = !mp_input_test_dragging(vo->input_ctx, loc.x, loc.y);
}
+
+ [self.window setMovableByWindowBackground:movable];
+}
+
+- (void)mouseEntered:(NSEvent *)event
+{
+ // do nothing!
+}
+
+- (void)mouseExited:(NSEvent *)event
+{
+ cocoa_put_key(MP_KEY_MOUSE_LEAVE);
+ vo_cocoa_set_cursor_visibility(self.videoOutput, true);
+}
+
+- (void)signalMouseMovement:(NSEvent *)event
+{
+ NSPoint p = [self convertPoint:[event locationInWindow] fromView:nil];
+ vo_mouse_movement(self.videoOutput, p.x, p.y);
}
-- (void)mouseMoved:(NSEvent *)evt { [self signalMouseMovement:evt]; }
-- (void)mouseDragged:(NSEvent *)evt { [self signalMouseMovement:evt]; }
+- (void)mouseMoved:(NSEvent *)event { [self signalMouseMovement:event]; }
+- (void)mouseDragged:(NSEvent *)event { [self signalMouseMovement:event]; }
- (void)mouseDown:(NSEvent *)evt { [self mouseEvent:evt]; }
- (void)mouseUp:(NSEvent *)evt { [self mouseEvent:evt]; }
- (void)rightMouseDown:(NSEvent *)evt { [self mouseEvent:evt]; }
@@ -940,7 +988,7 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
// The visible frame's width is smaller: dock is on left or right end
// of this method's receiver.
vF.size.width < f.size.width ||
- // The visible frame's veritical origin is bigger is smaller: dock is
+ // The visible frame's veritical origin is bigger: dock is
// on the bottom of this method's receiver.
vF.origin.y > f.origin.y;
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index 6540177ad0..25d0b8f0da 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <assert.h>
#include <d3d9.h>
+#include <inttypes.h>
#include "config.h"
#include "core/options.h"
#include "core/subopt-helper.h"
@@ -290,7 +291,7 @@ static void calc_fs_rect(d3d_priv *priv)
priv->fs_panscan_rect.bottom = src_rect.y1;
mp_msg(MSGT_VO, MSGL_V,
- "<vo_direct3d>Video rectangle: t: %ld, l: %ld, r: %ld, b:%ld\n",
+ "<vo_direct3d>Video rectangle: t: %"PRId32", l: %"PRId32", r: %"PRId32", b:%"PRId32"\n",
priv->fs_movie_rect.top, priv->fs_movie_rect.left,
priv->fs_movie_rect.right, priv->fs_movie_rect.bottom);
}