Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Fix #74 #78 #45
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Oct 23, 2023
1 parent 741cba5 commit d2f1000
Show file tree
Hide file tree
Showing 15 changed files with 366 additions and 187 deletions.
14 changes: 13 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "default",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/vector_audio.app/Contents/MacOS/vector_audio",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/resources",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
},
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/vector_audio",
"program": "${workspaceFolder}/resources/vector_audio",
"args": [],
"preRunCommands": ["settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_INSTRUCTION", "process handle SIGILL -n false -p true -s false"],
"initCommands": ["settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_INSTRUCTION", "process handle SIGILL -n false -p true -s false"],
Expand Down
3 changes: 2 additions & 1 deletion bundle_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ install_name_tool -add_rpath "@executable_path/../Frameworks" build/VectorAudio.
rm resources/VectorAudio.icns

xattr -cr build/VectorAudio.app
codesign --force --deep -s - build/VectorAudio.app
codesign --force --timestamp -s - build/VectorAudio.app/Contents/Frameworks/libafv_native.dylib
codesign --force --deep --timestamp -s - build/VectorAudio.app
3 changes: 2 additions & 1 deletion collect_licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
['ImGui', os.path.join('extern', 'imgui', 'LICENSE.txt')],
['Platform Folders', os.path.join('extern', 'PlatformFolders', 'LICENSE')],
['Airports Database', os.path.join('resources', 'LICENSE_AIRPORTS')],
['swift pilot client', os.path.join('resources', 'LICENSE_SWIFT')]]
['swift pilot client', os.path.join('resources', 'LICENSE_SWIFT')],
['audio alert tune', os.path.join('resources', 'LICENSE_AUDIO_ALERT')]]

for sublicense in submodules_licenses:
print('Getting license for: ' + sublicense[0])
Expand Down
18 changes: 14 additions & 4 deletions include/application.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "afv-native/atcClientWrapper.h"
#include "config.h"
#include "afv-native/event.h"
#include "config.h"
#include "imgui.h"
#include "imgui_internal.h"
#include "imgui_stdlib.h"
Expand Down Expand Up @@ -45,6 +45,17 @@ class App {
afv_native::ClientEventType evt, void* data, void* data2);
void buildSDKServer();

void disconnectAndCleanup();

void playErrorSound()
{
if (!disconnect_warning_sound_available) {
return;
}
// Load the warning sound for disconnection
sound_player_.play();
};

// Used in another thread
static void loadAirportsDatabaseAsync();

Expand All @@ -53,9 +64,8 @@ class App {

std::unique_ptr<vector_audio::vatsim::DataHandler> dataHandler_;

sf::SoundBuffer disconnectWarningSoundbuffer_;
sf::Sound soundPlayer_;
bool disconnectWarningSoundAvailable_ = true;
bool manuallyDisconnected_ = false;
sf::SoundBuffer disconnect_warning_soundbuffer_;
sf::Sound sound_player_;
};
}
3 changes: 0 additions & 3 deletions include/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ inline std::string station_add_callsign = "";
inline std::string station_auto_add_callsign = "";
inline float station_add_frequency = 118.0;

inline std::vector<int> StationsPendingRemoval;
inline std::vector<int> StationsPendingRxChange;

inline afv_native::HardwareType hardware
= afv_native::HardwareType::Schmid_ED_137B;

Expand Down
9 changes: 7 additions & 2 deletions include/util.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include "imgui.h"
#include "shared.h"
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <afv-native/hardwareType.h>
#include <algorithm>
Expand Down Expand Up @@ -135,7 +137,7 @@ inline int round8_33kHzChannel(int fKHz)
fKHz = lower_diff < upper_diff ? lower : upper;
fKHz = std::clamp(fKHz, 118000, 136990);
}
return fKHz*100;
return fKHz * 100;
}

inline void TextURL(const std::string& name_, std::string URL_)
Expand Down Expand Up @@ -181,7 +183,8 @@ inline int cleanUpFrequency(int frequency)
return util::round8_33kHzChannel(frequency);
}

return std::clamp(frequency, 118000000, 136990000);;
return std::clamp(frequency, 118000000, 136990000);
;
}

static bool endsWith(const std::string& str, const std::string& suffix)
Expand Down Expand Up @@ -219,6 +222,8 @@ inline static std::string findHeadsetInputDeviceOrDefault()
return vector_audio::shared::availableInputDevices.front();
}

inline static bool disconnect_warning_sound_available = true;

inline static std::string findHeadsetOutputDeviceOrDefault()
{
if (std::find(vector_audio::shared::availableOutputDevices.begin(),
Expand Down
2 changes: 1 addition & 1 deletion lib/include/afv-native/atcClientWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace afv_native::api {
public:
AFV_NATIVE_API static void setLogger(afv_native::log_fn gLogger);

AFV_NATIVE_API explicit atcClient(std::string clientName, std::string resourcePath = "");
AFV_NATIVE_API atcClient(std::string clientName, std::string resourcePath = "");
AFV_NATIVE_API ~atcClient();

AFV_NATIVE_API bool IsInitialized();
Expand Down
3 changes: 2 additions & 1 deletion lib/include/afv-native/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace afv_native {
VccsReceived,
StationDataReceived,
InputDeviceError,
AudioDisabled
AudioDisabled,
AudioDeviceStoppedError, // data is a pointer to a std::string of the relevant device name
};

namespace afv {
Expand Down
4 changes: 4 additions & 0 deletions resources/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,10 @@ Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.


audio alert tune

Sound Effect by <a href="https://pixabay.com/users/universfield-28281460/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=153266">UNIVERSFIELD</a> from <a href="https://pixabay.com/sound-effects//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=153266">Pixabay</a>

libflac_arm64-osx

Copyright (C) 2000-2009 Josh Coalson
Expand Down
1 change: 1 addition & 0 deletions resources/LICENSE_AUDIO_ALERT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sound Effect by <a href="https://pixabay.com/users/universfield-28281460/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=132111">UNIVERSFIELD</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=132111">Pixabay</a>
Binary file modified resources/disconnect.wav
Binary file not shown.
20 changes: 20 additions & 0 deletions resources/imgui.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Window][MainWindow]
Pos=0,0
Size=800,600
Collapsed=0

[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

[Window][Settings Panel]
Pos=158,51
Size=484,498
Collapsed=0

[Window][Error]
Pos=250,237
Size=300,126
Collapsed=0

Loading

0 comments on commit d2f1000

Please sign in to comment.