[Mac OS] add support native OpenAl for mac os

For this you need to add cmake arg PROCXX_USE_NATIVE_OPEN_AL
This commit is contained in:
Pavel Perekhozhikh 2018-01-18 01:05:52 +03:00
parent 42fea7cd81
commit 3904a9e67c
8 changed files with 49 additions and 13 deletions

View File

@ -44,7 +44,10 @@ if (LINUX)
find_package(ALSA) find_package(ALSA)
find_package(PulseAudio) find_package(PulseAudio)
find_package(Qt5 COMPONENTS DBus) 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 # Needs OpenAL-SOFT
# Install via `brew install openal-soft` and configure with cmake call from README.md # Install via `brew install openal-soft` and configure with cmake call from README.md
find_package(OpenAL REQUIRED NO_MODULE) find_package(OpenAL REQUIRED NO_MODULE)

View File

@ -5,6 +5,10 @@ if (LINUX)
else() else()
add_definitions(-DQ_OS_LINUX32) add_definitions(-DQ_OS_LINUX32)
endif() endif()
elseif(APPLE)
if (PROCXX_USE_NATIVE_OPEN_AL_MAC)
add_definitions(-DPROCXX_USE_NATIVE_OPEN_AL_MAC)
endif()
endif() endif()
##================================================ ##================================================

View File

@ -27,9 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "platform/platform_audio.h" #include "platform/platform_audio.h"
#include "base/task_queue.h" #include "base/task_queue.h"
#include <AL/al.h> #include "media/media_defs.h"
#include <AL/alc.h>
#include <AL/alext.h>
#include <numeric> #include <numeric>
@ -1344,8 +1342,13 @@ bool audioDeviceIsConnected() {
if (!AudioDevice) { if (!AudioDevice) {
return false; 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); auto isConnected = ALint(0);
alcGetIntegerv(AudioDevice, ALC_CONNECTED, 1, &isConnected); alcGetIntegerv(AudioDevice, ALC_CONNECTED, 1, &isConnected);
#endif
if (Audio::ContextErrorHappened()) { if (Audio::ContextErrorHappened()) {
return false; return false;
} }

View File

@ -22,9 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "media/media_audio_ffmpeg_loader.h" #include "media/media_audio_ffmpeg_loader.h"
#include <AL/al.h> #include "media/media_defs.h"
#include <AL/alc.h>
#include <AL/alext.h>
#include <numeric> #include <numeric>

View File

@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "media/media_audio.h" #include "media/media_audio.h"
#include "media/media_audio_loader.h" #include "media/media_audio_loader.h"
#include "media/media_defs.h"
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
@ -30,8 +31,6 @@ extern "C" {
#include <libswresample/swresample.h> #include <libswresample/swresample.h>
} // extern "C" } // extern "C"
#include <AL/al.h>
class AbstractFFMpegLoader : public AudioPlayerLoader { class AbstractFFMpegLoader : public AudioPlayerLoader {
public: public:
AbstractFFMpegLoader(const FileLocation &file, const QByteArray &data, base::byte_vector &&bytes) : AudioPlayerLoader(file, data, std::move(bytes)) { AbstractFFMpegLoader(const FileLocation &file, const QByteArray &data, base::byte_vector &&bytes) : AudioPlayerLoader(file, data, std::move(bytes)) {

View File

@ -24,9 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "media/media_audio.h" #include "media/media_audio.h"
#include "messenger.h" #include "messenger.h"
#include <AL/al.h> #include "media/media_defs.h"
#include <AL/alc.h>
#include <AL/alext.h>
namespace Media { namespace Media {
namespace Audio { namespace Audio {

View File

@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "media/media_audio_loader.h" #include "media/media_audio_loader.h"
#include "media/media_audio.h" #include "media/media_audio.h"
#include "media/media_defs.h"
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
@ -30,7 +31,6 @@ extern "C" {
#include <libswresample/swresample.h> #include <libswresample/swresample.h>
} // extern "C" } // extern "C"
#include <AL/al.h>
struct VideoSoundData { struct VideoSoundData {
AVCodecContext *context = nullptr; AVCodecContext *context = nullptr;

View File

@ -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 <OpenAL/OpenAL.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>
#endif