Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
panelcontrol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
minus
panelcontrol
Commits
b5a7f0ec
Commit
b5a7f0ec
authored
Sep 07, 2019
by
minus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggle button LED on mute & speakers
parent
cdce3a82
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
6 deletions
+38
-6
pa.c
pa.c
+1
-1
pa_sink_input_watch_list.c
pa_sink_input_watch_list.c
+3
-1
pa_sink_input_watch_list.h
pa_sink_input_watch_list.h
+2
-1
panelcontrol.c
panelcontrol.c
+27
-3
panelcontrol.h
panelcontrol.h
+5
-0
No files found.
pa.c
View file @
b5a7f0ec
...
...
@@ -18,7 +18,7 @@ static void xpa_on_sink_input_info(pa_context *ctx,
struct
sink_input_watch
*
w
=
sink_inputs_get
(
info
->
name
);
if
(
w
)
{
sink_input_watch_add_index
(
w
,
info
->
index
);
sink_input_watch_update
(
w
,
info
->
volume
.
values
[
0
],
info
->
mute
!=
0
);
sink_input_watch_update
(
w
,
info
->
sink
,
info
->
volume
.
values
[
0
],
info
->
mute
!=
0
);
}
}
...
...
pa_sink_input_watch_list.c
View file @
b5a7f0ec
...
...
@@ -35,7 +35,8 @@ void sink_input_watch_remove_index(struct sink_input_watch *w, uint32_t pa_index
}
}
void
sink_input_watch_update
(
struct
sink_input_watch
*
w
,
pa_volume_t
volume
,
bool
mute
)
{
void
sink_input_watch_update
(
struct
sink_input_watch
*
w
,
uint32_t
sink_index
,
pa_volume_t
volume
,
bool
mute
)
{
w
->
sink
=
sink_index
;
w
->
volume
=
volume
;
w
->
mute
=
mute
;
if
(
w
->
volume_changed
)
{
...
...
@@ -49,6 +50,7 @@ struct sink_input_watch *sink_inputs_add_sink(const char* sink_name) {
sizeof
(
struct
sink_input_watch
)
*
sink_inputs
.
len
);
struct
sink_input_watch
*
item
=
&
sink_inputs
.
items
[
sink_inputs
.
len
-
1
];
item
->
name
=
strdup
(
sink_name
);
item
->
sink
=
-
1
;
item
->
volume
=
PA_VOLUME_MUTED
;
item
->
mute
=
true
;
item
->
indices
.
len
=
0
;
...
...
pa_sink_input_watch_list.h
View file @
b5a7f0ec
...
...
@@ -3,6 +3,7 @@
struct
sink_input_watch
{
const
char
*
name
;
uint32_t
sink
;
pa_volume_t
volume
;
bool
mute
;
struct
indices_list
{
...
...
@@ -15,7 +16,7 @@ struct sink_input_watch {
void
sink_input_watch_add_index
(
struct
sink_input_watch
*
w
,
uint32_t
pa_index
);
void
sink_input_watch_remove_index
(
struct
sink_input_watch
*
w
,
uint32_t
pa_index
);
void
sink_input_watch_update
(
struct
sink_input_watch
*
w
,
pa_volume_t
volume
,
bool
mute
);
void
sink_input_watch_update
(
struct
sink_input_watch
*
w
,
uint32_t
sink_index
,
pa_volume_t
volume
,
bool
mute
);
struct
sink_input_watch
*
sink_inputs_add_sink
(
const
char
*
sink_name
);
struct
sink_input_watch
*
sink_inputs_get
(
const
char
*
sink_name
);
void
sink_inputs_remove_index
(
uint32_t
pa_index
);
panelcontrol.c
View file @
b5a7f0ec
...
...
@@ -37,6 +37,8 @@ gboolean on_alsa_readable(GIOChannel *source, GIOCondition condition, gpointer d
return
TRUE
;
}
static
int
port
;
snd_seq_t
*
alsa
(
int
source
)
{
// connect to ALSA seq
snd_seq_t
*
seq
;
...
...
@@ -45,7 +47,7 @@ snd_seq_t *alsa(int source) {
exit
(
1
);
}
snd_seq_set_client_name
(
seq
,
CLIENT_NAME
);
int
port
=
snd_seq_create_simple_port
(
seq
,
CLIENT_NAME
,
port
=
snd_seq_create_simple_port
(
seq
,
CLIENT_NAME
,
SND_SEQ_PORT_CAP_WRITE
|
SND_SEQ_PORT_CAP_SUBS_WRITE
|
SND_SEQ_PORT_CAP_READ
|
SND_SEQ_PORT_CAP_SUBS_READ
,
SND_SEQ_PORT_TYPE_APPLICATION
);
...
...
@@ -104,6 +106,25 @@ snd_seq_t *alsa(int source) {
//static const struct encoder_map_entry encoder_map[] = {
// {.encoder = ENC1, .sink_input = NULL, .action = &change_volume},
//};
void
midi_button_led
(
snd_seq_t
*
seq
,
enum
button
button
,
enum
button_led_state
state
)
{
snd_seq_event_t
ev
;
snd_seq_ev_clear
(
&
ev
);
snd_seq_ev_set_source
(
&
ev
,
port
);
snd_seq_ev_set_subs
(
&
ev
);
snd_seq_ev_set_direct
(
&
ev
);
snd_seq_ev_set_noteon
(
&
ev
,
0
,
button
,
state
);
snd_seq_event_output_direct
(
seq
,
&
ev
);
}
void
show_mute_and_speakers
(
struct
sink_input_watch
*
w
)
{
snd_seq_t
*
seq
=
w
->
userdata
;
midi_button_led
(
seq
,
TOP1
,
w
->
mute
?
BUTTON_LED_ON
:
BUTTON_LED_OFF
);
uint32_t
speakers
=
3
;
uint32_t
headphones
=
4
;
midi_button_led
(
seq
,
BOTTOM1
,
w
->
sink
==
speakers
?
BUTTON_LED_ON
:
BUTTON_LED_OFF
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
2
)
{
...
...
@@ -112,10 +133,13 @@ int main(int argc, char *argv[]) {
}
int
source
=
atoi
(
argv
[
1
]);
snd_seq_t
*
seq
=
alsa
(
source
);
struct
sink_input_watch
*
mpd
=
sink_inputs_add_sink
(
"mpd pulse"
);
mpd
->
userdata
=
seq
;
mpd
->
volume_changed
=
show_mute_and_speakers
;
pa
();
snd_seq_t
*
seq
=
alsa
(
source
);
// create PA watch object for sink name "mpd pulse"
// with a callback function on change (info, sinks)
...
...
@@ -127,7 +151,7 @@ int main(int argc, char *argv[]) {
// on change from MIDI side, the callback is executed and passed the
// MIDI action as well as the mapping struct with the PA watch reference
GMainLoop
*
main_loop
=
g_main_loop_new
(
NULL
,
FALSE
);
GMainLoop
*
main_loop
=
g_main_loop_new
(
NULL
,
FALSE
);
g_main_loop_run
(
main_loop
);
g_main_loop_unref
(
main_loop
);
return
0
;
...
...
panelcontrol.h
View file @
b5a7f0ec
...
...
@@ -24,6 +24,11 @@ enum button {
LAYERB
=
85
,
};
enum
button_led_state
{
BUTTON_LED_ON
=
127
,
BUTTON_LED_OFF
=
0
,
};
enum
encoder
{
ENC1
=
16
,
ENC2
=
17
,
...
...
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