Music Hub  ..
A session-wide music playback service
output_observer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  * Copyright © 2022 UBports Foundation.
4  *
5  * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License version 3,
9  * as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Authored by: Thomas Voß <thomas.voss@canonical.com>
20  */
21 
22 #include "audio/output_observer.h"
23 
25 #include "audio/ostream_reporter.h"
26 
27 #include <iostream>
28 
30 
31 using namespace audio;
32 
33 std::ostream& audio::operator<<(std::ostream& out, audio::OutputState state)
34 {
35  switch (state)
36  {
37  case audio::OutputState::Earpiece:
38  return out << "OutputState::Earpiece";
39  case audio::OutputState::Speaker:
40  return out << "OutputState::Speaker";
41  case audio::OutputState::External:
42  return out << "OutputState::External";
43  }
44 
45  return out;
46 }
47 
49  QObject(parent),
50  d_ptr(new PulseAudioOutputObserver("sink.primary",
51  {"output-wired_head.*|output-a2dp_headphones"},
52  std::make_shared<audio::OStreamReporter>(),
53  this))
54 {
55 }
56 
58 
60 {
61  Q_D(const OutputObserver);
62  return d->outputState();
63 }
QObject
lomiri::MediaHubService::audio::PulseAudioOutputObserver
Definition: pulse_audio_output_observer.h:43
lomiri::MediaHub::operator<<
QDebug operator<<(QDebug dbg, const Error &error)
Definition: error.h:64
lomiri::MediaHubService::audio
Definition: ostream_reporter.h:33
ostream_reporter.h
output_observer.h
lomiri::MediaHubService::audio::OutputObserver
Definition: output_observer.h:50
pulse_audio_output_observer.h
lomiri::MediaHubService::audio::OutputObserver::~OutputObserver
virtual ~OutputObserver()
lomiri::MediaHubService::audio::OutputState
OutputState
Definition: output_observer.h:35
lomiri::MediaHubService::audio::OutputObserver::outputState
OutputState outputState() const
Definition: output_observer.cpp:59
lomiri::MediaHubService::audio::OutputObserver::OutputObserver
OutputObserver(QObject *parent=nullptr)
Definition: output_observer.cpp:48