[vlc-devel] [PATCH v2 11/11] macosx: use vlc_actions_do
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Aug 9 18:16:35 CEST 2017
From: Thomas Guillem <thomas at gllm.fr>
---
modules/gui/macosx/VLCCoreInteraction.m | 84 ++++++++++++---------------------
1 file changed, 31 insertions(+), 53 deletions(-)
diff --git a/modules/gui/macosx/VLCCoreInteraction.m b/modules/gui/macosx/VLCCoreInteraction.m
index ab78b045da..af003b989b 100644
--- a/modules/gui/macosx/VLCCoreInteraction.m
+++ b/modules/gui/macosx/VLCCoreInteraction.m
@@ -148,41 +148,37 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
- (void)pause
{
- playlist_t *p_playlist = pl_Get(getIntf());
-
- playlist_Pause(p_playlist);
+ vlc_actions_do(getIntf(), ACTIONID_PAUSE, true, 0);
}
- (void)stop
{
- playlist_Stop(pl_Get(getIntf()));
+ vlc_actions_do(getIntf(), ACTIONID_STOP, true, 0);
}
- (void)faster
{
- var_TriggerCallback(pl_Get(getIntf()), "rate-faster");
+ vlc_actions_do(getIntf(), ACTIONID_FASTER, true, 0);
}
- (void)slower
{
- var_TriggerCallback(pl_Get(getIntf()), "rate-slower");
+ vlc_actions_do(getIntf(), ACTIONID_SLOWER, true, 0);
+}
}
- (void)normalSpeed
{
- var_SetFloat(pl_Get(getIntf()), "rate", 1.);
+ vlc_actions_do(getIntf(), ACTIONID_RATE_NORMAL, true, 0);
+}
}
- (void)toggleRecord
{
- intf_thread_t *p_intf = getIntf();
- if (!p_intf)
- return;
-
input_thread_t * p_input;
p_input = pl_CurrentInput(p_intf);
if (p_input) {
- var_ToggleBool(p_input, "record");
+ vlc_actions_do(getIntf(), ACTIONID_RECORD, true, 1, p_input);
vlc_object_release(p_input);
}
}
@@ -232,12 +228,12 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
- (void)previous
{
- playlist_Prev(pl_Get(getIntf()));
+ vlc_actions_do(getIntf(), ACTIONID_PREV, true, 0);
}
- (void)next
{
- playlist_Next(pl_Get(getIntf()));
+ vlc_actions_do(getIntf(), ACTIONID_NEXT, true, 0);
}
- (int)durationOfCurrentPlaylistItem
@@ -342,60 +338,53 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
[self backwardShort];
}
-- (void)jumpWithValue:(char *)p_value forward:(BOOL)b_value
+- (void)jumpWithValue:(vlc_action_id_t)i_action
{
input_thread_t *p_input = pl_CurrentInput(getIntf());
if (!p_input)
return;
-
- int i_interval = var_InheritInteger( p_input, p_value );
- if (i_interval > 0) {
- mtime_t val = CLOCK_FREQ * i_interval;
- if (!b_value)
- val = val * -1;
- var_SetInteger( p_input, "time-offset", val );
- }
+ vlc_actions_do(getIntf(), i_action, true, 1, p_input);
vlc_object_release(p_input);
}
- (void)forwardExtraShort
{
- [self jumpWithValue:"extrashort-jump-size" forward:YES];
+ [self jumpWithValue:ACTIONID_JUMP_FORWARD_EXTRASHORT];
}
- (void)backwardExtraShort
{
- [self jumpWithValue:"extrashort-jump-size" forward:NO];
+ [self jumpWithValue:ACTIONID_JUMP_BACKWARD_EXTRASHORT];
}
- (void)forwardShort
{
- [self jumpWithValue:"short-jump-size" forward:YES];
+ [self jumpWithValue:ACTIONID_JUMP_FORWARD_SHORT];
}
- (void)backwardShort
{
- [self jumpWithValue:"short-jump-size" forward:NO];
+ [self jumpWithValue:ACTIONID_JUMP_BACKWARD_SHORT];
}
- (void)forwardMedium
{
- [self jumpWithValue:"medium-jump-size" forward:YES];
+ [self jumpWithValue:ACTIONID_JUMP_FORWARD_MEDIUM];
}
- (void)backwardMedium
{
- [self jumpWithValue:"medium-jump-size" forward:NO];
+ [self jumpWithValue:ACTIONID_JUMP_BACKWARD_MEDIUM];
}
- (void)forwardLong
{
- [self jumpWithValue:"long-jump-size" forward:YES];
+ [self jumpWithValue:ACTIONID_JUMP_FORWARD_LONG];
}
- (void)backwardLong
{
- [self jumpWithValue:"long-jump-size" forward:NO];
+ [self jumpWithValue:ACTIONID_JUMP_BACKWARD_LONG];
}
- (void)shuffle
@@ -530,8 +519,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
intf_thread_t *p_intf = getIntf();
if (!p_intf)
return;
-
- playlist_VolumeUp(pl_Get(p_intf), 1, NULL);
+ vlc_actions_do(p_intf, ACTIONID_VOL_UP, true, 0);
}
- (void)volumeDown
@@ -539,8 +527,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
intf_thread_t *p_intf = getIntf();
if (!p_intf)
return;
-
- playlist_VolumeDown(pl_Get(p_intf), 1, NULL);
+ vlc_actions_do(p_intf, ACTIONID_VOL_DOWN, true, 0);
}
- (void)toggleMute
@@ -548,8 +535,7 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
intf_thread_t *p_intf = getIntf();
if (!p_intf)
return;
-
- playlist_MuteToggle(pl_Get(p_intf));
+ vlc_actions_do(p_intf, ACTIONID_VOL_MUTE, true, 0);
}
- (BOOL)mute
@@ -620,14 +606,10 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
- (void)showPosition
{
input_thread_t *p_input = pl_CurrentInput(getIntf());
- if (p_input != NULL) {
- vout_thread_t *p_vout = input_GetVout(p_input);
- if (p_vout != NULL) {
- var_SetInteger(getIntf()->obj.libvlc, "key-action", ACTIONID_POSITION);
- vlc_object_release(p_vout);
- }
- vlc_object_release(p_input);
- }
+ if (!p_input)
+ return;
+ vlc_actions_do(getIntf(), ACTIONID_POSITION, true, 1, p_input);
+ vlc_object_release(p_input);
}
#pragma mark - Drop support for files into the video, controls bar or drop box
@@ -1008,12 +990,10 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
[self backward];
break;
case kRemoteButtonVolume_Plus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
+ vlc_actions_do(p_intf, ACTIONID_VOL_UP, true, 0);
break;
case kRemoteButtonVolume_Minus_Hold:
- if (p_intf)
- var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
+ vlc_actions_do(p_intf, ACTIONID_VOL_DOWN, true, 0);
break;
}
if (b_remote_button_hold) {
@@ -1051,15 +1031,13 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
[NSSound increaseSystemVolume];
else
- if (p_intf)
- var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_UP);
+ vlc_actions_do(p_intf, ACTIONID_VOL_UP, true, 0);
break;
case kRemoteButtonVolume_Minus:
if (config_GetInt(getIntf(), "macosx-appleremote-sysvol"))
[NSSound decreaseSystemVolume];
else
- if (p_intf)
- var_SetInteger(p_intf->obj.libvlc, "key-action", ACTIONID_VOL_DOWN);
+ vlc_actions_do(p_intf, ACTIONID_VOL_DOWN, true, 0);
break;
case kRemoteButtonRight:
if (config_GetInt(getIntf(), "macosx-appleremote-prevnext"))
--
2.11.0
More information about the vlc-devel
mailing list