From 9c463830ce9a701c20acfc7f6139a297788229f1 Mon Sep 17 00:00:00 2001 From: Toondad <63920597+Toondad@users.noreply.github.com> Date: Apr 29 2020 22:46:17 +0000 Subject: No QtAudio device issue solved Closes issue #2308. --- diff --git a/doc/how_to_build_linux.md b/doc/how_to_build_linux.md index aba9d47..e82fe81 100644 --- a/doc/how_to_build_linux.md +++ b/doc/how_to_build_linux.md @@ -17,7 +17,7 @@ Building OpenToonz from source requires the following dependencies: ### 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: @@ -33,7 +33,7 @@ Notes: (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: @@ -60,7 +60,7 @@ Notes: ### 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: diff --git a/toonz/sources/include/tsound.h b/toonz/sources/include/tsound.h index b75b150..1adfe8f 100644 --- a/toonz/sources/include/tsound.h +++ b/toonz/sources/include/tsound.h @@ -248,6 +248,7 @@ Range in seconds class TSoundDeviceException final : public TException { public: enum Type { + NoDevice, // no device found FailedInit, // fallimento del costruttore UnableOpenDevice, UnableCloseDevice, diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp index 0162959..dd44f57 100644 --- a/toonz/sources/toonz/viewerpane.cpp +++ b/toonz/sources/toonz/viewerpane.cpp @@ -808,7 +808,15 @@ bool SceneViewerPanel::hasSoundtrack() { TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet(); TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); 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) { m_hasSoundtrack = false; return false; @@ -847,4 +855,4 @@ void SceneViewerPanel::save(QSettings &settings) const { void SceneViewerPanel::load(QSettings &settings) { m_visiblePartsFlag = settings.value("visibleParts", CVPARTS_ALL).toUInt(); updateShowHide(); -} \ No newline at end of file +} diff --git a/toonz/sources/toonzlib/txsheet.cpp b/toonz/sources/toonzlib/txsheet.cpp index e5f2798..9cd8d5c 100644 --- a/toonz/sources/toonzlib/txsheet.cpp +++ b/toonz/sources/toonzlib/txsheet.cpp @@ -1475,20 +1475,28 @@ TSoundTrack *TXsheet::makeSound(SoundProperties *properties) { //----------------------------------------------------------------------------- void TXsheet::scrub(int frame, bool isPreview) { - double fps = + try { + double fps = getScene()->getProperties()->getOutputProperties()->getFrameRate(); - TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); - prop->m_isPreview = isPreview; + TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); + prop->m_isPreview = isPreview; - TSoundTrack *st = makeSound(prop); // Absorbs prop's ownership - if (!st) return; + TSoundTrack *st = makeSound(prop); // Absorbs prop's ownership + 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++; } } -} \ No newline at end of file +} diff --git a/toonz/sources/toonzlib/txshsoundcolumn.cpp b/toonz/sources/toonzlib/txshsoundcolumn.cpp index dd27a7a..2d46dc4 100644 --- a/toonz/sources/toonzlib/txshsoundcolumn.cpp +++ b/toonz/sources/toonzlib/txshsoundcolumn.cpp @@ -845,17 +845,25 @@ void TXshSoundColumn::play(ColumnLevel *columnLevel, 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 startFrame = (currentFrame - getFirstRow()); + int spf = m_levels.at(0)->getSoundLevel()->getSamplePerFrame(); + int startFrame = (currentFrame - getFirstRow()); - int s0 = startFrame * spf; - int s1 = getMaxFrame() * spf; + int s0 = startFrame * 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) { if (!isCamstandVisible()) return; - TSoundTrackP soundTrack = getOverallSoundTrack(fromFrame, toFrame + 1); - if (!soundTrack) return; - - play(soundTrack, 0, soundTrack->getSampleCount(), false); + try { + TSoundTrackP soundTrack = getOverallSoundTrack(fromFrame, toFrame + 1); + if (!soundTrack) return; + 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; #else QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (info.deviceName().length() == 0) throw TSoundDeviceException(TSoundDeviceException::NoDevice, + "No device found, check QAudio backends"); QList ssrs = info.supportedSampleRates(); if (!ssrs.contains(format.m_sampleRate)) format.m_sampleRate = 44100; QAudioFormat qFormat;