mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:30:04 +00:00 
			
		
		
		
	Audio should follow default device
This commit is contained in:
		
							parent
							
								
									3ad3c98daf
								
							
						
					
					
						commit
						e1ccc1ebb8
					
				
					 1 changed files with 14 additions and 5 deletions
				
			
		|  | @ -3,6 +3,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <QAudioDevice> | #include <QAudioDevice> | ||||||
| #include <QAudioOutput> | #include <QAudioOutput> | ||||||
|  | #include <QMediaDevices> | ||||||
| #include <QMediaPlayer> | #include <QMediaPlayer> | ||||||
| #include <QUrl> | #include <QUrl> | ||||||
| 
 | 
 | ||||||
|  | @ -21,15 +22,15 @@ class MediaManager::Impl | ||||||
| public: | public: | ||||||
|    explicit Impl(MediaManager* self) : |    explicit Impl(MediaManager* self) : | ||||||
|        self_ {self}, |        self_ {self}, | ||||||
|  |        mediaDevices_ {new QMediaDevices(self)}, | ||||||
|        mediaPlayer_ {new QMediaPlayer(self)}, |        mediaPlayer_ {new QMediaPlayer(self)}, | ||||||
|        audioOutput_ {new QAudioOutput(self)} |        audioOutput_ {new QAudioOutput(self)} | ||||||
|    { |    { | ||||||
|       audioOutput_->setVolume(1.0f); |  | ||||||
|       mediaPlayer_->setAudioOutput(audioOutput_); |  | ||||||
| 
 |  | ||||||
|       logger_->debug("Audio device: {}", |       logger_->debug("Audio device: {}", | ||||||
|                      audioOutput_->device().description().toStdString()); |                      audioOutput_->device().description().toStdString()); | ||||||
| 
 | 
 | ||||||
|  |       mediaPlayer_->setAudioOutput(audioOutput_); | ||||||
|  | 
 | ||||||
|       ConnectSignals(); |       ConnectSignals(); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | @ -39,6 +40,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    MediaManager* self_; |    MediaManager* self_; | ||||||
| 
 | 
 | ||||||
|  |    QMediaDevices* mediaDevices_; | ||||||
|    QMediaPlayer*  mediaPlayer_; |    QMediaPlayer*  mediaPlayer_; | ||||||
|    QAudioOutput*  audioOutput_; |    QAudioOutput*  audioOutput_; | ||||||
| }; | }; | ||||||
|  | @ -48,6 +50,13 @@ MediaManager::~MediaManager() = default; | ||||||
| 
 | 
 | ||||||
| void MediaManager::Impl::ConnectSignals() | void MediaManager::Impl::ConnectSignals() | ||||||
| { | { | ||||||
|  |    QObject::connect( | ||||||
|  |       mediaDevices_, | ||||||
|  |       &QMediaDevices::audioOutputsChanged, | ||||||
|  |       self_, | ||||||
|  |       [this]() | ||||||
|  |       { audioOutput_->setDevice(QMediaDevices::defaultAudioOutput()); }); | ||||||
|  | 
 | ||||||
|    QObject::connect(audioOutput_, |    QObject::connect(audioOutput_, | ||||||
|                     &QAudioOutput::deviceChanged, |                     &QAudioOutput::deviceChanged, | ||||||
|                     self_, |                     self_, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat