From 10950bd702269db645754e5751b5ea8832624098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fauconnier?= Date: Wed, 26 Feb 2020 09:39:51 +0100 Subject: [PATCH] rollback to windowsmedia + fix on audio crash --- src/podcast/UBPodcastController.cpp | 16 ++++++++++++++-- src/podcast/podcast.pri | 15 ++++++--------- src/podcast/windowsmedia/UBWaveRecorder.cpp | 5 ++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/podcast/UBPodcastController.cpp b/src/podcast/UBPodcastController.cpp index 35b00563..0a33ab32 100644 --- a/src/podcast/UBPodcastController.cpp +++ b/src/podcast/UBPodcastController.cpp @@ -59,8 +59,8 @@ #ifdef Q_OS_WIN - #include "ffmpeg/UBFFmpegVideoEncoder.h" - #include "ffmpeg/UBMicrophoneInput.h" + #include "windowsmedia/UBWindowsMediaVideoEncoder.h" + #include "windowsmedia/UBWaveRecorder.h" #elif defined(Q_OS_OSX) #include "ffmpeg/UBFFmpegVideoEncoder.h" #include "ffmpeg/UBMicrophoneInput.h" @@ -308,7 +308,13 @@ void UBPodcastController::start() applicationMainModeChanged(UBApplication::applicationController->displayMode()); +#ifdef Q_OS_WIN + mVideoEncoder = new UBWindowsMediaVideoEncoder(this); //deleted on stop +#elif defined(Q_OS_OSX) + mVideoEncoder = new UBFFmpegVideoEncoder(this); +#elif defined(Q_OS_LINUX) mVideoEncoder = new UBFFmpegVideoEncoder(this); +#endif if (mVideoEncoder) { @@ -799,7 +805,13 @@ QStringList UBPodcastController::audioRecordingDevices() { QStringList devices; +#ifdef Q_OS_WIN + devices = UBWaveRecorder::waveInDevices(); +#elif defined(Q_OS_OSX) devices = UBMicrophoneInput::availableDevicesNames(); +#elif defined(Q_OS_LINUX) + devices = UBMicrophoneInput::availableDevicesNames(); +#endif return devices; } diff --git a/src/podcast/podcast.pri b/src/podcast/podcast.pri index 1e0f0673..e96263fa 100644 --- a/src/podcast/podcast.pri +++ b/src/podcast/podcast.pri @@ -13,16 +13,13 @@ SOURCES += src/podcast/UBPodcastController.cpp \ win32 { - SOURCES += src/podcast/ffmpeg/UBFFmpegVideoEncoder.cpp \ - src/podcast/ffmpeg/UBMicrophoneInput.cpp - - HEADERS += src/podcast/ffmpeg/UBFFmpegVideoEncoder.h \ - src/podcast/ffmpeg/UBMicrophoneInput.h - - LIBS += -L$$PWD/../OpenBoard-ThirdParty/ffmpeg/lib/ -lavformat -lavcodec -lswscale -lswresample -lavutil + SOURCES += src/podcast/windowsmedia/UBWindowsMediaVideoEncoder.cpp \ + src/podcast/windowsmedia/UBWindowsMediaFile.cpp \ + src/podcast/windowsmedia/UBWaveRecorder.cpp - INCLUDEPATH += $$PWD/../OpenBoard-ThirdParty/ffmpeg/include - DEPENDPATH += $$PWD/../OpenBoard-ThirdParty/ffmpeg/include + HEADERS += src/podcast/windowsmedia/UBWindowsMediaVideoEncoder.h \ + src/podcast/windowsmedia/UBWindowsMediaFile.h \ + src/podcast/windowsmedia/UBWaveRecorder.h } macx { diff --git a/src/podcast/windowsmedia/UBWaveRecorder.cpp b/src/podcast/windowsmedia/UBWaveRecorder.cpp index 1ae94e3f..f1142100 100644 --- a/src/podcast/windowsmedia/UBWaveRecorder.cpp +++ b/src/podcast/windowsmedia/UBWaveRecorder.cpp @@ -76,8 +76,7 @@ bool UBWaveRecorder::init(const QString& waveInDeviceName) } } - WAVEFORMATEX format; - format.cbSize = 0; + WAVEFORMATEX format = {0}; format.wFormatTag = WAVE_FORMAT_PCM; format.nChannels = mNbChannels; format.wBitsPerSample = mBitsPerSample; @@ -85,7 +84,7 @@ bool UBWaveRecorder::init(const QString& waveInDeviceName) format.nBlockAlign = format.nChannels * (format.wBitsPerSample / 8); format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; - if (waveInOpen(&mWaveInDevice, deviceID, &format, (DWORD)waveInProc, (DWORD_PTR)this, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) + if (waveInOpen(&mWaveInDevice, deviceID, &format, reinterpret_cast(waveInProc), reinterpret_cast(this), CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { setLastErrorMessage("Cannot open wave in device "); return false;