Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 547:82d7e5cf7517 bqaudioio
Audio device selection
author | Chris Cannam |
---|---|
date | Wed, 07 Dec 2016 11:50:54 +0000 |
parents | 56acd9368532 |
children | baa11365ebdd |
comparison
equal
deleted
inserted
replaced
474:fdce8a452b19 | 547:82d7e5cf7517 |
---|---|
2162 void | 2162 void |
2163 MainWindowBase::createPlayTarget() | 2163 MainWindowBase::createPlayTarget() |
2164 { | 2164 { |
2165 if (m_playTarget) return; | 2165 if (m_playTarget) return; |
2166 | 2166 |
2167 //!!! how to handle preferences | |
2168 /* | |
2169 QSettings settings; | 2167 QSettings settings; |
2170 settings.beginGroup("Preferences"); | 2168 settings.beginGroup("Preferences"); |
2171 QString targetName = settings.value("audio-target", "").toString(); | 2169 QString implementation = settings.value |
2170 ("audio-target", "").toString(); | |
2171 QString suffix; | |
2172 if (implementation != "") suffix = "-" + implementation; | |
2173 QString recordDevice = settings.value | |
2174 ("audio-record-device" + suffix, "").toString(); | |
2175 QString playbackDevice = settings.value | |
2176 ("audio-playback-device" + suffix, "").toString(); | |
2172 settings.endGroup(); | 2177 settings.endGroup(); |
2173 AudioTargetFactory *factory = AudioTargetFactory::getInstance(); | 2178 |
2174 | 2179 if (implementation == "auto") { |
2175 factory->setDefaultCallbackTarget(targetName); | 2180 implementation = ""; |
2176 */ | 2181 } |
2177 | 2182 |
2178 m_playTarget = | 2183 breakfastquay::AudioFactory::Preference preference; |
2179 breakfastquay::AudioFactory::createCallbackPlayTarget(m_playSource); | 2184 preference.implementation = implementation.toStdString(); |
2180 | 2185 preference.recordDevice = recordDevice.toStdString(); |
2181 m_playSource->setSystemPlaybackTarget(m_playTarget); | 2186 preference.playbackDevice = playbackDevice.toStdString(); |
2182 | 2187 |
2183 if (!m_playTarget) { | 2188 SVCERR << "createAudioIO: Preferred implementation = \"" |
2189 << preference.implementation << "\"" << endl; | |
2190 SVCERR << "createAudioIO: Preferred playback device = \"" | |
2191 << preference.playbackDevice << "\"" << endl; | |
2192 SVCERR << "createAudioIO: Preferred record device = \"" | |
2193 << preference.recordDevice << "\"" << endl; | |
2194 | |
2195 if (m_soundOptions & WithAudioInput) { | |
2196 m_audioIO = breakfastquay::AudioFactory:: | |
2197 createCallbackIO(m_recordTarget, m_playSource, preference); | |
2198 if (m_audioIO) { | |
2199 m_audioIO->suspend(); // start in suspended state | |
2200 m_playSource->setSystemPlaybackTarget(m_audioIO); | |
2201 } | |
2202 } else { | |
2203 m_playTarget = breakfastquay::AudioFactory:: | |
2204 createCallbackPlayTarget(m_playSource, preference); | |
2205 if (m_playTarget) { | |
2206 m_playTarget->suspend(); // start in suspended state | |
2207 m_playSource->setSystemPlaybackTarget(m_playTarget); | |
2208 } | |
2209 } | |
2210 | |
2211 if (!m_playTarget && !m_audioIO) { | |
2184 emit hideSplash(); | 2212 emit hideSplash(); |
2185 | 2213 if (implementation == "") { |
2186 // if (factory->isAutoCallbackTarget(targetName)) { | |
2187 QMessageBox::warning | 2214 QMessageBox::warning |
2188 (this, tr("Couldn't open audio device"), | 2215 (this, tr("Couldn't open audio device"), |
2189 tr("<b>No audio available</b><p>Could not open an audio device for playback.<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"), | 2216 tr("<b>No audio available</b><p>Could not open an audio device for playback.<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"), |
2190 QMessageBox::Ok); | 2217 QMessageBox::Ok); |
2191 /* | |
2192 } else { | 2218 } else { |
2193 QMessageBox::warning | 2219 QMessageBox::warning |
2194 (this, tr("Couldn't open audio device"), | 2220 (this, tr("Couldn't open audio device"), |
2195 tr("<b>No audio available</b><p>Failed to open your preferred audio device (\"%1\").<p>Audio playback will not be available during this session.</p>") | 2221 tr("<b>No audio available</b><p>Failed to open your preferred audio device (\"%1\").<p>Audio playback will not be available during this session.</p>") |
2196 .arg(factory->getCallbackTargetDescription(targetName)), | 2222 .arg(breakfastquay::AudioFactory:: |
2223 getImplementationDescription(implementation.toStdString()) | |
2224 .c_str()), | |
2197 QMessageBox::Ok); | 2225 QMessageBox::Ok); |
2198 } | 2226 } |
2199 */ | |
2200 } | 2227 } |
2201 } | 2228 } |
2202 | 2229 |
2203 WaveFileModel * | 2230 WaveFileModel * |
2204 MainWindowBase::getMainModel() | 2231 MainWindowBase::getMainModel() |