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
60e47a90
Commit
60e47a90
authored
Jul 01, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout: use float volume in internals and deal with errors
parent
ac564301
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
41 deletions
+42
-41
src/audio_output/intf.c
src/audio_output/intf.c
+42
-41
No files found.
src/audio_output/intf.c
View file @
60e47a90
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
/* calloc(), malloc(), free() */
#include <stdlib.h>
/* calloc(), malloc(), free() */
#include <string.h>
#include <string.h>
#include <math.h>
#include <vlc_aout.h>
#include <vlc_aout.h>
#include "aout_internal.h"
#include "aout_internal.h"
...
@@ -61,7 +62,7 @@ static audio_output_t *findAout (vlc_object_t *obj)
...
@@ -61,7 +62,7 @@ static audio_output_t *findAout (vlc_object_t *obj)
/** Start a volume change transaction. */
/** Start a volume change transaction. */
static
void
prepareVolume
(
vlc_object_t
*
obj
,
audio_output_t
**
aoutp
,
static
void
prepareVolume
(
vlc_object_t
*
obj
,
audio_output_t
**
aoutp
,
audio_volume_t
*
volp
,
bool
*
mutep
)
float
*
vol
,
bool
*
mute
)
{
{
audio_output_t
*
aout
=
findAout
(
obj
);
audio_output_t
*
aout
=
findAout
(
obj
);
...
@@ -72,41 +73,43 @@ static void prepareVolume (vlc_object_t *obj, audio_output_t **aoutp,
...
@@ -72,41 +73,43 @@ static void prepareVolume (vlc_object_t *obj, audio_output_t **aoutp,
obj
=
VLC_OBJECT
(
aout
);
/* use aout volume if aout exists */
obj
=
VLC_OBJECT
(
aout
);
/* use aout volume if aout exists */
aout_lock_volume
(
aout
);
aout_lock_volume
(
aout
);
}
}
if
(
vol
p
!=
NULL
)
if
(
vol
!=
NULL
)
*
vol
p
=
var_InheritInteger
(
obj
,
"volume"
)
;
*
vol
=
var_InheritInteger
(
obj
,
"volume"
)
/
(
float
)
AOUT_VOLUME_DEFAULT
;
if
(
mute
p
!=
NULL
)
if
(
mute
!=
NULL
)
*
mute
p
=
var_InheritBool
(
obj
,
"mute"
);
*
mute
=
var_InheritBool
(
obj
,
"mute"
);
}
}
/** Commit a volume change transaction. */
/** Commit a volume change transaction. */
static
int
commitVolume
(
vlc_object_t
*
obj
,
audio_output_t
*
aout
,
static
int
commitVolume
(
vlc_object_t
*
obj
,
audio_output_t
*
aout
,
audio_volume_t
volume
,
bool
mute
)
float
vol
,
bool
mute
)
{
{
long
volume
=
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
);
int
ret
=
0
;
int
ret
=
0
;
/* update caller (input manager) volume */
var_SetInteger
(
obj
,
"volume"
,
volume
);
var_SetBool
(
obj
,
"mute"
,
mute
);
if
(
var_InheritBool
(
obj
,
"volume-save"
))
config_PutInt
(
obj
,
"volume"
,
volume
);
if
(
aout
!=
NULL
)
if
(
aout
!=
NULL
)
{
{
float
vol
=
volume
/
(
float
)
AOUT_VOLUME_DEFAULT
;
/* apply volume to the pipeline */
/* apply volume to the pipeline */
aout_lock
(
aout
);
aout_lock
(
aout
);
if
(
aout
->
pf_volume_set
!=
NULL
)
if
(
aout
->
pf_volume_set
!=
NULL
)
ret
=
aout
->
pf_volume_set
(
aout
,
vol
,
mute
);
ret
=
aout
->
pf_volume_set
(
aout
,
vol
,
mute
);
aout_unlock
(
aout
);
aout_unlock
(
aout
);
/* update aout volume if it maintains its own */
if
(
ret
==
0
)
var_SetInteger
(
aout
,
"volume"
,
volume
);
{
/* update aout volume if it maintains its own */
var_SetBool
(
aout
,
"mute"
,
mute
);
var_SetInteger
(
aout
,
"volume"
,
volume
);
var_SetBool
(
aout
,
"mute"
,
mute
);
}
aout_unlock_volume
(
aout
);
aout_unlock_volume
(
aout
);
vlc_object_release
(
aout
);
vlc_object_release
(
aout
);
}
}
if
(
ret
==
0
)
{
/* update caller (input manager) volume */
var_SetInteger
(
obj
,
"volume"
,
volume
);
var_SetBool
(
obj
,
"mute"
,
mute
);
if
(
var_InheritBool
(
obj
,
"volume-save"
))
config_PutInt
(
obj
,
"volume"
,
volume
);
}
return
ret
;
return
ret
;
}
}
...
@@ -128,11 +131,11 @@ static void cancelVolume (vlc_object_t *obj, audio_output_t *aout)
...
@@ -128,11 +131,11 @@ static void cancelVolume (vlc_object_t *obj, audio_output_t *aout)
audio_volume_t
aout_VolumeGet
(
vlc_object_t
*
obj
)
audio_volume_t
aout_VolumeGet
(
vlc_object_t
*
obj
)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
audio_volume_t
volume
;
float
vol
;
prepareVolume
(
obj
,
&
aout
,
&
vol
ume
,
NULL
);
prepareVolume
(
obj
,
&
aout
,
&
vol
,
NULL
);
cancelVolume
(
obj
,
aout
);
cancelVolume
(
obj
,
aout
);
return
volume
;
return
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
}
}
#undef aout_VolumeSet
#undef aout_VolumeSet
...
@@ -143,10 +146,11 @@ audio_volume_t aout_VolumeGet (vlc_object_t *obj)
...
@@ -143,10 +146,11 @@ audio_volume_t aout_VolumeGet (vlc_object_t *obj)
int
aout_VolumeSet
(
vlc_object_t
*
obj
,
audio_volume_t
volume
)
int
aout_VolumeSet
(
vlc_object_t
*
obj
,
audio_volume_t
volume
)
{
{
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
);
return
commitVolume
(
obj
,
aout
,
vol
ume
,
mute
);
return
commitVolume
(
obj
,
aout
,
vol
,
mute
);
}
}
#undef aout_VolumeUp
#undef aout_VolumeUp
...
@@ -159,23 +163,20 @@ int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
...
@@ -159,23 +163,20 @@ int aout_VolumeUp (vlc_object_t *obj, int value, audio_volume_t *volp)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
int
ret
;
int
ret
;
audio_volume_t
volume
;
float
vol
;
bool
mute
;
bool
mute
;
value
*=
var_InheritInteger
(
obj
,
"volume-step"
);
value
*=
var_InheritInteger
(
obj
,
"volume-step"
);
prepareVolume
(
obj
,
&
aout
,
&
volume
,
&
mute
);
prepareVolume
(
obj
,
&
aout
,
&
vol
,
&
mute
);
value
+=
volume
;
vol
+=
value
/
(
float
)
AOUT_VOLUME_DEFAULT
;
if
(
value
<
0
)
if
(
vol
<
0
.)
volume
=
0
;
vol
=
0
.;
else
if
(
vol
>
(
AOUT_VOLUME_MAX
/
AOUT_VOLUME_DEFAULT
))
if
(
value
>
AOUT_VOLUME_MAX
)
vol
=
AOUT_VOLUME_MAX
/
AOUT_VOLUME_DEFAULT
;
volume
=
AOUT_VOLUME_MAX
;
ret
=
commitVolume
(
obj
,
aout
,
vol
,
mute
);
else
volume
=
value
;
ret
=
commitVolume
(
obj
,
aout
,
volume
,
mute
);
if
(
volp
!=
NULL
)
if
(
volp
!=
NULL
)
*
volp
=
volume
;
*
volp
=
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
return
ret
;
return
ret
;
}
}
...
@@ -187,14 +188,14 @@ int aout_ToggleMute (vlc_object_t *obj, audio_volume_t *volp)
...
@@ -187,14 +188,14 @@ int aout_ToggleMute (vlc_object_t *obj, audio_volume_t *volp)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
int
ret
;
int
ret
;
audio_volume_t
volume
;
float
vol
;
bool
mute
;
bool
mute
;
prepareVolume
(
obj
,
&
aout
,
&
vol
ume
,
&
mute
);
prepareVolume
(
obj
,
&
aout
,
&
vol
,
&
mute
);
mute
=
!
mute
;
mute
=
!
mute
;
ret
=
commitVolume
(
obj
,
aout
,
vol
ume
,
mute
);
ret
=
commitVolume
(
obj
,
aout
,
vol
,
mute
);
if
(
volp
!=
NULL
)
if
(
volp
!=
NULL
)
*
volp
=
mute
?
0
:
volume
;
*
volp
=
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
return
ret
;
return
ret
;
}
}
...
@@ -218,12 +219,12 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute)
...
@@ -218,12 +219,12 @@ int aout_SetMute (vlc_object_t *obj, audio_volume_t *volp, bool mute)
{
{
audio_output_t
*
aout
;
audio_output_t
*
aout
;
int
ret
;
int
ret
;
audio_volume_t
volume
;
float
vol
;
prepareVolume
(
obj
,
&
aout
,
&
vol
ume
,
NULL
);
prepareVolume
(
obj
,
&
aout
,
&
vol
,
NULL
);
ret
=
commitVolume
(
obj
,
aout
,
vol
ume
,
mute
);
ret
=
commitVolume
(
obj
,
aout
,
vol
,
mute
);
if
(
volp
!=
NULL
)
if
(
volp
!=
NULL
)
*
volp
=
mute
?
0
:
volume
;
*
volp
=
mute
?
0
:
lroundf
(
vol
*
AOUT_VOLUME_DEFAULT
)
;
return
ret
;
return
ret
;
}
}
...
...
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