mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
pactl: add get_default_source command
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/430>
This commit is contained in:
parent
75390822b4
commit
258bc97fb1
2 changed files with 25 additions and 0 deletions
|
|
@ -176,6 +176,11 @@ License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||||
<optdesc><p>Set the specified sink (identified by its symbolic name or numerical index) to the specified port (identified by its symbolic name).</p></optdesc>
|
<optdesc><p>Set the specified sink (identified by its symbolic name or numerical index) to the specified port (identified by its symbolic name).</p></optdesc>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<p><opt>get-default-source</opt></p>
|
||||||
|
<optdesc><p>Returns the symbolic name of the default source.</p></optdesc>
|
||||||
|
</option>
|
||||||
|
|
||||||
<option>
|
<option>
|
||||||
<p><opt>set-default-source</opt> <arg>SOURCE</arg></p>
|
<p><opt>set-default-source</opt> <arg>SOURCE</arg></p>
|
||||||
<optdesc><p>Make the specified source (identified by its symbolic name or numerical index) the default source.</p></optdesc>
|
<optdesc><p>Make the specified source (identified by its symbolic name or numerical index) the default source.</p></optdesc>
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ static enum {
|
||||||
GET_DEFAULT_SINK,
|
GET_DEFAULT_SINK,
|
||||||
SET_DEFAULT_SINK,
|
SET_DEFAULT_SINK,
|
||||||
SET_SOURCE_PORT,
|
SET_SOURCE_PORT,
|
||||||
|
GET_DEFAULT_SOURCE,
|
||||||
SET_DEFAULT_SOURCE,
|
SET_DEFAULT_SOURCE,
|
||||||
GET_SINK_VOLUME,
|
GET_SINK_VOLUME,
|
||||||
SET_SINK_VOLUME,
|
SET_SINK_VOLUME,
|
||||||
|
|
@ -203,6 +204,18 @@ static void get_default_sink(pa_context *c, const pa_server_info *i, void *userd
|
||||||
complete_action();
|
complete_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_default_source(pa_context *c, const pa_server_info *i, void *userdata) {
|
||||||
|
if (!i) {
|
||||||
|
pa_log(_("Failed to get server information: %s"), pa_strerror(pa_context_errno(c)));
|
||||||
|
quit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(_("%s\n"), i->default_source_name);
|
||||||
|
|
||||||
|
complete_action();
|
||||||
|
}
|
||||||
|
|
||||||
static void get_server_info_callback(pa_context *c, const pa_server_info *i, void *useerdata) {
|
static void get_server_info_callback(pa_context *c, const pa_server_info *i, void *useerdata) {
|
||||||
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
|
||||||
|
|
||||||
|
|
@ -1528,6 +1541,10 @@ static void context_state_callback(pa_context *c, void *userdata) {
|
||||||
o = pa_context_set_source_port_by_name(c, source_name, port_name, simple_callback, NULL);
|
o = pa_context_set_source_port_by_name(c, source_name, port_name, simple_callback, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GET_DEFAULT_SOURCE:
|
||||||
|
o = pa_context_get_server_info(c, get_default_source, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
case SET_DEFAULT_SOURCE:
|
case SET_DEFAULT_SOURCE:
|
||||||
o = pa_context_set_default_source(c, source_name, simple_callback, NULL);
|
o = pa_context_set_default_source(c, source_name, simple_callback, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2086,6 +2103,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
source_name = pa_xstrdup(argv[optind+1]);
|
source_name = pa_xstrdup(argv[optind+1]);
|
||||||
|
|
||||||
|
} else if (pa_streq(argv[optind], "get-default-source")) {
|
||||||
|
action = GET_DEFAULT_SOURCE;
|
||||||
|
|
||||||
} else if (pa_streq(argv[optind], "get-sink-volume")) {
|
} else if (pa_streq(argv[optind], "get-sink-volume")) {
|
||||||
action = GET_SINK_VOLUME;
|
action = GET_SINK_VOLUME;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue