No QtAudio device issue solved

Closes issue #2308.
This commit is contained in:
Toondad 2020-04-30 00:46:17 +02:00
parent a6289ae9fa
commit 9c463830ce
5 changed files with 59 additions and 25 deletions

View file

@ -17,7 +17,7 @@ Building OpenToonz from source requires the following dependencies:
### Installing Dependencies on Debian / Ubuntu ### Installing Dependencies on Debian / Ubuntu
``` ```
$ sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 $ sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libqt5multimedia5-plugins
``` ```
For newest versions of OS you may install libmypaint from repository and don't need to build it from source: For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
@ -33,7 +33,7 @@ Notes:
(it may include some useless packages) (it may include some useless packages)
``` ```
$ sudo dnf install gcc gcc-c++ automake git cmake boost boost-devel SuperLU SuperLU-devel lz4-devel lzma libusb-devel lzo-devel libjpeg-turbo-devel libGLEW glew-devel freeglut-devel freeglut freetype-devel libpng-devel qt5-qtbase-devel qt5-qtsvg qt5-qtsvg-devel qt5-qtscript qt5-qtscript-devel qt5-qttools qt5-qttools-devel qt5-qtmultimedia-devel blas blas-devel json-c-devel libtool intltool make $ sudo dnf install gcc gcc-c++ automake git cmake boost boost-devel SuperLU SuperLU-devel lz4-devel lzma libusb-devel lzo-devel libjpeg-turbo-devel libGLEW glew-devel freeglut-devel freeglut freetype-devel libpng-devel qt5-qtbase-devel qt5-qtsvg qt5-qtsvg-devel qt5-qtscript qt5-qtscript-devel qt5-qttools qt5-qttools-devel qt5-qtmultimedia-devel blas blas-devel json-c-devel libtool intltool make qt5-qtmultimedia
``` ```
For newest versions of OS you may install libmypaint from repository and don't need to build it from source: For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
@ -60,7 +60,7 @@ Notes:
### Installing Dependencies on openSUSE ### Installing Dependencies on openSUSE
``` ```
$ zypper in boost-devel cmake freeglut-devel freetype2-devel gcc-c++ glew-devel libQt5OpenGL-devel libjpeg-devel liblz4-devel libpng16-compat-devel libqt5-linguist-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtscript-devel libqt5-qtsvg-devel libtiff-devel libusb-devel lzo-devel openblas-devel pkgconfig sed superlu-devel zlib-devel json-c-devel $ zypper in boost-devel cmake freeglut-devel freetype2-devel gcc-c++ glew-devel libQt5OpenGL-devel libjpeg-devel liblz4-devel libpng16-compat-devel libqt5-linguist-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel libqt5-qtscript-devel libqt5-qtsvg-devel libtiff-devel libusb-devel lzo-devel openblas-devel pkgconfig sed superlu-devel zlib-devel json-c-devel libqt5-qtmultimedia
``` ```
For newest versions of OS you may install libmypaint from repository and don't need to build it from source: For newest versions of OS you may install libmypaint from repository and don't need to build it from source:

View file

@ -248,6 +248,7 @@ Range in seconds
class TSoundDeviceException final : public TException { class TSoundDeviceException final : public TException {
public: public:
enum Type { enum Type {
NoDevice, // no device found
FailedInit, // fallimento del costruttore FailedInit, // fallimento del costruttore
UnableOpenDevice, UnableOpenDevice,
UnableCloseDevice, UnableCloseDevice,

View file

@ -808,7 +808,15 @@ bool SceneViewerPanel::hasSoundtrack() {
TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet(); TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties();
if (!m_sceneViewer->isPreviewEnabled()) prop->m_isPreview = true; if (!m_sceneViewer->isPreviewEnabled()) prop->m_isPreview = true;
m_sound = xsheetHandle->getXsheet()->makeSound(prop); try {
m_sound = xsheetHandle->getXsheet()->makeSound(prop);
} catch (TSoundDeviceException &e) {
if (e.getType() == TSoundDeviceException::NoDevice) {
std::cout << ::to_string(e.getMessage()) << std::endl;
} else {
throw TSoundDeviceException(e.getType(), e.getMessage());
}
}
if (m_sound == NULL) { if (m_sound == NULL) {
m_hasSoundtrack = false; m_hasSoundtrack = false;
return false; return false;
@ -847,4 +855,4 @@ void SceneViewerPanel::save(QSettings &settings) const {
void SceneViewerPanel::load(QSettings &settings) { void SceneViewerPanel::load(QSettings &settings) {
m_visiblePartsFlag = settings.value("visibleParts", CVPARTS_ALL).toUInt(); m_visiblePartsFlag = settings.value("visibleParts", CVPARTS_ALL).toUInt();
updateShowHide(); updateShowHide();
} }

View file

@ -1475,20 +1475,28 @@ TSoundTrack *TXsheet::makeSound(SoundProperties *properties) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TXsheet::scrub(int frame, bool isPreview) { void TXsheet::scrub(int frame, bool isPreview) {
double fps = try {
double fps =
getScene()->getProperties()->getOutputProperties()->getFrameRate(); getScene()->getProperties()->getOutputProperties()->getFrameRate();
TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties();
prop->m_isPreview = isPreview; prop->m_isPreview = isPreview;
TSoundTrack *st = makeSound(prop); // Absorbs prop's ownership TSoundTrack *st = makeSound(prop); // Absorbs prop's ownership
if (!st) return; if (!st) return;
double samplePerFrame = st->getSampleRate() / fps; double samplePerFrame = st->getSampleRate() / fps;
double s0 = frame * samplePerFrame, s1 = s0 + samplePerFrame; double s0 = frame * samplePerFrame, s1 = s0 + samplePerFrame;
play(st, s0, s1, false); play(st, s0, s1, false);
} catch (TSoundDeviceException &e) {
if (e.getType() == TSoundDeviceException::NoDevice) {
std::cout << ::to_string(e.getMessage()) << std::endl;
} else {
throw TSoundDeviceException(e.getType(), e.getMessage());
}
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1766,4 +1774,4 @@ void TXsheet::autoInputCellNumbers(int increment, int interval, int step,
row++; row++;
} }
} }
} }

View file

@ -845,17 +845,25 @@ void TXshSoundColumn::play(ColumnLevel *columnLevel, int currentFrame) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void TXshSoundColumn::play(int currentFrame) { void TXshSoundColumn::play(int currentFrame) {
TSoundTrackP soundTrack = getOverallSoundTrack(currentFrame); try {
TSoundTrackP soundTrack = getOverallSoundTrack(currentFrame);
if (!soundTrack) return; if (!soundTrack) return;
int spf = m_levels.at(0)->getSoundLevel()->getSamplePerFrame(); int spf = m_levels.at(0)->getSoundLevel()->getSamplePerFrame();
int startFrame = (currentFrame - getFirstRow()); int startFrame = (currentFrame - getFirstRow());
int s0 = startFrame * spf; int s0 = startFrame * spf;
int s1 = getMaxFrame() * spf; int s1 = getMaxFrame() * spf;
play(soundTrack, s0, s1, false); play(soundTrack, s0, s1, false);
} catch (TSoundDeviceException &e) {
if (e.getType() == TSoundDeviceException::NoDevice) {
std::cout << ::to_string(e.getMessage()) << std::endl;
} else {
throw TSoundDeviceException(e.getType(), e.getMessage());
}
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -943,10 +951,17 @@ void TXshSoundColumn::onTimerOut() {
void TXshSoundColumn::scrub(int fromFrame, int toFrame) { void TXshSoundColumn::scrub(int fromFrame, int toFrame) {
if (!isCamstandVisible()) return; if (!isCamstandVisible()) return;
TSoundTrackP soundTrack = getOverallSoundTrack(fromFrame, toFrame + 1); try {
if (!soundTrack) return; TSoundTrackP soundTrack = getOverallSoundTrack(fromFrame, toFrame + 1);
if (!soundTrack) return;
play(soundTrack, 0, soundTrack->getSampleCount(), false); play(soundTrack, 0, soundTrack->getSampleCount(), false);
} catch (TSoundDeviceException &e) {
if (e.getType() == TSoundDeviceException::NoDevice) {
std::cout << ::to_string(e.getMessage()) << std::endl;
} else {
throw TSoundDeviceException(e.getType(), e.getMessage());
}
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1006,6 +1021,8 @@ TSoundTrackP TXshSoundColumn::getOverallSoundTrack(int fromFrame, int toFrame,
if (format.m_sampleRate >= 44100) format.m_sampleRate = 22050; if (format.m_sampleRate >= 44100) format.m_sampleRate = 22050;
#else #else
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (info.deviceName().length() == 0) throw TSoundDeviceException(TSoundDeviceException::NoDevice,
"No device found, check QAudio backends");
QList<int> ssrs = info.supportedSampleRates(); QList<int> ssrs = info.supportedSampleRates();
if (!ssrs.contains(format.m_sampleRate)) format.m_sampleRate = 44100; if (!ssrs.contains(format.m_sampleRate)) format.m_sampleRate = 44100;
QAudioFormat qFormat; QAudioFormat qFormat;