Browse Source

feat(audio):OutgoingCallSound

Adds outgoing call sound when call is started
Alice Weigt 4 years ago
parent
commit
a06ad7048e

BIN
audio/ToxOutgoingCall.pcm


+ 1 - 0
res.qrc

@@ -8,6 +8,7 @@
     <qresource prefix="/">
         <file>audio/notification.pcm</file>
         <file>audio/ToxIncomingCall.pcm</file>
+        <file>audio/ToxOutgoingCall.pcm</file>
         <file>img/add.svg</file>
         <file>img/avatar_mask.svg</file>
         <file>img/contact.svg</file>

+ 1 - 0
src/audio/audio.cpp

@@ -34,6 +34,7 @@
  * @value NewMessage Returns the new message notification sound.
  * @value Test Returns the test sound.
  * @value IncomingCall Returns the incoming call sound.
+ * @value OutgoingCall Returns the outgoing call sound.
  *
  * @fn QString Audio::getSound(Sound s)
  * @brief Function to get the path of the requested sound.

+ 4 - 1
src/audio/audio.h

@@ -39,7 +39,8 @@ public:
     {
         NewMessage,
         Test,
-        IncomingCall
+        IncomingCall,
+        OutgoingCall
     };
 
     inline static QString getSound(Sound s)
@@ -51,6 +52,8 @@ public:
             return QStringLiteral(":/audio/notification.pcm");
         case Sound::IncomingCall:
             return QStringLiteral(":/audio/ToxIncomingCall.pcm");
+        case Sound::OutgoingCall:
+            return QStringLiteral(":/audio/ToxOutgoingCall.pcm");
         }
         assert(false);
         return QString();

+ 2 - 0
src/widget/form/chatform.cpp

@@ -369,6 +369,7 @@ void ChatForm::onAvStart(uint32_t friendId, bool video)
         hideNetcam();
     }
 
+    Audio::getInstance().stopLoop();
     updateCallButtons();
     startCounter();
 }
@@ -399,6 +400,7 @@ void ChatForm::showOutgoingCall(bool video)
     btn->setToolTip(video ? tr("Cancel video call") : tr("Cancel audio call"));
     addSystemInfoMessage(tr("Calling %1").arg(f->getDisplayedName()), ChatMessage::INFO,
                          QDateTime::currentDateTime());
+    emit outgoingNotification();
     Widget::getInstance()->updateFriendActivity(f);
 }
 

+ 1 - 0
src/widget/form/chatform.h

@@ -58,6 +58,7 @@ public:
 signals:
     void aliasChanged(const QString& alias);
     void incomingNotification(uint32_t friendId);
+    void outgoingNotification();
     void rejectCall(uint32_t friendId);
     void acceptCall(uint32_t friendId);
 

+ 8 - 0
src/widget/widget.cpp

@@ -934,6 +934,13 @@ void Widget::incomingNotification(uint32_t friendId)
     audio.playMono16Sound(Audio::getSound(Audio::Sound::IncomingCall));
 }
 
+void Widget::outgoingNotification()
+{
+    Audio& audio = Audio::getInstance();
+    audio.startLoop();
+    audio.playMono16Sound(Audio::getSound(Audio::Sound::OutgoingCall));
+}
+
 void Widget::onRejectCall(uint32_t friendId)
 {
     Audio::getInstance().stopLoop();
@@ -977,6 +984,7 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk)
     connect(newfriend, &Friend::nameChanged, this, &Widget::onFriendAliasChanged);
 
     connect(friendForm, &ChatForm::incomingNotification, this, &Widget::incomingNotification);
+    connect(friendForm, &ChatForm::outgoingNotification, this, &Widget::outgoingNotification);
     connect(friendForm, &ChatForm::rejectCall, this, &Widget::onRejectCall);
     connect(friendForm, &ChatForm::acceptCall, this, &Widget::onAcceptCall);
 

+ 1 - 0
src/widget/widget.h

@@ -217,6 +217,7 @@ private slots:
     void groupInvitesUpdate();
     void groupInvitesClear();
     void onDialogShown(GenericChatroomWidget* widget);
+    void outgoingNotification();
     void incomingNotification(uint32_t friendId);
     void onRejectCall(uint32_t friendId);
     void onAcceptCall(uint32_t friendId);