• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • routing
AudioOutput.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "AudioOutput.h"
12 
13 #include "MarbleDirs.h"
14 #include "MarbleDebug.h"
15 #include "routing/VoiceNavigationModel.h"
16 
17 #include <QDirIterator>
18 #include <phonon/MediaObject>
19 #include <phonon/MediaSource>
20 #include <phonon/AudioOutput>
21 
22 namespace Marble
23 {
24 
25 class AudioOutputPrivate
26 {
27 public:
28  AudioOutput *q;
29 
30  Phonon::MediaObject *m_output;
31 
32  bool m_muted;
33 
34  VoiceNavigationModel m_voiceNavigation;
35 
36  AudioOutputPrivate( AudioOutput* parent );
37 
38  void audioOutputFinished();
39 
40  void setupAudio();
41 
42  void reset();
43 
44  void playInstructions();
45 };
46 
47 AudioOutputPrivate::AudioOutputPrivate( AudioOutput* parent ) :
48  q( parent ), m_output( 0 ), m_muted( false )
49 {
50  QObject::connect( &m_voiceNavigation, SIGNAL(instructionChanged()),
51  q, SLOT(playInstructions()) );
52 }
53 
54 void AudioOutputPrivate::audioOutputFinished()
55 {
56  m_output->setCurrentSource( QString() );
57  m_output->clearQueue();
58 }
59 
60 void AudioOutputPrivate::setupAudio()
61 {
62  if ( !m_output ) {
63  m_output = new Phonon::MediaObject( q );
64  Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput( Phonon::VideoCategory, q );
65  Phonon::createPath( m_output, audioOutput );
66 
67  q->connect( m_output, SIGNAL(finished()), q, SLOT(audioOutputFinished()) );
68  }
69 }
70 
71 void AudioOutputPrivate::reset()
72 {
73  if ( m_output ) {
74  m_output->stop();
75  m_output->setCurrentSource( QString() );
76  m_output->clearQueue();
77  }
78 
79  m_voiceNavigation.reset();
80 }
81 
82 void AudioOutputPrivate::playInstructions()
83 {
84  setupAudio();
85  if ( m_output ) {
86  m_output->enqueue( m_voiceNavigation.instruction() );
87  m_output->play();
88  }
89 }
90 
91 AudioOutput::AudioOutput( QObject* parent ) : QObject( parent ),
92  d( new AudioOutputPrivate( this ) )
93 {
94  setSoundEnabled( false );
95 }
96 
97 AudioOutput::~AudioOutput()
98 {
99  delete d;
100 }
101 
102 void AudioOutput::update(const Route &route, qreal distanceManeuver, qreal distanceTarget, bool deviated )
103 {
104  d->m_voiceNavigation.update( route, distanceManeuver, distanceTarget, deviated );
105 }
106 
107 void AudioOutput::setMuted( bool muted )
108 {
109  d->m_muted = muted;
110 }
111 
112 bool AudioOutput::isMuted() const
113 {
114  return d->m_muted;
115 }
116 
117 void AudioOutput::setSpeaker( const QString &speaker )
118 {
119  d->m_voiceNavigation.setSpeaker( speaker );
120 }
121 
122 QString AudioOutput::speaker() const
123 {
124  return d->m_voiceNavigation.speaker();
125 }
126 
127 void AudioOutput::setSoundEnabled( bool enabled )
128 {
129  d->m_voiceNavigation.setSpeakerEnabled( !enabled );
130 }
131 
132 bool AudioOutput::isSoundEnabled() const
133 {
134  return !d->m_voiceNavigation.isSpeakerEnabled();
135 }
136 
137 }
138 
139 #include "AudioOutput.moc"
VoiceNavigationModel.h
Marble::AudioOutput::setMuted
void setMuted(bool muted)
Toggle muting (neither sound nor voice output)
Definition: AudioOutput.cpp:107
Marble::AudioOutput::setSoundEnabled
void setSoundEnabled(bool enabled)
Toggle whether sound output is used instead of a speaker.
Definition: AudioOutput.cpp:127
QObject
Marble::AudioOutput::~AudioOutput
~AudioOutput()
Destructor.
Definition: AudioOutput.cpp:97
MarbleDebug.h
Marble::AudioOutput::speaker
QString speaker() const
Definition: AudioOutput.cpp:122
Marble::AudioOutput::setSpeaker
void setSpeaker(const QString &speaker)
Change the speaker to use.
Definition: AudioOutput.cpp:117
MarbleDirs.h
Marble::AudioOutput::isSoundEnabled
bool isSoundEnabled() const
Definition: AudioOutput.cpp:132
Marble::AudioOutput::update
void update(const Route &route, qreal distanceManeuver, qreal distanceTarget, bool deviated)
Generate an audible notification (if needed) after the position on the route has changed.
Definition: AudioOutput.cpp:102
AudioOutput.h
Marble::AudioOutput::isMuted
bool isMuted() const
Definition: AudioOutput.cpp:112
Marble::Route
Definition: Route.h:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal