Skip to content
Permalink
Browse files

PulseAudio: fall back to default device if chosen device is no longer…

… present.
  • Loading branch information...
mkrautz committed Apr 24, 2016
1 parent 8dbc793 commit a50a120b2c398afe41801ae7d14c805ceac73110
Showing with 28 additions and 3 deletions.
  1. +25 −3 src/mumble/PulseAudio.cpp
  2. +3 −0 src/mumble/PulseAudio.h
@@ -153,6 +153,28 @@ PulseAudioSystem::~PulseAudioSystem() {
pa_threaded_mainloop_free(pam);
}

QString PulseAudioSystem::outputDevice() const {
QString odev = g.s.qsPulseAudioOutput;
if (odev.isEmpty()) {
odev = qsDefaultOutput;
}
if (!qhOutput.contains(odev)) {
odev = qsDefaultOutput;
}
return odev;
}

QString PulseAudioSystem::inputDevice() const {
QString idev = g.s.qsPulseAudioInput;
if (idev.isEmpty()) {
idev = qsDefaultInput;
}
if (!qhInput.contains(idev)) {
idev = qsDefaultInput;
}
return idev;
}

void PulseAudioSystem::wakeup() {
pa_mainloop_api *api = pa_threaded_mainloop_get_api(pam);
api->defer_enable(pade, true);
@@ -184,7 +206,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
PulseAudioOutput *pao = dynamic_cast<PulseAudioOutput *>(raw_ao);

if (raw_ao) {
QString odev = g.s.qsPulseAudioOutput.isEmpty() ? qsDefaultOutput : g.s.qsPulseAudioOutput;
QString odev = outputDevice();
pa_stream_state ost = pasOutput ? pa_stream_get_state(pasOutput) : PA_STREAM_TERMINATED;
bool do_stop = false;
bool do_start = false;
@@ -253,7 +275,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
}

if (raw_ai) {
QString idev = g.s.qsPulseAudioInput.isEmpty() ? qsDefaultInput : g.s.qsPulseAudioInput;
QString idev = inputDevice();
pa_stream_state ist = pasInput ? pa_stream_get_state(pasInput) : PA_STREAM_TERMINATED;
bool do_stop = false;
bool do_start = false;
@@ -312,7 +334,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
}

if (raw_ai) {
QString odev = g.s.qsPulseAudioOutput.isEmpty() ? qsDefaultOutput : g.s.qsPulseAudioOutput;
QString odev = outputDevice();
QString edev = qhEchoMap.value(odev);
pa_stream_state est = pasSpeaker ? pa_stream_get_state(pasSpeaker) : PA_STREAM_TERMINATED;
bool do_stop = false;
@@ -99,6 +99,9 @@ class PulseAudioSystem : public QObject {

void query();

QString outputDevice() const;
QString inputDevice() const;

void setVolumes();
PulseAttenuation* getAttenuation(QString stream_restore_id);

0 comments on commit a50a120

Please sign in to comment.
You can’t perform that action at this time.