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
1f442822
Commit
1f442822
authored
Jul 21, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PulseAudio: keep track of sink input volume
parent
c7885fe1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
1 deletion
+65
-1
modules/audio_output/pulse.c
modules/audio_output/pulse.c
+65
-1
No files found.
modules/audio_output/pulse.c
View file @
1f442822
...
...
@@ -71,6 +71,45 @@ struct aout_sys_t
unsigned
rate
;
/**< Current stream sample rate */
};
static
void
sink_input_info_cb
(
pa_context
*
,
const
pa_sink_input_info
*
,
int
,
void
*
);
/*** Context ***/
static
void
context_cb
(
pa_context
*
ctx
,
pa_subscription_event_type_t
type
,
uint32_t
idx
,
void
*
userdata
)
{
audio_output_t
*
aout
=
userdata
;
aout_sys_t
*
sys
=
aout
->
sys
;
pa_operation
*
op
;
switch
(
type
&
PA_SUBSCRIPTION_EVENT_FACILITY_MASK
)
{
case
PA_SUBSCRIPTION_EVENT_SINK_INPUT
:
if
(
idx
!=
pa_stream_get_index
(
sys
->
stream
))
break
;
/* only interested in our sink input */
/* Gee... PA will not provide the infos directly in the event. */
switch
(
type
&
PA_SUBSCRIPTION_EVENT_TYPE_MASK
)
{
case
PA_SUBSCRIPTION_EVENT_REMOVE
:
msg_Err
(
aout
,
"sink input killed!"
);
break
;
default:
op
=
pa_context_get_sink_input_info
(
ctx
,
idx
,
sink_input_info_cb
,
aout
);
if
(
likely
(
op
!=
NULL
))
pa_operation_unref
(
op
);
break
;
}
break
;
default:
/* unsubscribed facility?! */
assert
(
0
);
}
}
/*** Sink ***/
static
void
sink_list_cb
(
pa_context
*
c
,
const
pa_sink_info
*
i
,
int
eol
,
void
*
userdata
)
...
...
@@ -296,6 +335,24 @@ static void stream_success_cb(pa_stream *s, int success, void *userdata)
# define stream_success_cb NULL
#endif
/*** Sink input ***/
static
void
sink_input_info_cb
(
pa_context
*
ctx
,
const
pa_sink_input_info
*
i
,
int
eol
,
void
*
userdata
)
{
audio_output_t
*
aout
=
userdata
;
if
(
eol
)
return
;
const
float
volume
=
pa_sw_volume_to_linear
(
pa_cvolume_avg
(
&
i
->
volume
));
aout_VolumeHardSet
(
aout
,
volume
,
i
->
mute
);
(
void
)
ctx
;
}
/*** VLC audio output callbacks ***/
/* Memory free callback. The block_t address is in front of the data. */
static
void
data_free
(
void
*
data
)
{
...
...
@@ -440,7 +497,6 @@ static int VolumeSet(audio_output_t *aout, float vol, bool mute)
pa_cvolume
cvolume
;
/* TODO: do not ruin the channel balance (if set outside VLC) */
/* TODO: notify UI about volume changes by other PulseAudio clients */
pa_cvolume_set
(
&
sys
->
cvolume
,
sys
->
cvolume
.
channels
,
volume
);
pa_sw_cvolume_multiply_scalar
(
&
cvolume
,
&
sys
->
cvolume
,
sys
->
base_volume
);
assert
(
pa_cvolume_valid
(
&
cvolume
));
...
...
@@ -634,6 +690,14 @@ static int Open(vlc_object_t *obj)
sys
->
desync
=
0
;
sys
->
rate
=
ss
.
rate
;
/* Context events */
const
pa_subscription_mask_t
mask
=
PA_SUBSCRIPTION_MASK_SINK_INPUT
;
pa_context_set_subscribe_callback
(
ctx
,
context_cb
,
aout
);
op
=
pa_context_subscribe
(
ctx
,
mask
,
NULL
,
NULL
);
if
(
likely
(
op
!=
NULL
))
pa_operation_unref
(
op
);
/* Channel volume */
sys
->
base_volume
=
PA_VOLUME_NORM
;
pa_cvolume_set
(
&
sys
->
cvolume
,
ss
.
channels
,
PA_VOLUME_NORM
);
...
...
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