Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
5d5f1713
Commit
5d5f1713
authored
Jul 02, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout_Volume*: use float rather than integer
parent
e90d7934
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
96 additions
and
92 deletions
+96
-92
configure.ac
configure.ac
+1
-1
include/vlc_aout_intf.h
include/vlc_aout_intf.h
+3
-3
lib/audio.c
lib/audio.c
+6
-13
modules/control/dbus/dbus_player.c
modules/control/dbus/dbus_player.c
+5
-7
modules/control/hotkeys.c
modules/control/hotkeys.c
+16
-22
modules/control/rc.c
modules/control/rc.c
+11
-7
modules/gui/macosx/CoreInteraction.m
modules/gui/macosx/CoreInteraction.m
+4
-3
modules/gui/macosx/MainWindow.m
modules/gui/macosx/MainWindow.m
+2
-3
modules/gui/ncurses.c
modules/gui/ncurses.c
+9
-4
modules/gui/qt4/components/controller_widget.cpp
modules/gui/qt4/components/controller_widget.cpp
+3
-6
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.cpp
+2
-2
modules/gui/skins2/vars/volume.cpp
modules/gui/skins2/vars/volume.cpp
+1
-1
modules/lua/libs/volume.c
modules/lua/libs/volume.c
+14
-9
src/audio_output/intf.c
src/audio_output/intf.c
+7
-6
src/audio_output/output.c
src/audio_output/output.c
+2
-2
src/text/strings.c
src/text/strings.c
+10
-3
No files found.
configure.ac
View file @
5d5f1713
...
@@ -628,7 +628,7 @@ AC_CHECK_FUNC(getopt_long,, [
...
@@ -628,7 +628,7 @@ AC_CHECK_FUNC(getopt_long,, [
AC_SUBST(GNUGETOPT_LIBS)
AC_SUBST(GNUGETOPT_LIBS)
AC_CHECK_LIB(m,cos,[
AC_CHECK_LIB(m,cos,[
VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph],[-lm])
VLC_ADD_LIBS([adjust wave ripple psychedelic gradient a52tofloat32 dtstofloat32 x264 goom visual panoramix rotate noise grain scene kate flac lua chorus_flanger freetype avcodec avformat access_avio swscale postproc i420_rgb faad twolame equalizer spatializer param_eq samplerate freetype mpc dmo mp4 quicktime qt4 compressor headphone_channel_mixer normvol audiobargraph_a speex mono colorthres extract ball access_imem hotkeys mosaic gaussianblur dbus x26410b hqdn3d anaglyph
oldrc ncurses
],[-lm])
LIBM="-lm"
LIBM="-lm"
], [
], [
LIBM=""
LIBM=""
...
...
include/vlc_aout_intf.h
View file @
5d5f1713
...
@@ -29,11 +29,11 @@
...
@@ -29,11 +29,11 @@
#define AOUT_VOLUME_DEFAULT 256
#define AOUT_VOLUME_DEFAULT 256
#define AOUT_VOLUME_MAX 512
#define AOUT_VOLUME_MAX 512
VLC_API
audio_volume_
t
aout_VolumeGet
(
vlc_object_t
*
);
VLC_API
floa
t
aout_VolumeGet
(
vlc_object_t
*
);
#define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
#define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
VLC_API
int
aout_VolumeSet
(
vlc_object_t
*
,
audio_volume_
t
);
VLC_API
int
aout_VolumeSet
(
vlc_object_t
*
,
floa
t
);
#define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
#define aout_VolumeSet(a, b) aout_VolumeSet(VLC_OBJECT(a), b)
VLC_API
int
aout_VolumeUp
(
vlc_object_t
*
,
int
,
audio_volume_
t
*
);
VLC_API
int
aout_VolumeUp
(
vlc_object_t
*
,
int
,
floa
t
*
);
#define aout_VolumeUp(a, b, c) aout_VolumeUp(VLC_OBJECT(a), b, c)
#define aout_VolumeUp(a, b, c) aout_VolumeUp(VLC_OBJECT(a), b, c)
#define aout_VolumeDown(a, b, c) aout_VolumeUp(a, -(b), c)
#define aout_VolumeDown(a, b, c) aout_VolumeUp(a, -(b), c)
VLC_API
int
aout_MuteToggle
(
vlc_object_t
*
);
VLC_API
int
aout_MuteToggle
(
vlc_object_t
*
);
...
...
lib/audio.c
View file @
5d5f1713
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#endif
#endif
#include <assert.h>
#include <assert.h>
#include <math.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
#include <vlc/libvlc_media.h>
...
@@ -323,29 +324,21 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
...
@@ -323,29 +324,21 @@ void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
aout_MuteSet
(
VLC_OBJECT
(
mp
),
mute
!=
0
);
aout_MuteSet
(
VLC_OBJECT
(
mp
),
mute
!=
0
);
}
}
/*****************************************************************************
* libvlc_audio_get_volume : Get the current volume
*****************************************************************************/
int
libvlc_audio_get_volume
(
libvlc_media_player_t
*
mp
)
int
libvlc_audio_get_volume
(
libvlc_media_player_t
*
mp
)
{
{
unsigned
volume
=
aout_VolumeGet
(
mp
);
float
vol
=
aout_VolumeGet
(
mp
);
return
(
vol
>=
0
.
f
)
?
lroundf
(
vol
*
100
.
f
)
:
-
1
;
return
(
volume
*
100
+
AOUT_VOLUME_DEFAULT
/
2
)
/
AOUT_VOLUME_DEFAULT
;
}
}
/*****************************************************************************
* libvlc_audio_set_volume : Set the current volume
*****************************************************************************/
int
libvlc_audio_set_volume
(
libvlc_media_player_t
*
mp
,
int
volume
)
int
libvlc_audio_set_volume
(
libvlc_media_player_t
*
mp
,
int
volume
)
{
{
volume
=
(
volume
*
AOUT_VOLUME_DEFAULT
+
50
)
/
100
;
float
vol
=
volume
/
100
.
f
;
if
(
vol
ume
<
0
||
volume
>
AOUT_VOLUME_MAX
)
if
(
vol
<
0
.
f
)
{
{
libvlc_printerr
(
"Volume out of range"
);
libvlc_printerr
(
"Volume out of range"
);
return
-
1
;
return
-
1
;
}
}
aout_VolumeSet
(
mp
,
vol
ume
);
aout_VolumeSet
(
mp
,
vol
);
return
0
;
return
0
;
}
}
...
...
modules/control/dbus/dbus_player.c
View file @
5d5f1713
...
@@ -167,11 +167,11 @@ DBUS_METHOD( Seek )
...
@@ -167,11 +167,11 @@ DBUS_METHOD( Seek )
static
void
static
void
MarshalVolume
(
intf_thread_t
*
p_intf
,
DBusMessageIter
*
container
)
MarshalVolume
(
intf_thread_t
*
p_intf
,
DBusMessageIter
*
container
)
{
{
audio_volume_t
i_vol
=
aout_VolumeGet
(
p_intf
->
p_sys
->
p_playlist
);
float
f_vol
=
aout_VolumeGet
(
p_intf
->
p_sys
->
p_playlist
);
if
(
f_vol
<
0
.
f
)
/* A volume of 1.0 represents a sensible maximum, ie: 0dB */
f_vol
=
1
.
f
;
/* ? */
double
d_vol
=
(
double
)
i_vol
/
AOUT_VOLUME_DEFAULT
;
double
d_vol
=
f_vol
;
dbus_message_iter_append_basic
(
container
,
DBUS_TYPE_DOUBLE
,
&
d_vol
);
dbus_message_iter_append_basic
(
container
,
DBUS_TYPE_DOUBLE
,
&
d_vol
);
}
}
...
@@ -204,9 +204,7 @@ DBUS_METHOD( VolumeSet )
...
@@ -204,9 +204,7 @@ DBUS_METHOD( VolumeSet )
d_dbus_vol
*=
AOUT_VOLUME_DEFAULT
;
d_dbus_vol
*=
AOUT_VOLUME_DEFAULT
;
if
(
d_dbus_vol
<
0
.
)
if
(
d_dbus_vol
<
0
.
)
d_dbus_vol
=
0
.;
d_dbus_vol
=
0
.;
if
(
d_dbus_vol
>
AOUT_VOLUME_MAX
)
aout_VolumeSet
(
PL
,
d_dbus_vol
);
d_dbus_vol
=
AOUT_VOLUME_MAX
;
aout_VolumeSet
(
PL
,
lround
(
d_dbus_vol
)
);
REPLY_SEND
;
REPLY_SEND
;
}
}
...
...
modules/control/hotkeys.c
View file @
5d5f1713
...
@@ -70,7 +70,7 @@ static int SpecialKeyEvent( vlc_object_t *, char const *,
...
@@ -70,7 +70,7 @@ static int SpecialKeyEvent( vlc_object_t *, char const *,
static
void
PlayBookmark
(
intf_thread_t
*
,
int
);
static
void
PlayBookmark
(
intf_thread_t
*
,
int
);
static
void
SetBookmark
(
intf_thread_t
*
,
int
);
static
void
SetBookmark
(
intf_thread_t
*
,
int
);
static
void
DisplayPosition
(
intf_thread_t
*
,
vout_thread_t
*
,
input_thread_t
*
);
static
void
DisplayPosition
(
intf_thread_t
*
,
vout_thread_t
*
,
input_thread_t
*
);
static
void
DisplayVolume
(
intf_thread_t
*
,
vout_thread_t
*
,
audio_volume_
t
);
static
void
DisplayVolume
(
intf_thread_t
*
,
vout_thread_t
*
,
floa
t
);
static
void
DisplayRate
(
vout_thread_t
*
,
float
);
static
void
DisplayRate
(
vout_thread_t
*
,
float
);
static
float
AdjustRateFine
(
input_thread_t
*
,
const
int
);
static
float
AdjustRateFine
(
input_thread_t
*
,
const
int
);
static
void
ClearChannels
(
intf_thread_t
*
,
vout_thread_t
*
);
static
void
ClearChannels
(
intf_thread_t
*
,
vout_thread_t
*
);
...
@@ -186,33 +186,31 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
...
@@ -186,33 +186,31 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
/* Volume and audio actions */
/* Volume and audio actions */
case
ACTIONID_VOL_UP
:
case
ACTIONID_VOL_UP
:
{
{
audio_volume_t
i_new
vol
;
float
vol
;
aout_VolumeUp
(
p_playlist
,
1
,
&
i_newvol
);
if
(
aout_VolumeUp
(
p_playlist
,
1
,
&
vol
)
==
0
)
DisplayVolume
(
p_intf
,
p_vout
,
i_new
vol
);
DisplayVolume
(
p_intf
,
p_vout
,
vol
);
break
;
break
;
}
}
case
ACTIONID_VOL_DOWN
:
case
ACTIONID_VOL_DOWN
:
{
{
audio_volume_t
i_new
vol
;
float
vol
;
aout_VolumeDown
(
p_playlist
,
1
,
&
i_newvol
);
if
(
aout_VolumeDown
(
p_playlist
,
1
,
&
vol
)
==
0
)
DisplayVolume
(
p_intf
,
p_vout
,
i_new
vol
);
DisplayVolume
(
p_intf
,
p_vout
,
vol
);
break
;
break
;
}
}
case
ACTIONID_VOL_MUTE
:
case
ACTIONID_VOL_MUTE
:
if
(
aout_MuteToggle
(
p_playlist
)
==
0
&&
p_vout
!=
NULL
)
if
(
aout_MuteToggle
(
p_playlist
)
==
0
)
{
{
if
(
aout_MuteGet
(
p_playlist
)
>
0
)
float
vol
=
aout_VolumeGet
(
p_playlist
);
if
(
aout_MuteGet
(
p_playlist
)
>
0
||
vol
==
0
.
f
)
{
{
ClearChannels
(
p_intf
,
p_vout
);
ClearChannels
(
p_intf
,
p_vout
);
DisplayIcon
(
p_vout
,
OSD_MUTE_ICON
);
DisplayIcon
(
p_vout
,
OSD_MUTE_ICON
);
}
}
else
else
{
DisplayVolume
(
p_intf
,
p_vout
,
vol
);
audio_volume_t
i_vol
=
aout_VolumeGet
(
p_playlist
);
DisplayVolume
(
p_intf
,
p_vout
,
i_vol
);
}
}
}
break
;
break
;
...
@@ -1013,21 +1011,17 @@ static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
...
@@ -1013,21 +1011,17 @@ static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
}
}
static
void
DisplayVolume
(
intf_thread_t
*
p_intf
,
vout_thread_t
*
p_vout
,
static
void
DisplayVolume
(
intf_thread_t
*
p_intf
,
vout_thread_t
*
p_vout
,
audio_volume_t
i_
vol
)
float
vol
)
{
{
if
(
p_vout
==
NULL
)
if
(
p_vout
==
NULL
)
{
return
;
return
;
}
ClearChannels
(
p_intf
,
p_vout
);
ClearChannels
(
p_intf
,
p_vout
);
if
(
var_GetBool
(
p_vout
,
"fullscreen"
)
)
if
(
var_GetBool
(
p_vout
,
"fullscreen"
)
)
{
vout_OSDSlider
(
p_vout
,
VOLUME_WIDGET_CHAN
,
lround
(
vol
*
100
.),
vout_OSDSlider
(
p_vout
,
VOLUME_WIDGET_CHAN
,
OSD_VERT_SLIDER
);
i_vol
*
100
/
AOUT_VOLUME_MAX
,
OSD_VERT_SLIDER
);
DisplayMessage
(
p_vout
,
VOLUME_TEXT_CHAN
,
_
(
"Volume %ld%%"
),
}
lround
(
vol
*
100
.)
);
DisplayMessage
(
p_vout
,
VOLUME_TEXT_CHAN
,
_
(
"Volume %d%%"
),
i_vol
*
100
/
AOUT_VOLUME_DEFAULT
);
}
}
static
void
DisplayRate
(
vout_thread_t
*
p_vout
,
float
f_rate
)
static
void
DisplayRate
(
vout_thread_t
*
p_vout
,
float
f_rate
)
...
...
modules/control/rc.c
View file @
5d5f1713
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <errno.h>
/* ENOMEM */
#include <errno.h>
/* ENOMEM */
#include <signal.h>
#include <signal.h>
#include <assert.h>
#include <assert.h>
#include <math.h>
#include <vlc_interface.h>
#include <vlc_interface.h>
#include <vlc_aout_intf.h>
#include <vlc_aout_intf.h>
...
@@ -1497,8 +1498,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -1497,8 +1498,9 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
if
(
*
newval
.
psz_string
)
if
(
*
newval
.
psz_string
)
{
{
/* Set. */
/* Set. */
audio_volume_t
i_volume
=
atoi
(
newval
.
psz_string
);
int
i_volume
=
atoi
(
newval
.
psz_string
);
if
(
!
aout_VolumeSet
(
p_playlist
,
i_volume
)
)
if
(
!
aout_VolumeSet
(
p_playlist
,
i_volume
/
(
float
)
AOUT_VOLUME_DEFAULT
)
)
i_error
=
VLC_SUCCESS
;
i_error
=
VLC_SUCCESS
;
aout_MuteSet
(
p_playlist
,
i_volume
==
0
);
aout_MuteSet
(
p_playlist
,
i_volume
==
0
);
osd_Volume
(
p_this
);
osd_Volume
(
p_this
);
...
@@ -1507,8 +1509,8 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -1507,8 +1509,8 @@ static int Volume( vlc_object_t *p_this, char const *psz_cmd,
else
else
{
{
/* Get. */
/* Get. */
audio_volume_t
i_volume
=
aout_VolumeGet
(
p_playlist
);
msg_rc
(
STATUS_CHANGE
"( audio volume: %ld )"
,
msg_rc
(
STATUS_CHANGE
"( audio volume: %d )"
,
i_volume
);
lroundf
(
aout_VolumeGet
(
p_playlist
)
*
AOUT_VOLUME_DEFAULT
)
);
i_error
=
VLC_SUCCESS
;
i_error
=
VLC_SUCCESS
;
}
}
...
@@ -1520,7 +1522,7 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -1520,7 +1522,7 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
{
{
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
p_data
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
p_data
);
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
audio_volume_t
i_
volume
;
float
volume
;
input_thread_t
*
p_input
=
input_thread_t
*
p_input
=
playlist_CurrentInput
(
p_intf
->
p_sys
->
p_playlist
);
playlist_CurrentInput
(
p_intf
->
p_sys
->
p_playlist
);
int
i_nb_steps
=
atoi
(
newval
.
psz_string
);
int
i_nb_steps
=
atoi
(
newval
.
psz_string
);
...
@@ -1539,11 +1541,13 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
...
@@ -1539,11 +1541,13 @@ static int VolumeMove( vlc_object_t *p_this, char const *psz_cmd,
if
(
!
strcmp
(
psz_cmd
,
"voldown"
)
)
if
(
!
strcmp
(
psz_cmd
,
"voldown"
)
)
i_nb_steps
*=
-
1
;
i_nb_steps
*=
-
1
;
if
(
aout_VolumeUp
(
p_intf
->
p_sys
->
p_playlist
,
i_nb_steps
,
&
i_
volume
)
<
0
)
if
(
aout_VolumeUp
(
p_intf
->
p_sys
->
p_playlist
,
i_nb_steps
,
&
volume
)
<
0
)
i_error
=
VLC_EGENERIC
;
i_error
=
VLC_EGENERIC
;
osd_Volume
(
p_this
);
osd_Volume
(
p_this
);
if
(
!
i_error
)
msg_rc
(
STATUS_CHANGE
"( audio volume: %d )"
,
i_volume
);
if
(
!
i_error
)
msg_rc
(
STATUS_CHANGE
"( audio volume: %ld )"
,
lroundf
(
volume
*
AOUT_VOLUME_DEFAULT
)
);
return
i_error
;
return
i_error
;
}
}
...
...
modules/gui/macosx/CoreInteraction.m
View file @
5d5f1713
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#import "intf.h"
#import "intf.h"
#import "open.h"
#import "open.h"
#import "playlist.h"
#import "playlist.h"
#import <math.h>
#import <vlc_playlist.h>
#import <vlc_playlist.h>
#import <vlc_input.h>
#import <vlc_input.h>
#import <vlc_keys.h>
#import <vlc_keys.h>
...
@@ -515,9 +516,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
...
@@ -515,9 +516,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
if
(
!
p_intf
)
if
(
!
p_intf
)
return
0
;
return
0
;
audio_volume_t
i_
volume
=
aout_VolumeGet
(
pl_Get
(
p_intf
)
);
float
volume
=
aout_VolumeGet
(
pl_Get
(
p_intf
)
);
return
(
int
)
i_volume
;
return
lroundf
(
volume
*
AOUT_VOLUME_DEFAULT
)
;
}
}
-
(
void
)
setVolume
:
(
int
)
i_value
-
(
void
)
setVolume
:
(
int
)
i_value
...
@@ -526,7 +527,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
...
@@ -526,7 +527,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
if
(
!
p_intf
)
if
(
!
p_intf
)
return
;
return
;
aout_VolumeSet
(
pl_Get
(
p_intf
),
i_value
);
aout_VolumeSet
(
pl_Get
(
p_intf
),
i_value
/
(
float
)
AOUT_VOLUME_DEFAULT
);
}
}
#pragma mark -
#pragma mark -
...
...
modules/gui/macosx/MainWindow.m
View file @
5d5f1713
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#import "controls.h" // TODO: remove me
#import "controls.h" // TODO: remove me
#import "playlist.h"
#import "playlist.h"
#import "SideBarItem.h"
#import "SideBarItem.h"
#import <math.h>
#import <vlc_playlist.h>
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
#import <vlc_aout_intf.h>
#import <vlc_url.h>
#import <vlc_url.h>
...
@@ -1515,10 +1516,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
...
@@ -1515,10 +1516,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
-
(
void
)
updateVolumeSlider
-
(
void
)
updateVolumeSlider
{
{
audio_volume_t
i_volume
;
playlist_t
*
p_playlist
=
pl_Get
(
VLCIntf
);
playlist_t
*
p_playlist
=
pl_Get
(
VLCIntf
);
int
i_volume
=
lroundf
(
aout_VolumeGet
(
p_playlist
)
*
AOUT_VOLUME_DEFAULT
);
i_volume
=
aout_VolumeGet
(
p_playlist
);
BOOL
b_muted
=
[[
VLCCoreInteraction
sharedInstance
]
isMuted
];
BOOL
b_muted
=
[[
VLCCoreInteraction
sharedInstance
]
isMuted
];
if
(
!
b_muted
)
if
(
!
b_muted
)
...
...
modules/gui/ncurses.c
View file @
5d5f1713
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include <assert.h>
#include <assert.h>
#include <wchar.h>
#include <wchar.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <math.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
...
@@ -1068,7 +1069,7 @@ static int DrawStatus(intf_thread_t *intf)
...
@@ -1068,7 +1069,7 @@ static int DrawStatus(intf_thread_t *intf)
};
};
char
buf1
[
MSTRTIME_MAX_SIZE
];
char
buf1
[
MSTRTIME_MAX_SIZE
];
char
buf2
[
MSTRTIME_MAX_SIZE
];
char
buf2
[
MSTRTIME_MAX_SIZE
];
unsigned
i_
volume
;
float
volume
;
case
INIT_S
:
case
INIT_S
:
case
END_S
:
case
END_S
:
...
@@ -1089,9 +1090,13 @@ static int DrawStatus(intf_thread_t *intf)
...
@@ -1089,9 +1090,13 @@ static int DrawStatus(intf_thread_t *intf)
mvnprintw
(
y
++
,
0
,
COLS
,
_
(
" Position : %s/%s"
),
buf1
,
buf2
);
mvnprintw
(
y
++
,
0
,
COLS
,
_
(
" Position : %s/%s"
),
buf1
,
buf2
);
i_volume
=
aout_VolumeGet
(
p_playlist
);
volume
=
aout_VolumeGet
(
p_playlist
);
mvnprintw
(
y
++
,
0
,
COLS
,
_
(
" Volume : %u%%"
),
if
(
volume
>=
0
.
f
)
i_volume
*
100
/
AOUT_VOLUME_DEFAULT
);
mvnprintw
(
y
++
,
0
,
COLS
,
_
(
" Volume : %3ld%%"
),
lroundf
(
volume
*
100
.
f
));
else
mvnprintw
(
y
++
,
0
,
COLS
,
_
(
" Volume : ----"
),
lroundf
(
volume
*
100
.
f
));
if
(
!
var_Get
(
p_input
,
"title"
,
&
val
))
{
if
(
!
var_Get
(
p_input
,
"title"
,
&
val
))
{
int
i_title_count
=
var_CountChoices
(
p_input
,
"title"
);
int
i_title_count
=
var_CountChoices
(
p_input
,
"title"
);
...
...
modules/gui/qt4/components/controller_widget.cpp
View file @
5d5f1713
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "input_manager.hpp"
/* Get notification of Volume Change */
#include "input_manager.hpp"
/* Get notification of Volume Change */
#include "util/input_slider.hpp"
/* SoundSlider */
#include "util/input_slider.hpp"
/* SoundSlider */
#include <math.h>
#include <vlc_aout_intf.h>
/* Volume functions */
#include <vlc_aout_intf.h>
/* Volume functions */
#include <QLabel>
#include <QLabel>
...
@@ -151,8 +152,7 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
...
@@ -151,8 +152,7 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
/* Only if volume is set by user action on slider */
/* Only if volume is set by user action on slider */
setMuted
(
false
);
setMuted
(
false
);
playlist_t
*
p_playlist
=
pl_Get
(
p_intf
);
playlist_t
*
p_playlist
=
pl_Get
(
p_intf
);
int
i_res
=
i_sliderVolume
*
(
AOUT_VOLUME_DEFAULT
*
2
)
/
VOLUME_MAX
;
aout_VolumeSet
(
p_playlist
,
i_sliderVolume
/
100.
f
);
aout_VolumeSet
(
p_playlist
,
i_res
);
refreshLabels
();
refreshLabels
();
}
}
...
@@ -160,11 +160,8 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
...
@@ -160,11 +160,8 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
void
SoundWidget
::
libUpdateVolume
()
void
SoundWidget
::
libUpdateVolume
()
{
{
/* Audio part */
/* Audio part */
audio_volume_t
i_volume
;
playlist_t
*
p_playlist
=
pl_Get
(
p_intf
);
playlist_t
*
p_playlist
=
pl_Get
(
p_intf
);
long
i_volume
=
lroundf
(
aout_VolumeGet
(
p_playlist
)
*
100.
f
);
i_volume
=
aout_VolumeGet
(
p_playlist
);
i_volume
=
(
i_volume
*
VOLUME_MAX
)
/
(
AOUT_VOLUME_DEFAULT
*
2
);
if
(
i_volume
-
volumeSlider
->
value
()
!=
0
)
if
(
i_volume
-
volumeSlider
->
value
()
!=
0
)
{
{
...
...
modules/gui/skins2/src/vlcproc.cpp
View file @
5d5f1713
...
@@ -693,7 +693,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
...
@@ -693,7 +693,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
(
void
)
p_obj
;
(
void
)
newVal
;
(
void
)
p_obj
;
(
void
)
newVal
;
playlist_t
*
pPlaylist
=
getIntf
()
->
p_sys
->
p_playlist
;
playlist_t
*
pPlaylist
=
getIntf
()
->
p_sys
->
p_playlist
;
audio_volume_t
volume
=
aout_VolumeGet
(
pPlaylist
)
;
float
volume
=
aout_VolumeGet
(
pPlaylist
)
*
100.
f
;
SET_VOLUME
(
m_cVarVolume
,
volume
,
false
);
SET_VOLUME
(
m_cVarVolume
,
volume
,
false
);
bool
b_is_muted
=
aout_MuteGet
(
pPlaylist
)
>
0
;
bool
b_is_muted
=
aout_MuteGet
(
pPlaylist
)
>
0
;
SET_BOOL
(
m_cVarMute
,
b_is_muted
);
SET_BOOL
(
m_cVarMute
,
b_is_muted
);
...
@@ -798,7 +798,7 @@ void VlcProc::init_variables()
...
@@ -798,7 +798,7 @@ void VlcProc::init_variables()
SET_BOOL
(
m_cVarLoop
,
var_GetBool
(
pPlaylist
,
"loop"
)
);
SET_BOOL
(
m_cVarLoop
,
var_GetBool
(
pPlaylist
,
"loop"
)
);
SET_BOOL
(
m_cVarRepeat
,
var_GetBool
(
pPlaylist
,
"repeat"
)
);
SET_BOOL
(
m_cVarRepeat
,
var_GetBool
(
pPlaylist
,
"repeat"
)
);
audio_volume_t
volume
=
aout_VolumeGet
(
pPlaylist
)
;
float
volume
=
aout_VolumeGet
(
pPlaylist
)
*
100.
f
;
SET_VOLUME
(
m_cVarVolume
,
volume
,
false
);
SET_VOLUME
(
m_cVarVolume
,
volume
,
false
);
bool
b_is_muted
=
aout_MuteGet
(
pPlaylist
)
>
0
;
bool
b_is_muted
=
aout_MuteGet
(
pPlaylist
)
>
0
;
SET_BOOL
(
m_cVarMute
,
b_is_muted
);
SET_BOOL
(
m_cVarMute
,
b_is_muted
);
...
...
modules/gui/skins2/vars/volume.cpp
View file @
5d5f1713
...
@@ -38,7 +38,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
...
@@ -38,7 +38,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
m_volumeMax
=
AOUT_VOLUME_DEFAULT
*
2
;
m_volumeMax
=
AOUT_VOLUME_DEFAULT
*
2
;
// Initial value
// Initial value
audio_volume_t
val
=
aout_VolumeGet
(
getIntf
()
->
p_sys
->
p_playlist
)
;
float
val
=
aout_VolumeGet
(
getIntf
()
->
p_sys
->
p_playlist
)
*
100.
f
;
set
(
val
,
false
);
set
(
val
,
false
);
}
}
...
...
modules/lua/libs/volume.c
View file @
5d5f1713
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <math.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_meta.h>
#include <vlc_meta.h>
...
@@ -48,34 +49,38 @@
...
@@ -48,34 +49,38 @@
static
int
vlclua_volume_set
(
lua_State
*
L
)
static
int
vlclua_volume_set
(
lua_State
*
L
)
{
{
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
int
i_volume
=
VLC_CLIP
(
luaL_checkint
(
L
,
1
),
0
,
AOUT_VOLUME_MAX
);
int
i_volume
=
luaL_checkint
(
L
,
1
);
int
i_ret
=
aout_VolumeSet
(
p_this
,
i_volume
);
if
(
i_volume
<
0
)
i_volume
=
0
;
int
i_ret
=
aout_VolumeSet
(
p_this
,
i_volume
/
(
float
)
AOUT_VOLUME_DEFAULT
);
return
vlclua_push_ret
(
L
,
i_ret
);
return
vlclua_push_ret
(
L
,
i_ret
);
}
}
static
int
vlclua_volume_get
(
lua_State
*
L
)
static
int
vlclua_volume_get
(
lua_State
*
L
)
{
{
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
audio_volume_t
i_volume
=
aout_VolumeGet
(
p_this
);
long
i_volume
=
lroundf
(
aout_VolumeGet
(
p_this
)
*
AOUT_VOLUME_DEFAULT
);
lua_pushnumber
(
L
,
i_volume
);
lua_pushnumber
(
L
,
i_volume
);
return
1
;
return
1
;
}
}
static
int
vlclua_volume_up
(
lua_State
*
L
)
static
int
vlclua_volume_up
(
lua_State
*
L
)
{
{
audio_volume_t
i_volume
;
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
aout_VolumeUp
(
p_this
,
luaL_optint
(
L
,
1
,
1
),
&
i_volume
);
float
volume
;
lua_pushnumber
(
L
,
i_volume
);
aout_VolumeUp
(
p_this
,
luaL_optint
(
L
,
1
,
1
),
&
volume
);
lua_pushnumber
(
L
,
lroundf
(
volume
*
AOUT_VOLUME_DEFAULT
)
);
return
1
;
return
1
;
}
}
static
int
vlclua_volume_down
(
lua_State
*
L
)
static
int
vlclua_volume_down
(
lua_State
*
L
)
{
{
audio_volume_t
i_volume
;
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
playlist_t
*
p_this
=
vlclua_get_playlist_internal
(
L
);
aout_VolumeDown
(
p_this
,
luaL_optint
(
L
,
1
,
1
),
&
i_volume
);
float
volume
;
lua_pushnumber
(
L
,
i_volume
);
aout_VolumeDown
(
p_this
,
luaL_optint
(
L
,
1
,
1
),
&
volume
);
lua_pushnumber
(
L
,
lroundf
(
volume
*
AOUT_VOLUME_DEFAULT
)
);
return
1
;
return
1
;
}
}
...
...
src/audio_output/intf.c
View file @
5d5f1713
...
@@ -127,15 +127,17 @@ static void cancelVolume (vlc_object_t *obj, audio_output_t *aout)
...
@@ -127,15 +127,17 @@ static void cancelVolume (vlc_object_t *obj, audio_output_t *aout)
#undef aout_VolumeGet
#undef aout_VolumeGet
/**
/**
* Gets the volume of the output device (independent of mute).
* Gets the volume of the output device (independent of mute).
* \return Current audio volume (0 = silent, 1 = nominal),
* or a strictly negative value if undefined.
*/
*/
audio_volume_
t
aout_VolumeGet
(
vlc_object_t
*
obj
)
floa
t
aout_VolumeGet
(
vlc_object_t
*
obj
)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
float
vol
;
float
vol
;
prepareVolume
(
obj
,
&
aout
,
&
vol
,
NULL
);
prepareVolume
(
obj
,
&
aout
,
&
vol
,
NULL
);
cancelVolume
(
obj
,
aout
);
cancelVolume
(
obj
,
aout
);
return
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
return
vol
;
}
}
#undef aout_VolumeSet
#undef aout_VolumeSet
...
@@ -143,10 +145,9 @@ audio_volume_t aout_VolumeGet (vlc_object_t *obj)
...
@@ -143,10 +145,9 @@ audio_volume_t aout_VolumeGet (vlc_object_t *obj)
* Sets the volume of the output device.
* Sets the volume of the output device.
* The mute status is not changed.
* The mute status is not changed.
*/
*/
int
aout_VolumeSet
(
vlc_object_t
*
obj
,
audio_volume_t
volume
)
int
aout_VolumeSet
(
vlc_object_t
*
obj
,
float
vol
)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
float
vol
=
volume
/
(
float
)
AOUT_VOLUME_DEFAULT
;
bool
mute
;
bool
mute
;
prepareVolume
(
obj
,
&
aout
,
NULL
,
&
mute
);
prepareVolume
(
obj
,
&
aout
,
NULL
,
&
mute
);
...
@@ -159,7 +160,7 @@ int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
...
@@ -159,7 +160,7 @@ int aout_VolumeSet (vlc_object_t *obj, audio_volume_t volume)
* \param value how much to increase (> 0) or decrease (< 0) the volume
* \param value how much to increase (> 0) or decrease (< 0) the volume
* \param volp if non-NULL, will contain contain the resulting volume
* \param volp if non-NULL, will contain contain the resulting volume
*/
*/
int
aout_VolumeUp
(
vlc_object_t
*
obj
,
int
value
,
audio_volume_
t
*
volp
)
int
aout_VolumeUp
(
vlc_object_t
*
obj
,
int
value
,
floa
t
*
volp
)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
int
ret
;
int
ret
;
...
@@ -176,7 +177,7 @@ int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
...
@@ -176,7 +177,7 @@ int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
vol
=
AOUT_VOLUME_MAX
/
AOUT_VOLUME_DEFAULT
;
vol
=
AOUT_VOLUME_MAX
/
AOUT_VOLUME_DEFAULT
;
ret
=
commitVolume
(
obj
,
aout
,
vol
,
mute
);
ret
=
commitVolume
(
obj
,
aout
,
vol
,
mute
);
if
(
volp
!=
NULL
)
if
(
volp
!=
NULL
)
*
volp
=
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
*
volp
=
vol
;
return
ret
;
return
ret
;
}
}
...
...
src/audio_output/output.c
View file @
5d5f1713
...
@@ -91,7 +91,7 @@ static void aout_OutputTimeReport (audio_output_t *aout, mtime_t ideal)
...
@@ -91,7 +91,7 @@ static void aout_OutputTimeReport (audio_output_t *aout, mtime_t ideal)
*/
*/
static
void
aout_OutputVolumeReport
(
audio_output_t
*
aout
,
float
volume
)
static
void
aout_OutputVolumeReport
(
audio_output_t
*
aout
,
float
volume
)
{
{
audio_volume_t
vol
=
lroundf
(
volume
*
(
float
)
AOUT_VOLUME_DEFAULT
);
long
vol
=
lroundf
(
volume
*
(
float
)
AOUT_VOLUME_DEFAULT
);
/* We cannot acquire the volume lock as this gets called from the audio
/* We cannot acquire the volume lock as this gets called from the audio
* output plug-in (it would cause a lock inversion). */
* output plug-in (it would cause a lock inversion). */
...
@@ -365,7 +365,7 @@ static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute)
...
@@ -365,7 +365,7 @@ static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute)
*/
*/
void
aout_VolumeSoftInit
(
audio_output_t
*
aout
)
void
aout_VolumeSoftInit
(
audio_output_t
*
aout
)
{
{
audio_volume_t
volume
=
var_GetInteger
(
aout
,
"volume"
);
long
volume
=
var_GetInteger
(
aout
,
"volume"
);
bool
mute
=
var_GetBool
(
aout
,
"mute"
);
bool
mute
=
var_GetBool
(
aout
,
"mute"
);
aout_assert_locked
(
aout
);
aout_assert_locked
(
aout
);
...
...
src/text/strings.c
View file @
5d5f1713
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
/* Needed by str_format_time */
/* Needed by str_format_time */
#include <time.h>
#include <time.h>
#include <limits.h>
#include <limits.h>
#include <math.h>
/* Needed by str_format_meta */
/* Needed by str_format_meta */
#include <vlc_input.h>
#include <vlc_input.h>
...
@@ -889,12 +890,18 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
...
@@ -889,12 +890,18 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
}
}
break
;
break
;
case
'V'
:
case
'V'
:
{
float
vol
=
aout_VolumeGet
(
p_object
);
if
(
vol
>=
0
.
)
{
{
audio_volume_t
volume
=
aout_VolumeGet
(
p_object
);
snprintf
(
buf
,
10
,
"%ld"
,
snprintf
(
buf
,
10
,
"%d"
,
volume
);
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
);
INSERT_STRING_NO_FREE
(
buf
);
INSERT_STRING_NO_FREE
(
buf
);
break
;
}
}
else
INSERT_STRING_NO_FREE
(
"---"
);
break
;
}
case
'_'
:
case
'_'
:
*
(
dst
+
d
)
=
'\n'
;
*
(
dst
+
d
)
=
'\n'
;
d
++
;
d
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment