summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio
Commit message (Collapse)AuthorAgeFilesLines
* Implement QAudioBufferInput and QVideoFrameInputArtem Dyomin4 days2-8/+134
| | | | | | | | | [ChangeLog] Added classes QAudioBufferInput and QVideoFrameInput allowing to send custom media data to QMediaRecorder. Task-number: QTBUG-125401 Change-Id: I8792f84e39f44eabb9349e3ea1d90c1b4cc971ca Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* Harden binding source to encoder in the RecordingEngineArtem Dyomin6 days1-4/+4
| | | | | | | | | | | | * used QMediaInputEncoderInterface instead of a functor * used functions connect***/disconnect*** to for consistency * added comments to the code Task-number: QTBUG-125401 Change-Id: I3e12bb4c0229fe9631b6608c66705703ce99aa1f Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io>
* Implement private classes for QVideoFrameInput and QAudioBufferInputArtem Dyomin7 days1-0/+75
| | | | | | | | | | | | | | The private classes will be used by public API in following CRs. Implemented logic of handling and emitting 'readyToSendFrame', and capture session changing, for both classes, QVideoFrameInput and QAudioBufferInput. Task-number: QTBUG-125401 Change-Id: Id86ec324017013fdd95454fe4adcabbc492e8bc5 Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io> Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* Apply clazy's old-style-connectTim Blechmann2024-05-032-9/+10
| | | | | | | | | Pointer-to-member syntax is faster, has improved type safety and is more tooling friendly. Pick-to: 6.5 6.7 Change-Id: If629ba3fe29bfa88014ee07d9641b77e030e7de8 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Add missing implementation for QWaveDecoder::setIODeviceDoris Verria2024-04-221-0/+4
| | | | | | | | | | | | QWaveDecoder defines setIODevice but the implementation is missing. This was giving missing symbol errors for Python bindings. Add an empty implementation for now to avoid those. Pick-to: 6.7 6.5 6.2 Change-Id: I8ed41df6ccc3075dd79292a28a18f73dbd4d145e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* QAudioDecoder: fix unit tests for GStreamerTim Blechmann2024-04-173-38/+107
| | | | | | | | | | | | | | | When setting a QUrl with an empty scheme, we need to set the file:// pattern for uridecodebin. This has been done for QMediaPlayer in the past, but not for QAudioDecoder. Compare: 8a3806f6263f56b5be5b557e321b9b13d1913d5f To keep consistency with QMediaPlayer, we introduce a QAudioDecoderPrivate class. Pick-to: 6.5 6.7 Task-number: QTBUG-96985 Change-Id: If954a04a003aecb0f862a7e5041ead43e4c9d259 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Fix ABI breakage wrt QAudioSink/Source::stateChanged signalsVolker Hilsheimer2024-04-056-24/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends edaec2bf714c98d65f12c8ed9a2ffbd1603635a7, which removed the QAudioSink/Source::stateChanged(QAudio::State) symbols from the API, thus breaking binary compatibility to Qt 6.6. Since moc-generated code compares pointer-to-member- functions, we cannot bring that symbol back and still have such connections work. The only reasonable way to fix this is to reverse the namespace aliasing: QAudio is the real namespace, QtAudio becomes an alias. All symbols are then exported with the QAudio type in their signature, even if declared with QtAudio types as parameters, so we don't need any removed_api tricks to bring the old symbols back. We just need to trick qdoc into seeing the namespace as QtAudio, which is trivial and has no ABI implications. The previous caveat that string-based connections need to use QAudio doesn't change with this. [ChangeLog][Binary Compatibility Note] Qt 6.7.0 broke binary compatibility by renaming the QAudio namespace to QtAudio. Qt 6.7.1 restores compatibility with previous Qt 6 versions again by making QtAudio an alias for the QAudio namespace, but breaks BC with 6.7.0. Code previously built against 6.7.0 needs to be recompiled. Pick-to: 6.7 Fixes: QTBUG-123997 Change-Id: I456db61ff0bd1d97af7ce2d2a7968999d891a84d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* Tie Qt Multimedia backend lifetime to Qt Application lifetimeJøger Hansegård2024-03-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | This patch uses a specialized application static variable to tie backend lifetime to the Qt application lifetime if an application is present. This ensures that system resources are released before static destruction, and prevents abrupt termination on Windows during static destruction. This is according to Windows Media Foundation's documentation that states that WMF classes shall not be released during static destruction. If Qt Multimedia features are used without a Qt Application object, the lifetime of the multimedia backend remains as before, and destruction takes place as part of static destruction. As a side effect, this change fixes a crash if Qt Multimedia features are used after recreating the Qt Application. Fixes: QTBUG-120198 Pick-to: 6.7 6.6 6.5 Change-Id: I570743d6462e27630d8f29dc60cfa414c8cbc17d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Get SPDX license tag on one line onlyLucie Gérard2024-03-262-4/+2
| | | | | | | | | If spread on two lines, the license test does not read the entire tag Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I2703440020b36ea2838034d50a7e03aa2404fc4a Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Simplify lifetime management of QPlatformAudioResamplerJøger Hansegård2024-03-081-7/+7
| | | | | | | | | | | | | | | | | | QPlatformMediaIntegration creates various objects, and return them as QMaybe<Type*>. This moves responsibility of ownership to the caller. This patch makes the createAudioResampler function return the resampler as QMaybe<std::unique_ptr<Type>> which simplifies lifetime management. This introduces an asymmetry with other factory functions, but this is a step in the right direction Pick-to: 6.7 6.6 6.5 Change-Id: Id2f67597c8d8271b184321d138e126edff5f3202 Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Lars Sutterud <lars.sutterud@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* Play entire sound with resampled data in QSoundEffectJøger Hansegård2024-02-281-3/+4
| | | | | | | | | | | | | | | | | | | | If FFmpeg resampler is used to convert an audio signal from mono to stereo in QSoundEffect, the number of bytes of data doubles. This patch makes sure that the byte count of the resampled buffer is used instead of the number of bytes in the raw sample buffer. Before this patch, QSoundEffect could only play the first half of a WAV file if the file contained mono signals. This change makes sense for both the QSoundEffectPrivate size() and bytesAvailable() functions because QSoundEffectPrivate can only read data from the resampled audio buffer, never from the raw sample buffer. Amends: f0016c4763361292c3eaf153e184b9b110f44c61 Fixes: QTBUG-122750 Pick-to: 6.7 6.6 6.5 Change-Id: Icbfa6f5c4b5f85d02dca875e76f01a046ce49143 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Move ownership of media devices to platform media integrationJøger Hansegård2024-02-283-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This change removes the PlatformMediaDevices singleton instance, and moves ownership to the platform integration layer. This makes it easier to reason around object lifetimes during destruction, and will later allow us to fix issues on the Windows Platform related to uninitialization of the Windows Media Foundation. This uninitialization must be done before static destruction takes place. As a side effect, we no longer need hooks to mock media devices in unit tests. If no media backend is available, we use a fallback media integration that provides basic support needed by QMediaDevices, QAudioDevice, QSoundEffect, QAudioSink, and QAudioSource. Therefore we don't need applications that only rely on basic services to ship a full multimedia backend. Reimplements a6bb5f743dd404bce3734ad0c81449b8c4bf7b29 Task-number: QTBUG-120198 Pick-to: 6.7 6.6 6.5 Change-Id: If7ee7a4892e2d84e1af71b5f867cc24d950749c2 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Fix QWaveDecoder handling of padding bytes in RIFF chunksJøger Hansegård2024-02-272-3/+11
| | | | | | | | | | | | | | | | | | | | | | This patch adds support for reading WAV files with odd sized payloads in QWaveDecoder. This allows playing WAV files that contains odd-sized chunks before the 'data' chunk that contains the audio data. According to the specification, Multimedia Programming Interface and Data Specifications 1.0. IBM / Microsoft. pp. 10-11, the payload of RIFF chunks should be padded to an even length, so the fix is to round odd payload sizes up to next even size. Tests are extended with two files where a bext section patched in. One file has an odd length bext chunk with padding byte, the second file has an even length bext chunk without padding byte. Fixes: QTBUG-122193 Pick-to: 6.7 6.6 6.5 Change-Id: I6940db47db91a61e6b97f8f41043b2967b0d155a Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Tim Blechmann <tim@klingt.org>
* Set correct sample rate and channel count with big endian WAV dataJøger Hansegård2024-02-271-2/+2
| | | | | | | | | | | | | | | | | The QWaveDecoder failed to convert sample rate and channel count from big endian to little endian when populating the QAudioFormat. This patch fixes this issue, and revives the QWaveDecoder unit tests from Qt5. Since the QWaveDecoder no longer exposes an API for fetching endianness of the underlying data, the corresponding tests were removed. Still, the tests verify correct handling of both big and little endian. Task-number: QTBUG-122193 Pick-to: 6.7 6.6 6.5 Change-Id: Ia8fe9ab09fa479c3694d827d1505a1616fbacc24 Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Mikko Hallamaa <mikko.hallamaa@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Rename QAudio namespace to QtAudioVolker Hilsheimer2024-02-2015-65/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | With the addition of the QtVideo namespace in Qt 6.7 it becomes obvious that the existing QAudio namespace is not named according to the convention for namespaces in Qt. To fix this, we can rename the QAudio namespace to QtAudio, and declare the QAudio namespace as an alias for QtAudio. Public APIs using a QAudio type in their signature need to be exported from a removed_api.cpp file to maintain binary compatibility. Two of those are a signal, which leaves one challenge: string-based connects will have to use the QAudio namespace, in spite of the documentation, as the signal doesn't exist with a QtAudio parameter. Add a \note in the signals' documentation. [ChangeLog][Qt Multimedia][Potentially Source-Incompatible Changes] The QAudio namespace has been renamed to QtAudio, with QAudio still being available as an alias. String based connections to QAudioSink/Source::stateChanged need to continue to use QAudio::State as the parameter. Pick-to: 6.7 Change-Id: If49676ee62e048efbed68bb0e4848a5fefaea2f7 Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Implement audio resampling in QSoundEffectArtem Dyomin2024-01-231-3/+35
| | | | | | | | | | | | | | | | The resampling in QSoundEffect is needed to align the audio playback functionality with QMediaPlayer, otherwise, we get different volume levels when channels configurations of the source file and the audiodevice are different. QMediaPlayer uses ffmpeg resampling, so QSoundEffect is supposed to use it too. FFmpeg implementation is to be added in the following commits. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-118099 Change-Id: I24d0ca394635d53e8fdd4b09f328725dd4f51027 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Minor cleanup in QSoundEffectArtem Dyomin2024-01-191-41/+57
| | | | | | | | | | * rename m_audioOutput -> m_audioSink in order not to mix it up with QAudioOutput * use unique_ptr Pick-to: 6.7 6.6 6.5 Change-Id: I2d23e6fb36ba6691c4d5c6fd030f2eb3ec193717 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Doc: fix documentation of QAudioFormat::UInt8Volker Hilsheimer2023-11-271-1/+1
| | | | | | | | | | | | They are not both signed and unsigned. Follow the structure of the other values. Pick-to: 6.6 6.5 Task-number: QTBUG-118668 Change-Id: Id55d4f3e24f7023929959983f20e6f23bd4597d5 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* Doc: Fix template information for QAudioBuffer membersLuca Di Sera2023-11-181-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QDoc parses a project, it parses the source code to extract the user-provided documentation and perform sanity checkings based on the code itself on it. When QDoc parses an "\fn" command as part of this process, it tries to understand, based on its intermediate representation built on the information extracted from the code-base, which "documentable element" the "\fn" refers to. When QDoc performs this "matching" process, it takes into consideration only a certain amount of information. For example, no checking is performed over the template declaration of a callable. Due to some upcoming documentation, where two callables are indistinguishable to the current process, as they differ only in their template declaration, QDoc will start to take into consideration the template declaration of a callable when matching. This implies that an "\fn" command should now provide information parity, with regards to template declaration for callables, with the code-base so that QDoc can perform the match correctly. The documentation for some of the members of `QAudioBuffer` is not in sync with the intended target template declaration. In particular, `QAudioBuffer` provides a public templated version and a private non-templated version of `data`/`constData`. The documentation for those member was provided as an auto-tying block that was intended to tie to the private non-templated members, while documenting both the private and non-private API. As the private and public version only differ in their template declaration, which was not previously considered, and in their return type, which is correctly ignored when matching, QDoc would match the documentation to the public templated version, even if in the code it was positioned to match the private non-templated version. Now that QDoc will consider the template information, the matching will correctly pick the private non-templated version of the methods, thus producing no documentation in the final output as private methods are considered internal. To fix the issue, the auto-tying documentation blocks for `data`/`constData` were modified to use an `\fn` topic pointing to the public templated version. The body of the documentation was modified to avoid implying the presence of two overloads for the methods, instead referring directly to the public templated version, as the private version should not be generally referred to in the final output. Some spacing between the documentation blocks for `data`/`constData` and the out-of-line definition of the private non-templated version of the methods was added in the implementation file, so that it would be easier to see that the documentation blocks are not intended to auto-tie to the following definition. A commment referring to QDoc inability to recognize both the templated and non-templated version of the API was removed as it is soon going to be out-of-date and is not relevant to the presented version of the documentation anymore. Task-number: QTBUG-118080 Change-Id: I2280098f76fd34567db8ec588615621643329fd0 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Improve and prettify logic and usage of QAudioStateMachineArtem Dyomin2023-09-183-166/+113
| | | | | | | | | | | | | | | * both audio state + error now are handled atomically together. * internal synchronization is not need for current purposes; it has been addressed. * use acq/rel and relaxed memory order depending on the situation instead of the default non-optimal sequential order. * add new unit tests and remove some of old ones that are not relevant o the refactoring. Pick-to: 6.5 6.6 Change-Id: I644d8e67c933c0d98556a00d4a614fce879e37c2 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Doc: Add code snippet for stopping audio outputAndreas Eliasson2023-09-151-1/+1
| | | | | | | | | | | | The current docs have the same code snippet for changed audio state and for how to stop the output. The code snippet is correct for how to handle changed state, but not for how to stop the output. Fixes: QTBUG-116901 Pick-to: 6.6 6.5 6.2 Change-Id: Ibe4e6b14513b97781b85f4706aaadc2bab84b1d0 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Move some logic of QAudioStateMachine to AudioStateMachineUtilsArtem Dyomin2023-09-133-52/+74
| | | | | | | | | The patch is a part of QAudioStateMachine prettification. Pick-to: 6.5 6.6 Change-Id: I08092be2d497c5d3fba7f569e443e5139ce30ba8 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Rename StateChangeGuard -> NotifierArtem Dyomin2023-09-122-33/+30
| | | | | | | | | The patch is a part of QAudioStateMachine prettification. QAudioStateMachine::Notifier is going to do only signal notifications. Pick-to: 6.6 6.5 Change-Id: Ic76d1af6ec5be704a3c10597c2ac4240841ce4a4 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Fix unity build on WindowsVolker Hilsheimer2023-07-181-3/+1
| | | | | | | | | | | | | | Amends feffdf7cfef2d2ca69906aca9a11fe46acee7fa4. IgnoreError in the global namespace is also a symbol in winrt headers, causing ambiguities. Fix this by making IgnoreError a static value in the QAudio namespace, which then requires explicit qualifying of the value when used. Pick-to: 6.6 6.5 Task-number: QTBUG-113194 Change-Id: Id58ab1904d22ca5453b0c2db82b89e9b694df85e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix clang-tidy warning with noexcept move constructorArtem Dyomin2023-07-171-1/+1
| | | | | | Pick-to: 6.6 6.5 Change-Id: I2dbcc6a4dc5358f796ee26b9a689108a931a9007 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Refactor DarwinAudioSink and PulseAudioSink and run CI testArtem Dyomin2023-07-144-15/+448
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - the main change: implemented QAudioStateMachine allowing atomic state changing. The main reasons for creating the state machine: * get rid of state changing race conditions without mutex lockings and contentions. * it's good to have a common approach for audio states changings and notifications. The implementation of the state machine supports synchronization of actions after states toggling (turned off for pulse slink sinse it has own synchronization approach). Other audio sinks and sources might be refactored in the future. - remove a hack in PulseAudioSink with a callback based on QObject::destroyed connection, the hack appeared to cause a memory leak time-to-time. - the main business logic is not changed Testing: - tested manually on linux and macOS - auto tests * Linux QAudioSink tests became working locally and on CI. * macOS tests work locally, on CI only one test is blacklisted due to the issue not related to race conditions. Task-number: QTBUG-113194 Pick-to: 6.5 6.6 Change-Id: I68002c243dea874c4309b14b1fbd7b618392ab1f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Apply state check filter in QAudioSourceArtem Dyomin2023-06-221-2/+8
| | | | | | | | | | The same has been already applied for QAudioSink. The reason is the the signal can be emitted from different threads, that might affect inconsistent signal. Pick-to: 6.6 6.5 Change-Id: I067cfe7fa51f3caf2ff4b7e97b281f31e8df8bd0 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Handle devices changing in PulseAudioSinkArtem Dyomin2023-06-211-1/+13
| | | | | | | | | | | | - Updating of default audio devices comes in a separate event, implemented handling of it. - Signals PulseEngine::audioInputsChanged, audioOutputsChanged propagated to MediaDevice objects. Pick-to: 6.6 6.5 Task-number: QTBUG-112219 Change-Id: Ieb9ff342a6f87afaca97fbace27df8cb56a7ec8e Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Multimedia: Fix compiler warning warning C4723: potential divide by 0Jøger Hansegård2023-06-011-5/+6
| | | | | | | | | | | | cl.exe 19.35.32217.1 for x64 emits warning C4723: potential divide by 0 in RelWithDebInfo build of QtMultimedia.dll. The reason is likely that the compiler can not rule out that the QAudioFormat::bytesPerSample returns a different value from the point of check to the point of read. Pick-to: 6.5 Change-Id: Ifcc2db06310c94a7b90514f54d4d9e9c94c63072 Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Fix QAudioSink::stateChanged signal emittingArtem Dyomin2023-05-311-1/+6
| | | | | | | | | | | | | | 1. Ensure sending the signal from QAudioSink's thread. 2. QAudioSink backends emit signals from different threads what may cause a case when queued events are outdated and should be filtered. The patch has been decoupled from the big change codereview.qt-project.org/c/qt/qtmultimedia/+/474485 Task-number: QTBUG-113194 Pick-to: 6.5 Change-Id: I68002c243dea814c4309b14b1fbd7b618392ab11 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Fix inaccuracy in QAudioSink documentationArtem Dyomin2023-05-301-2/+3
| | | | | | Pick-to: 6.5 Change-Id: I4ae1304615bf8ec55fbe5f41dc280cbc83f1185e Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Add audio engine warm-up on WindowsPavel Dubsky2023-05-302-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | Current implementation has the following audio problem on Windows: if any of the classes that support audio playback are used (QMediaPlayer or QSoundEffect) sound is cutting off (part of the sound is missing usually beginning). If there're some other applications playing sounds in the system while we try to play our sound then everyting works fine. Apparently this happens due to warm up delays for system audio engine and if there're other applications available they're simply keeping it alive and it's already fully initialized and ready to be used by us when we need it. As a workaround to this problem an unused audio device is created that is fully initialized and set to play (nothing) but is actually present for any subsequently created audio devices that are ready from the start without any delays. Pick-to: 6.5 Task-number: QTBUG-112512 Change-Id: I660a48e8ac1a1ebd1cfb6a9ff76605c3b4742e17 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* docs: update warning note about QAudioDecoder::setAudioFormat()Nicholas Bennett2023-05-171-1/+2
| | | | | | | Fixes: QTBUG-100514 Pick-to: 6.5 Change-Id: Ib6ccfd13e80e2bc3f6166b3782148a55954f605d Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* QSampleCache: Wait for load thread to finish before restarting itMikolaj Boc2023-04-161-1/+5
| | | | | | | | | | | | One cannot rely on QThread::isRunning for checking whether the thread hasn't finished yet, as the thread might be quitting and still return true from isRunning. In that case, the thread won't process the sample load request that misses the start() call in this case. Fixes: QTBUG-109167 Pick-to: 6.5 Change-Id: I33382ad3d8a19ceb86857c51227e81a86a88eea7 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Fix behavior of QAudioSink::resume in push modeVolker Hilsheimer2023-02-061-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Up to now, a QAudioSink in push mode (ie. started without a QIODevice, but returning a QIODevice buffer that the client has to push data into) transitioned to IdleState when resuming after a suspend, even if there was still data in the buffer or device to play. This resulted in the sink playing audio even though it was in IdleState, and the client not getting notified when the audio data was actually drained (as the stateChanged signal did not get emitted again). Fix this by storing the state in which the sink gets suspended, and restore to that state when resuming. If the sink then runs into an underrun because not enough data is available in the push-buffer, then it will transition to IdleState with UnderrunError later. Implement this consistently in all platform implementations, adjust the test, which previously verified that a push-sink transitions to IdleState when resuming, and change the documentation accordingly. [ChangeLog][QtMutimedia][QAudioSink] Calling QAudioSink::resume() now returns the sink to the state it had when QAudioSink::suspend() was called, no matter whether the sink operates in pull or push mode. Pick-to: 6.5 Change-Id: If0c7fe8629627de814276d629d825e469c998d2d Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Set Q_LOGGING_CATEGORY staticArtem Dyomin2023-01-182-2/+2
| | | | | | | | | | | Q_LOGGING_CATEGORY is a macro with a function under the hood. Since we're using it in cpp files, better to make it static in order to get rid of extra public linking symbols. Pick-to: 6.5 Change-Id: If384073993fdc70a2affab4bd3bf50c0c4129687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Fix -Wclazy-incorrect-emitTasuku Suzuki2023-01-111-1/+1
| | | | | | Pick-to: 6.5 Change-Id: I1afd105a6b75e9be516b03595d254196c513be4a Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Include moc_*.cpp files in main QtMM codeArtem Dyomin2022-12-133-3/+24
| | | | | | | | | | | | | | | The reason of the refactoring is following the common approach that leads to reducing compilation time and binary size. - logic hasn't been touched - some headers have been decoupled into header and cpp - the same refactorings of examples, tests, plugins are coming in the next commits Task-number: QTBUG-103290 Pick-to: 6.5 6.4 Change-Id: I6716cef5116769230c36e8d584d9ba6ec40aabb2 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Map 0 channels to ChannelConfigUnknownPiotr Srebrny2022-12-021-0/+3
| | | | | | | | | | We must set default channel config with channel count 0 explicitly to ChannelConfigUnknown as the defualt algorithm will map it to UnknownPosition resulting in channel count 1. Pick-to: 6.4 Change-Id: I88c289b3edb1d3f8ac5a971f02c8b542373041c8 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Fix see-also syntax, silence qdoc warningVolker Hilsheimer2022-11-301-1/+1
| | | | | | | | | | | | | qdoc informed us that it can't link to space-less 'QAudioSink,QAudioSource,QAudioFormat' because there is no such thing. Insert space after comma to fix the links and silence qdoc. Pick-to: 6.4 6.2 Change-Id: I192a73753e2885ffc7e05a94b6fc0a9ac91f13b8 Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
* Add parent-child relationship on audio sources and sinksPiotr Srebrny2022-11-103-2/+4
| | | | | | | | | | | | | | QAudioSink and QAudioSource must propagate their parents to the platform specific implementation to enable correct operation of the moveToThread function. Furthermore, all QObject elements that are owned by audio sink/source must also establish the parent-child relationship. This mainly affects QTimer's used by the audio sink/sources. Pick-to: 6.4 Fixes: QTBUG-108187 Change-Id: I476a97300a6fb1e0022b2a5570a3803be8fd0a88 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Add audio listeners for macOS and cleanup codeArtem Dyomin2022-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | QMediaDevices doc says: The default device can change during the runtime of the application. The audioInputsChanged/audioOutputsChanged signal is emitted in this case. What's done: - add listening of properties kAudioHardwarePropertyDefaultOutputDevice and kAudioHardwarePropertyDefaultInputDevice in order to handle default input/output changes. - cleanup a mess of defines in qdarwinmediadevices.mm - some refactoring with code improving. Task-number: QTBUG-108020 Pick-to: 6.4 Change-Id: I35aec4f9da9755036141a70f5ce48f6db73d8148 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Fix redundant warning output on macOSArtem Dyomin2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | Redundant warnings were reproduced with specific installed sowtware, e.g. Soundflower. The software is able to create 64 audio channels and customize them. Basically, all the channels have unknown label, so we should filter the warnings. The logic of channels detection is not changed: only a little bit refactored. See dump of audio channels on client's PC: bugreports.qt.io/secure/attachment/132568/dump_audio_res2.txt Pick-to: 6.4 Task-number: QTBUG-107678 Change-Id: I85b63d39b71aa09b28d47bf5bf7d40d1e8a1328b Reviewed-by: Doris Verria <doris.verria@qt.io>
* Doc: Fix qdoc warnings for undocumented members in QAudio*Venugopal Shivashankar2022-09-299-60/+160
| | | | | | | | | In addition, fixed a few clang-format warnings. Pick-to: 6.4 Change-Id: I9d97f1e7e2454e524229d5621ee9461558049830 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Fix various issues in Qt Multimedia documentationTopi Reinio2022-09-281-1/+1
| | | | | | | | | | | * Avoid unnecessary repetition in .qdocconf * Fix incorrect link targets * Fix mistakes in QML property documentation * Add documentation for enumeration values in Camera::flashMode Pick-to: 6.4 Change-Id: If0f67ded1c014bc75e21ccff832ef197b93e5b24 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Update module headers to work with syncqt cppAlexey Edelev2022-09-261-0/+4
| | | | | | | | Make header files self-contained. Task-number: QTBUG-87480 Change-Id: I915aa9981c6205a3c04d1340b582f656eb6f7d6c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Enable error reporting when failed to initialize backend elementPiotr Srebrny2022-09-264-46/+42
| | | | | | | | | | | | | | | This patch adds an option to report error message when a backend component cannot be instantiated. This error message is then displayed in the console with qWarning and in some cases reported to the app user with error signals. We need further improvements on the error reporting side. Additionally, this patch cleans up the code in the .cpp API classes. Pick-to: 6.4 Change-Id: Id39865cc8f1e9b52804bf5b9d9b15e738508f860 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* wasm: fix QSoundEffect playingLorn Potter2022-08-111-0/+14
| | | | | | | | | | | | Wasm by default, is not threaded, so moveToThread does not work as intended. The asserts were removed as not needed and of course, asserting, as moveToThread does not work. Fixes: QTBUG-104045 Pick-to: 6.4 Change-Id: I7bda8288e5c9ea16d57b714b8cba9e57018058e5 Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* QAudioHelpers: fix C++20 -Werror,-Wdeprecated-enum-float-conversionMarc Mutz2022-06-301-1/+1
| | | | | | | | | | | | | | | | Says Clang 10.0.0 -std=c++20: qaudiohelpers.cpp:71:44: error: arithmetic between enumeration type 'QAudioHelperInternal::signedVersion<unsigned char>::(anonymous enum at /home/marc/Qt/qt5/qtmultimedia/src/multimedia/audio/qaudiohelpers.cpp:63:5)' and floating-point type 'double' is deprecated [-Werror,-Wdeprecated-enum-float-conversion] pDst[i] = signedVersion<T>::offset + ((typename signedVersion<T>::TS)(pSrc[i] - signedVersion<T>::offset) * factor); ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix by turning the enum { offset } into a static constexpr int instead. Pick-to: 6.4 6.3 6.2 5.15 Task-number: QTBUG-104172 Change-Id: I92a22583fc5e1fc524364b64701aa8d416b82671 Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-06-2428-1064/+56
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ida08dfe6c84778656e942178c3d39042c9ef1ed2 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>