Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds vt sequence DECPS #735

Merged
merged 1 commit into from
Jun 16, 2022
Merged

adds vt sequence DECPS #735

merged 1 commit into from
Jun 16, 2022

Conversation

Utkarsh-khambra
Copy link
Collaborator

@Utkarsh-khambra Utkarsh-khambra commented Jun 13, 2022

closes #237

  • Write tests
  • Support Qt6

@github-actions github-actions bot added documentation Improvements or additions to documentation frontend Contour Terminal Emulator (GUI frontend) VT: Backend Virtual Terminal Backend (libterminal API) labels Jun 13, 2022
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 2 times, most recently from ad20f76 to 18c5b51 Compare June 13, 2022 16:26
@github-actions github-actions bot added the CI GitHub Actions & CI label Jun 13, 2022
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 3 times, most recently from a360bdb to e142d4f Compare June 13, 2022 17:09
Changelog.md Show resolved Hide resolved
src/contour/TerminalSession.cpp Outdated Show resolved Hide resolved
src/crispy/Note.cpp Outdated Show resolved Hide resolved
src/crispy/Note.cpp Outdated Show resolved Hide resolved
src/terminal/Functions.h Outdated Show resolved Hide resolved
src/crispy/Note.h Outdated Show resolved Hide resolved
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 3 times, most recently from f8eacf8 to 645f05d Compare June 13, 2022 18:00
@christianparpart
Copy link
Member

@Utkarsh-khambra with regards to the build failures when building using Qt6 (the one CI test), the QAudioOutput API has changed slightly.

I hope it's possible to #ifdef that out to distinguish between < QT_VERSION(6, 0, 0) and >=.

Do we actually have any possibility to run Qt6 on Linux already (with what distro)? Hmm...

@Utkarsh-khambra
Copy link
Collaborator Author

Fedora has qt6 package in their repo.

src/contour/Audio.cpp Outdated Show resolved Hide resolved
src/contour/Audio.cpp Outdated Show resolved Hide resolved
@christianparpart
Copy link
Member

Write tests

I think here the test should be sufficient if it's abstractr, not testing the actual audio but only if it's forwarded correctly to the event listener.

@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 2 times, most recently from 11ec7ec to bd0a9a5 Compare June 15, 2022 17:05
@Utkarsh-khambra Utkarsh-khambra marked this pull request as ready for review June 16, 2022 03:12
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 2 times, most recently from ff56184 to ffec9ca Compare June 16, 2022 04:55
@christianparpart christianparpart force-pushed the feature/vt-decps branch 2 times, most recently from 9ed82b3 to 24fffad Compare June 16, 2022 12:56
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/vt-decps branch 2 times, most recently from ce8430e to ab8ff70 Compare June 16, 2022 13:08
@christianparpart
Copy link
Member

@Utkarsh-khambra my modifications (squashed)

diff --git a/src/contour/Audio.cpp b/src/contour/Audio.cpp
index d8050edb..01bd527d 100644
--- a/src/contour/Audio.cpp
+++ b/src/contour/Audio.cpp
@@ -42,6 +42,7 @@ Audio::Audio()
     QAudioFormat f;
     f.setSampleRate(44100);
     f.setChannelCount(1);
+
 #if QT_VERSION >= 0x060000
     f.setSampleFormat(QAudioFormat::Int16);
     QAudioDevice info(QMediaDevices::defaultAudioOutput());
@@ -51,24 +52,23 @@ Audio::Audio()
     f.setByteOrder(QAudioFormat::LittleEndian);
     f.setSampleType(QAudioFormat::SignedInt);
     QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
-
 #endif
+
     if (!info.isFormatSupported(f))
     {
         errorlog()("Default output device doesn't support 16 Bit signed integer PCM");
         return;
     }
-#if QT_VERSION >= 0x060000
-    audio = std::make_unique<QAudioSink>(f);
-#else
-    audio = std::make_unique<QAudioOutput>(f);
+
+#if QT_VERSION < 0x060000
+    using QAudioSink = QAudioOutput;
 #endif
+
+    audio = std::make_unique<QAudioSink>(f);
+
     audio->moveToThread(&soundThread_);
-#if QT_VERSION >= 0x060000
+
     connect(audio.get(), &QAudioSink::stateChanged, this, &Audio::handleStateChanged);
-#else
-    connect(audio.get(), &QAudioOutput::stateChanged, this, &Audio::handleStateChanged);
-#endif
     qRegisterMetaType<std::vector<int>>();
     connect(this, &Audio::play, this, &Audio::handlePlayback);
     soundThread_.start();
@@ -80,17 +80,18 @@ Audio::~Audio()
     soundThread_.wait();
 }
 
-void Audio::fillBuffer(int volume, int duration, crispy::span<const int> notes)
+void Audio::fillBuffer(int volume, int duration, crispy::span<int const> notes)
 {
-    for (auto i: notes)
+    for (auto const i: notes)
     {
         auto b = createMusicalNote(volume, duration, i);
-        byteArray_.append(reinterpret_cast<const char*>(b.data()), static_cast<int>(2 * b.size()));
+        byteArray_.append(reinterpret_cast<char const*>(b.data()), static_cast<int>(2 * b.size()));
     }
 }
 
 void Audio::handlePlayback(int volume, int duration, std::vector<int> const& notes)
 {
+    Require(audio);
     if (audio->state() == QAudio::State::ActiveState)
     {
         fillBuffer(volume, duration, crispy::span(notes.data(), notes.size()));
@@ -99,8 +100,7 @@ void Audio::handlePlayback(int volume, int duration, std::vector<int> const& not
     fillBuffer(volume, duration, crispy::span(notes.data(), notes.size()));
     audioBuffer_.setBuffer(&byteArray_);
     audioBuffer_.open(QIODevice::ReadWrite);
-    if (audio)
-        audio->start(&audioBuffer_);
+    audio->start(&audioBuffer_);
 }
 
 void Audio::handleStateChanged(QAudio::State state)

@christianparpart christianparpart merged commit 6a6af5d into master Jun 16, 2022
@christianparpart christianparpart deleted the feature/vt-decps branch June 16, 2022 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI GitHub Actions & CI documentation Improvements or additions to documentation frontend Contour Terminal Emulator (GUI frontend) VT: Backend Virtual Terminal Backend (libterminal API)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DECPS, play sound in terminal
3 participants