From 3904a9e67cc435116005cf95f57c074d498dc039 Mon Sep 17 00:00:00 2001 From: Pavel Perekhozhikh Date: Thu, 18 Jan 2018 01:05:52 +0300 Subject: [PATCH] [Mac OS] add support native OpenAl for mac os For this you need to add cmake arg PROCXX_USE_NATIVE_OPEN_AL --- CMakeLists.txt | 5 ++- Telegram/CMakeLists.txt | 4 +++ Telegram/SourceFiles/media/media_audio.cpp | 9 ++++-- .../SourceFiles/media/media_audio_capture.cpp | 4 +-- .../media/media_audio_ffmpeg_loader.h | 3 +- .../SourceFiles/media/media_audio_track.cpp | 4 +-- .../media/media_child_ffmpeg_loader.h | 2 +- Telegram/SourceFiles/media/media_defs.h | 31 +++++++++++++++++++ 8 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 Telegram/SourceFiles/media/media_defs.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 27eec807f..f96ab23f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,10 @@ if (LINUX) find_package(ALSA) find_package(PulseAudio) find_package(Qt5 COMPONENTS DBus) -else(LINUX) +elseif(APPLE AND PROCXX_USE_NATIVE_OPEN_AL) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework OpenAL") + set(PROCXX_USE_NATIVE_OPEN_AL_MAC 1) +else() # Needs OpenAL-SOFT # Install via `brew install openal-soft` and configure with cmake call from README.md find_package(OpenAL REQUIRED NO_MODULE) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 8ebdbe661..ff095358e 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -5,6 +5,10 @@ if (LINUX) else() add_definitions(-DQ_OS_LINUX32) endif() +elseif(APPLE) + if (PROCXX_USE_NATIVE_OPEN_AL_MAC) + add_definitions(-DPROCXX_USE_NATIVE_OPEN_AL_MAC) + endif() endif() ##================================================ diff --git a/Telegram/SourceFiles/media/media_audio.cpp b/Telegram/SourceFiles/media/media_audio.cpp index a3eba9794..943072815 100644 --- a/Telegram/SourceFiles/media/media_audio.cpp +++ b/Telegram/SourceFiles/media/media_audio.cpp @@ -27,9 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "platform/platform_audio.h" #include "base/task_queue.h" -#include -#include -#include +#include "media/media_defs.h" #include @@ -1344,8 +1342,13 @@ bool audioDeviceIsConnected() { if (!AudioDevice) { return false; } +#if defined (PROCXX_USE_NATIVE_OPEN_AL_MAC) +#pragma message ("Mac OS Native OpenAL not support ALC_EXT_disconnect") + auto isConnected = ALint(1); +#else auto isConnected = ALint(0); alcGetIntegerv(AudioDevice, ALC_CONNECTED, 1, &isConnected); +#endif if (Audio::ContextErrorHappened()) { return false; } diff --git a/Telegram/SourceFiles/media/media_audio_capture.cpp b/Telegram/SourceFiles/media/media_audio_capture.cpp index 8de184061..281157b03 100644 --- a/Telegram/SourceFiles/media/media_audio_capture.cpp +++ b/Telegram/SourceFiles/media/media_audio_capture.cpp @@ -22,9 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "media/media_audio_ffmpeg_loader.h" -#include -#include -#include +#include "media/media_defs.h" #include diff --git a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h index ce305a30d..a463374d3 100644 --- a/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h +++ b/Telegram/SourceFiles/media/media_audio_ffmpeg_loader.h @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "media/media_audio.h" #include "media/media_audio_loader.h" +#include "media/media_defs.h" extern "C" { #include @@ -30,8 +31,6 @@ extern "C" { #include } // extern "C" -#include - class AbstractFFMpegLoader : public AudioPlayerLoader { public: AbstractFFMpegLoader(const FileLocation &file, const QByteArray &data, base::byte_vector &&bytes) : AudioPlayerLoader(file, data, std::move(bytes)) { diff --git a/Telegram/SourceFiles/media/media_audio_track.cpp b/Telegram/SourceFiles/media/media_audio_track.cpp index 3d8c11e17..1eecfecf4 100644 --- a/Telegram/SourceFiles/media/media_audio_track.cpp +++ b/Telegram/SourceFiles/media/media_audio_track.cpp @@ -24,9 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "media/media_audio.h" #include "messenger.h" -#include -#include -#include +#include "media/media_defs.h" namespace Media { namespace Audio { diff --git a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h index 51b9a7c66..d1ae97424 100644 --- a/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h +++ b/Telegram/SourceFiles/media/media_child_ffmpeg_loader.h @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "media/media_audio_loader.h" #include "media/media_audio.h" +#include "media/media_defs.h" extern "C" { #include @@ -30,7 +31,6 @@ extern "C" { #include } // extern "C" -#include struct VideoSoundData { AVCodecContext *context = nullptr; diff --git a/Telegram/SourceFiles/media/media_defs.h b/Telegram/SourceFiles/media/media_defs.h new file mode 100644 index 000000000..21e270bad --- /dev/null +++ b/Telegram/SourceFiles/media/media_defs.h @@ -0,0 +1,31 @@ + +/* +This file is part of Kepka, +an unofficial desktop version of Telegram messaging app, see https://procxx.github.io/ + +Kepka is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/procxx/kepka/blob/master/LICENSE +Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org +Copyright (c) 2017-2018 ProCxx, https://procxx.github.io/ +*/ +#pragma once + +#if defined(PROCXX_USE_NATIVE_OPEN_AL_MAC) + #include +#else + #include + #include + #include +#endif