mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
add shared pointer
This commit is contained in:
parent
5d1f2a04c1
commit
83e370d9de
2 changed files with 6 additions and 7 deletions
|
@ -121,7 +121,7 @@ uint64_t uvec2ToUint64(const uvec2& v) {
|
||||||
class AudioHandler : public QObject, QRunnable {
|
class AudioHandler : public QObject, QRunnable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AudioHandler(OffscreenQmlSurface* surface, const QString& deviceName, int runDelayMs = 0, QObject* parent = nullptr) : QObject(parent) {
|
AudioHandler(QSharedPointer<OffscreenQmlSurface> surface, const QString& deviceName, int runDelayMs = 0, QObject* parent = nullptr) : QObject(parent) {
|
||||||
_newTargetDevice = deviceName;
|
_newTargetDevice = deviceName;
|
||||||
_runDelayMs = runDelayMs;
|
_runDelayMs = runDelayMs;
|
||||||
_surface = surface;
|
_surface = surface;
|
||||||
|
@ -138,9 +138,8 @@ public:
|
||||||
if (_runDelayMs > 0) {
|
if (_runDelayMs > 0) {
|
||||||
QThread::msleep(_runDelayMs);
|
QThread::msleep(_runDelayMs);
|
||||||
}
|
}
|
||||||
auto rootItem = _surface->getRootItem();
|
if (!_surface.isNull() && _surface->getRootItem() && !_surface->getCleaned()) {
|
||||||
if (rootItem && !_surface->getCleaned()) {
|
for (auto player : _surface->getRootItem()->findChildren<QMediaPlayer*>()) {
|
||||||
for (auto player : rootItem->findChildren<QMediaPlayer*>()) {
|
|
||||||
auto mediaState = player->state();
|
auto mediaState = player->state();
|
||||||
QMediaService *svc = player->service();
|
QMediaService *svc = player->service();
|
||||||
if (nullptr == svc) {
|
if (nullptr == svc) {
|
||||||
|
@ -178,7 +177,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _newTargetDevice;
|
QString _newTargetDevice;
|
||||||
OffscreenQmlSurface* _surface;
|
QSharedPointer<OffscreenQmlSurface> _surface;
|
||||||
int _runDelayMs;
|
int _runDelayMs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -705,7 +704,7 @@ void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
||||||
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||||
int waitForAudioQmlMs = 200;
|
int waitForAudioQmlMs = 200;
|
||||||
// The audio device need to be change using oth
|
// The audio device need to be change using oth
|
||||||
new AudioHandler(this, deviceName, waitForAudioQmlMs);
|
new AudioHandler(sharedFromThis(), deviceName, waitForAudioQmlMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class QQuickItem;
|
||||||
|
|
||||||
using QmlContextCallback = std::function<void(QQmlContext*, QObject*)>;
|
using QmlContextCallback = std::function<void(QQmlContext*, QObject*)>;
|
||||||
|
|
||||||
class OffscreenQmlSurface : public QObject {
|
class OffscreenQmlSurface : public QObject, public QEnableSharedFromThis<OffscreenQmlSurface> {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue