Ticket #7517: volume_control_mythplugins_r22850.patch
File volume_control_mythplugins_r22850.patch, 10.8 KB (added by , 14 years ago) |
---|
-
mythmusic/mythmusic/playbackbox.cpp
98 98 99 99 // Possibly (user-defined) control the volume 100 100 101 volume_control = false; 102 volume_display_timer = new QTimer(this); 103 if (gContext->GetNumSetting("MythControlsVolume", 0)) 101 volume_control = VolumeControlManager::GetControl(gContext->GetSetting("MixerDevice")); 102 if (volume_control) 104 103 { 105 volume_control = true; 104 connect(volume_control.data(), SIGNAL(changedVolume(int)), 105 this, SLOT(VolumeChanged(int))); 106 connect(volume_control.data(), SIGNAL(changedMute(bool)), 107 this, SLOT(MuteChanged(bool))); 106 108 } 109 110 volume_display_timer = new QTimer(this); 107 111 volume_display_timer->setSingleShot(true); 108 112 volume_display_timer->start(2000); 109 113 connect(volume_display_timer, SIGNAL(timeout()), … … 1171 1175 waiting_for_playlists_timer->start(100); // Restart Timer 1172 1176 } 1173 1177 1174 void PlaybackBoxMusic::changeVolume(bool up _or_down)1178 void PlaybackBoxMusic::changeVolume(bool up) 1175 1179 { 1176 if (volume_control && gPlayer->getOutput())1180 if (volume_control) 1177 1181 { 1178 if (up _or_down)1179 gPlayer->getOutput()->AdjustCurrentVolume(2);1182 if (up) 1183 volume_control->increaseVolume(); 1180 1184 else 1181 gPlayer->getOutput()->AdjustCurrentVolume(-2); 1182 showVolume(true); 1185 volume_control->decreaseVolume(); 1183 1186 } 1184 1187 } 1185 1188 … … 1197 1200 1198 1201 void PlaybackBoxMusic::toggleMute() 1199 1202 { 1200 if (volume_control && gPlayer->getOutput()) 1201 { 1202 gPlayer->getOutput()->ToggleMute(); 1203 showVolume(true); 1204 } 1203 if (volume_control) 1204 volume_control->setMute(!volume_control->mute()); 1205 1205 } 1206 1206 1207 1207 void PlaybackBoxMusic::toggleUpmix() … … 1232 1232 speed_status->refresh(); 1233 1233 } 1234 1234 1235 if (volume_control && gPlayer->getOutput())1235 if (volume_control) 1236 1236 { 1237 1237 if (volume_status) 1238 1238 { 1239 1239 if (on_or_off) 1240 1240 { 1241 volume_status->SetUsed( gPlayer->getOutput()->GetCurrentVolume());1241 volume_status->SetUsed(volume_control->mute() ? 0 : volume_control->volume()); 1242 1242 volume_status->SetOrder(0); 1243 1243 volume_status->refresh(); 1244 1244 volume_display_timer->setSingleShot(true); … … 1247 1247 lcd->switchToVolume("Music"); 1248 1248 1249 1249 volume_level = 1250 ( gPlayer->IsMuted()) ? 0.0f : gPlayer->GetVolume() * 0.01f;1250 (volume_control->mute()) ? 0.0f : volume_control->volume() * 0.01f; 1251 1251 1252 1252 if (class LCD *lcd = LCD::Get()) 1253 1253 lcd->setVolumeLevel(volume_level); … … 2431 2431 return true; 2432 2432 } 2433 2433 2434 void PlaybackBoxMusic::VolumeChanged(int) 2435 { 2436 showVolume(true); 2437 } 2438 2439 void PlaybackBoxMusic::MuteChanged(bool) 2440 { 2441 showVolume(true); 2442 } 2443 2434 2444 QString PlaybackBoxMusic::getTimeString(int exTime, int maxTime) 2435 2445 { 2436 2446 QString time_string; -
mythmusic/mythmusic/miniplayer.cpp
1 1 // mythtv 2 2 #include <mythtv/mythcontext.h> 3 3 #include <mythtv/lcddevice.h> 4 #include <libmyth/audiooutput.h> 4 5 5 6 // mythui 6 7 #include <mythtv/libmythui/mythuitext.h> … … 25 26 m_coverImage = NULL; 26 27 m_progressBar = NULL; 27 28 29 m_volumeControl = VolumeControlManager::GetControl(gContext->GetSetting("MixerDevice")); 30 if (m_volumeControl) 31 { 32 connect(m_volumeControl.data(), SIGNAL(changedVolume(int)), 33 this, SLOT(VolumeChanged(int))); 34 connect(m_volumeControl.data(), SIGNAL(changedMute(bool)), 35 this, SLOT(MuteChanged(bool))); 36 } 37 28 38 m_displayTimer = new QTimer(this); 29 39 m_displayTimer->setSingleShot(true); 30 40 connect(m_displayTimer, SIGNAL(timeout()), this, SLOT(timerTimeout())); … … 68 78 m_coverImage = dynamic_cast<MythUIImage *> (GetChild("coverart")); 69 79 m_progressBar = dynamic_cast<MythUIProgressBar *> (GetChild("progress")); 70 80 71 if (m_volText && gPlayer->getOutput())81 if (m_volText && m_volumeControl) 72 82 { 73 83 m_volFormat = m_volText->GetText(); 74 84 m_volText->SetText(QString(m_volFormat) 75 .arg((int) gPlayer->getOutput()->GetCurrentVolume()));85 .arg((int) m_volumeControl->volume())); 76 86 } 77 87 78 88 gPlayer->setListener(this); … … 172 182 } 173 183 else if (action == "VOLUMEDOWN") 174 184 { 175 if (gPlayer->getOutput()) 176 { 177 gPlayer->getOutput()->AdjustCurrentVolume(-2); 178 showVolume(); 179 } 185 if (m_volumeControl) 186 m_volumeControl->decreaseVolume(); 180 187 } 181 188 else if (action == "VOLUMEUP") 182 189 { 183 if (gPlayer->getOutput()) 184 { 185 gPlayer->getOutput()->AdjustCurrentVolume(2); 186 showVolume(); 187 } 190 if (m_volumeControl) 191 m_volumeControl->increaseVolume(); 188 192 } 189 193 else if (action == "MUTE") 190 194 { 191 if ( gPlayer->getOutput())195 if (m_volumeControl) 192 196 { 193 gPlayer->getOutput()->ToggleMute();197 m_volumeControl->setMute(!m_volumeControl->mute()); 194 198 195 199 if (m_infoText) 196 200 { 197 201 m_showingInfo = true; 198 if ( gPlayer->IsMuted())202 if (m_volumeControl->mute()) 199 203 m_infoText->SetText(tr("Mute: On")); 200 204 else 201 205 m_infoText->SetText(tr("Mute: Off")); … … 209 213 210 214 if (m_volText) 211 215 { 212 if ( gPlayer->IsMuted())216 if (m_volumeControl->mute()) 213 217 m_volText->SetText(QString(m_volFormat).arg(0)); 214 218 else 215 219 m_volText->SetText(QString(m_volFormat) 216 .arg( (int) gPlayer->getOutput()->GetCurrentVolume()));220 .arg(m_volumeControl->volume())); 217 221 } 218 222 } 219 223 } … … 554 558 lcd->switchToMusic(mdata->Artist(), mdata->Album(), mdata->Title()); 555 559 } 556 560 561 void MiniPlayer::VolumeChanged(int) 562 { 563 showVolume(); 564 } 565 566 void MiniPlayer::MuteChanged(bool) 567 { 568 showVolume(); 569 } 570 557 571 void MiniPlayer::showShuffleMode(void) 558 572 { 559 573 if (m_infoText) … … 645 659 646 660 void MiniPlayer::showVolume(void) 647 661 { 648 float level = (float)gPlayer->getOutput()->GetCurrentVolume();649 bool muted = gPlayer->IsMuted();662 float level = static_cast<float>(m_volumeControl->volume()); 663 bool muted = m_volumeControl->mute(); 650 664 651 665 if (m_infoText) 652 666 { -
mythmusic/mythmusic/musicplayer.h
2 2 #define MUSICPLAYER_H_ 3 3 4 4 #include <mythtv/mythdialogs.h> 5 #include <mythtv/audiooutput.h>6 5 7 6 #include "metadata.h" 8 7 … … 22 21 void setVisual(MainVisual *visual); 23 22 void setCDDevice(const QString &dev) { m_CDdevice = dev; } 24 23 25 void mute(void) {};26 void unMute(void) {};27 void setVolume(void) {};28 29 24 void setSpeed(float speed); 30 25 void incSpeed(); 31 26 void decSpeed(); … … 52 47 53 48 Decoder *getDecoder(void) { return m_decoder; } 54 49 AudioOutput *getOutput(void) { return m_output; } 55 MuteState GetMuteState(void) const;56 uint GetVolume(void) const;57 bool IsMuted(void) const { return GetMuteState() == kMuteAll; }58 50 59 51 GenericTree *constructPlaylist(void); 60 52 GenericTree *getPlaylistTree() { return m_playlistTree; } -
mythmusic/mythmusic/musicplayer.cpp
359 359 360 360 // TODO: Error checking that device is opened correctly! 361 361 m_output = AudioOutput::OpenAudio(adevice, pdevice, 16, 2, 0, 44100, 362 AUDIOOUTPUT_MUSIC, true,false,362 AUDIOOUTPUT_MUSIC, false, 363 363 gContext->GetNumSetting("MusicDefaultUpmix", 0) + 1); 364 364 m_output->setBufferSize(256 * 1024); 365 365 m_output->SetBlocking(false); … … 852 852 m_playSpeed -= 0.05; 853 853 setSpeed(m_playSpeed); 854 854 } 855 856 uint MusicPlayer::GetVolume(void) const857 {858 if (m_output)859 return m_output->GetCurrentVolume();860 return 0;861 }862 863 MuteState MusicPlayer::GetMuteState(void) const864 {865 if (m_output)866 return m_output->GetMuteState();867 return kMuteAll;868 } -
mythmusic/mythmusic/playbackbox.h
8 8 // mythtv 9 9 #include <mythtv/mythwidgets.h> 10 10 #include <mythtv/dialogbox.h> 11 #include < mythtv/audiooutput.h>11 #include <libmyth/volumecontrolmanager.h> 12 12 13 13 // mythmusic 14 14 #include "mainvisual.h" … … 101 101 bool getInsertPLOptions(InsertPLOption &insertOption, 102 102 PlayPLOption &playOption, bool &bRemoveDups); 103 103 104 protected slots: 105 void VolumeChanged(int volume); 106 void MuteChanged(bool mute); 107 104 108 signals: 105 109 106 110 void dummy(); // debugging … … 172 176 bool show_album_art; 173 177 bool show_whole_tree; 174 178 bool keyboard_accelerators; 175 bool volume_control;179 QSharedPointer<VolumeControl> volume_control; ///< Volume Control interface 176 180 177 181 QString exit_action; 178 182 -
mythmusic/mythmusic/miniplayer.h
1 1 #ifndef MINIPLAYER_H_ 2 2 #define MINIPLAYER_H_ 3 3 4 #include <libmyth/volumecontrolmanager.h> 4 5 #include <mythtv/libmythui/mythscreentype.h> 5 6 6 7 class MusicPlayer; … … 27 28 void timerTimeout(void); 28 29 void showInfoTimeout(void); 29 30 31 protected slots: 32 void VolumeChanged(int volume); 33 void MuteChanged(bool mute); 34 30 35 private: 31 36 QString getTimeString(int exTime, int maxTime); 32 37 void updateTrackInfo(Metadata *mdata); … … 44 49 int m_currTime, m_maxTime; 45 50 46 51 MusicPlayer *m_parentPlayer; 52 QSharedPointer<VolumeControl> m_volumeControl; ///< Volume Control interface 47 53 48 54 QTimer *m_displayTimer; 49 55 QTimer *m_infoTimer;