Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
e4b02513
Unverified
Commit
e4b02513
authored
Jan 07, 2019
by
Rémi Verschelde
Committed by
GitHub
Jan 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #24301 from marcelofg55/default_device_pulseaudio
PulseAudio driver will now change the device if the default system device changes
parents
270eae0a
a6743414
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
audio_driver_pulseaudio.cpp
drivers/pulseaudio/audio_driver_pulseaudio.cpp
+42
-0
No files found.
drivers/pulseaudio/audio_driver_pulseaudio.cpp
View file @
e4b02513
...
...
@@ -316,6 +316,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
AudioDriverPulseAudio
*
ad
=
(
AudioDriverPulseAudio
*
)
p_udata
;
unsigned
int
write_ofs
=
0
;
size_t
avail_bytes
=
0
;
uint32_t
default_device_msec
=
OS
::
get_singleton
()
->
get_ticks_msec
();
while
(
!
ad
->
exit_thread
)
{
...
...
@@ -406,6 +407,47 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
write_ofs
=
0
;
}
// If we're using the default device check that the current device is still the default
if
(
ad
->
device_name
==
"Default"
)
{
uint32_t
msec
=
OS
::
get_singleton
()
->
get_ticks_msec
();
if
(
msec
>
(
default_device_msec
+
1000
))
{
String
old_default_device
=
ad
->
default_device
;
default_device_msec
=
msec
;
ad
->
pa_status
=
0
;
pa_operation
*
pa_op
=
pa_context_get_server_info
(
ad
->
pa_ctx
,
&
AudioDriverPulseAudio
::
pa_server_info_cb
,
(
void
*
)
ad
);
if
(
pa_op
)
{
while
(
ad
->
pa_status
==
0
)
{
int
ret
=
pa_mainloop_iterate
(
ad
->
pa_ml
,
1
,
NULL
);
if
(
ret
<
0
)
{
ERR_PRINT
(
"pa_mainloop_iterate error"
);
}
}
pa_operation_unref
(
pa_op
);
}
else
{
ERR_PRINT
(
"pa_context_get_server_info error"
);
}
if
(
old_default_device
!=
ad
->
default_device
)
{
ad
->
finish_device
();
Error
err
=
ad
->
init_device
();
if
(
err
!=
OK
)
{
ERR_PRINT
(
"PulseAudio: init_device error"
);
ad
->
active
=
false
;
ad
->
exit_thread
=
true
;
break
;
}
avail_bytes
=
0
;
write_ofs
=
0
;
}
}
}
if
(
ad
->
pa_rec_str
&&
pa_stream_get_state
(
ad
->
pa_rec_str
)
==
PA_STREAM_READY
)
{
size_t
bytes
=
pa_stream_readable_size
(
ad
->
pa_rec_str
);
if
(
bytes
>
0
)
{
...
...
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