mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-05-19 09:10:29 -04:00
app: qt 6 audio fixes
This commit is contained in:
parent
68c35f3b72
commit
9b3a8da32a
2 changed files with 9 additions and 14 deletions
app/viewer
|
@ -394,6 +394,8 @@ void MediaPanel::Play(bool e)
|
||||||
auto output_dev = QAudioDevice(QMediaDevices::defaultAudioOutput());
|
auto output_dev = QAudioDevice(QMediaDevices::defaultAudioOutput());
|
||||||
auto fmt = output_dev.preferredFormat();
|
auto fmt = output_dev.preferredFormat();
|
||||||
|
|
||||||
|
ClearAudioSinks();
|
||||||
|
|
||||||
for (auto it=m_mediaInstances.cbegin(); it!=m_mediaInstances.cend(); it++) {
|
for (auto it=m_mediaInstances.cbegin(); it!=m_mediaInstances.cend(); it++) {
|
||||||
auto m = *it;
|
auto m = *it;
|
||||||
|
|
||||||
|
@ -407,7 +409,6 @@ void MediaPanel::Play(bool e)
|
||||||
auto out = new QAudioSink(output_dev, fmt, this);
|
auto out = new QAudioSink(output_dev, fmt, this);
|
||||||
out->setVolume(m->GetVolume());
|
out->setVolume(m->GetVolume());
|
||||||
out->start(m);
|
out->start(m);
|
||||||
connect(out, &QAudioSink::stateChanged, this, &MediaPanel::AudioStateChanged);
|
|
||||||
m_audioSinks.push_back(out);
|
m_audioSinks.push_back(out);
|
||||||
has_audio = true;
|
has_audio = true;
|
||||||
}
|
}
|
||||||
|
@ -449,9 +450,7 @@ void MediaPanel::TimerUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all_eof) {
|
if (all_eof) {
|
||||||
// Detach audio output so that it flushes itself
|
ClearAudioSinks();
|
||||||
m_audioSinks.clear();
|
|
||||||
|
|
||||||
Play(false);
|
Play(false);
|
||||||
m_PlayheadSlider->setValue(m_PlayheadSlider->maximum());
|
m_PlayheadSlider->setValue(m_PlayheadSlider->maximum());
|
||||||
}
|
}
|
||||||
|
@ -506,17 +505,13 @@ void MediaPanel::LabelContextMenuTriggered(const QPoint &pos)
|
||||||
m.exec(static_cast<QWidget*>(sender())->mapToGlobal(pos));
|
m.exec(static_cast<QWidget*>(sender())->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaPanel::AudioStateChanged(QAudio::State newState)
|
void MediaPanel::ClearAudioSinks()
|
||||||
{
|
{
|
||||||
if (newState == QAudio::IdleState) {
|
if (m_audioSinks.size() != 0) {
|
||||||
auto out = static_cast<QAudioSink*>(sender());
|
for (auto s : m_audioSinks)
|
||||||
|
delete s;
|
||||||
|
|
||||||
auto it = std::find(m_audioSinks.begin(), m_audioSinks.end(), out);
|
m_audioSinks.clear();
|
||||||
if (it != m_audioSinks.end()) {
|
|
||||||
m_audioSinks.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ private slots:
|
||||||
|
|
||||||
void LabelContextMenuTriggered(const QPoint &pos);
|
void LabelContextMenuTriggered(const QPoint &pos);
|
||||||
|
|
||||||
void AudioStateChanged(QAudio::State newState);
|
void ClearAudioSinks();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue