mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 16:48:52 +02:00
code review changes pt2: cleaned up cmake, removed unused addUs function and windows macro from time_defs.hpp
This commit is contained in:
parent
463f28008b
commit
1fcb8b4fc2
8 changed files with 26 additions and 149 deletions
|
@ -204,12 +204,26 @@ find_package(Boost 1.70 REQUIRED)
|
|||
add_definitions("-DBOOST_ERROR_CODE_HEADER_ONLY")
|
||||
|
||||
if(WIN32)
|
||||
find_package(FLAC REQUIRED)
|
||||
find_package(Ogg REQUIRED)
|
||||
find_package(Vorbis REQUIRED)
|
||||
find_package(Opus REQUIRED)
|
||||
add_definitions(-DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0602 -DWINVER=0x0602 -DWINDOWS -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS )
|
||||
add_definitions(-DHAS_OGG -DHAS_VORBIS -DHAS_FLAC -DHAS_VORBIS_ENC -DHAS_WASAPI -DHAS_OPUS)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_path(FLAC_INCLUDE_DIRS FLAC/all.h)
|
||||
find_library(FLAC_LIBRARIES FLAC)
|
||||
find_package_handle_standard_args(FLAC DEFAULT_MSG FLAC_INCLUDE_DIRS FLAC_LIBRARIES)
|
||||
|
||||
find_path(OGG_INCLUDE_DIRS ogg/ogg.h)
|
||||
find_library(OGG_LIBRARIES ogg)
|
||||
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDE_DIRS OGG_LIBRARIES)
|
||||
|
||||
find_path(VORBIS_INCLUDE_DIRS vorbis/vorbisenc.h)
|
||||
find_library(VORBIS_LIBRARIES vorbis)
|
||||
find_package_handle_standard_args(Vorbis DEFAULT_MSG VORBIS_INCLUDE_DIRS VORBIS_LIBRARIES)
|
||||
|
||||
find_path(OPUS_INCLUDE_DIRS opus/opus.h)
|
||||
find_library(OPUS_LIBRARIES opus)
|
||||
find_package_handle_standard_args(Opus REQUIRED OPUS_INCLUDE_DIRS OPUS_LIBRARIES)
|
||||
|
||||
add_definitions(-DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0602 -DWINVER=0x0602 -DWINDOWS -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS )
|
||||
add_definitions(-DHAS_OGG -DHAS_VORBIS -DHAS_FLAC -DHAS_VORBIS_ENC -DHAS_OPUS -DHAS_WASAPI)
|
||||
endif()
|
||||
|
||||
add_subdirectory(common)
|
||||
|
@ -220,4 +234,4 @@ endif()
|
|||
|
||||
if (BUILD_CLIENT)
|
||||
add_subdirectory(client)
|
||||
endif()
|
||||
endif()
|
|
@ -14,7 +14,7 @@ set(CLIENT_INCLUDE
|
|||
${CMAKE_SOURCE_DIR}/client
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${ASIO_INCLUDE_DIRS}
|
||||
${POPL_INCLUDE_DIRS})
|
||||
${POPL_INCLUDE_DIRS})
|
||||
|
||||
|
||||
if(MACOSX)
|
||||
|
@ -30,11 +30,9 @@ if(MACOSX)
|
|||
find_library(COREFOUNDATION_LIB CoreFoundation)
|
||||
find_library(AUDIOTOOLBOX_LIB AudioToolbox)
|
||||
list(APPEND CLIENT_LIBRARIES ${COREAUDIO_LIB} ${COREFOUNDATION_LIB} ${AUDIOTOOLBOX_LIB})
|
||||
elseif (WIN32)
|
||||
list(REMOVE_ITEM CLIENT_INCLUDE "common/daemon.cpp")
|
||||
list(APPEND CLIENT_SOURCES player/wasapi_player.cpp decoder/ogg_decoder.cpp)
|
||||
list(APPEND CLIENT_LIBRARIES ${FLAC_LIBRARIES} ${OGG_LIBRARIES} ${VORBIS_LIBRARIES} ${OGG_LIBRARIES} wsock32 ws2_32 avrt ksuser iphlpapi)
|
||||
list(APPEND CLIENT_INCLUDE ${FLAC_INCLUDE_DIRS} ${OGG_INCLUDE_DIRS} ${VORBIS_INCLUDE_DIRS})
|
||||
elseif (WIN32)
|
||||
list(APPEND CLIENT_SOURCES player/wasapi_player.cpp)
|
||||
list(APPEND CLIENT_LIBRARIES wsock32 ws2_32 avrt ksuser iphlpapi)
|
||||
else()
|
||||
# Avahi
|
||||
if (AVAHI_FOUND)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
# - Try to find FLAC
|
||||
# Once done this will define
|
||||
#
|
||||
# FLAC_FOUND - system has libFLAC
|
||||
# FLAC_INCLUDE_DIRS - the libFLAC include directory
|
||||
# FLAC_LIBRARIES - The libFLAC libraries
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (FLAC flac)
|
||||
list(APPEND FLAC_INCLUDE_DIRS ${FLAC_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
if(NOT FLAC_FOUND)
|
||||
find_path(FLAC_INCLUDE_DIRS FLAC/all.h)
|
||||
find_library(FLAC_LIBRARIES FLAC)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FLAC DEFAULT_MSG FLAC_INCLUDE_DIRS FLAC_LIBRARIES)
|
||||
|
||||
mark_as_advanced(FLAC_INCLUDE_DIRS FLAC_LIBRARIES)
|
|
@ -1,22 +0,0 @@
|
|||
# - Try to find ogg
|
||||
# Once done this will define
|
||||
#
|
||||
# OGG_FOUND - system has ogg
|
||||
# OGG_INCLUDE_DIRS - the ogg include directory
|
||||
# OGG_LIBRARIES - The ogg libraries
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (OGG ogg)
|
||||
list(APPEND OGG_INCLUDE_DIRS ${OGG_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
if(NOT OGG_FOUND)
|
||||
find_path(OGG_INCLUDE_DIRS ogg/ogg.h)
|
||||
find_library(OGG_LIBRARIES ogg)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDE_DIRS OGG_LIBRARIES)
|
||||
|
||||
mark_as_advanced(OGG_INCLUDE_DIRS OGG_LIBRARIES)
|
|
@ -1,22 +0,0 @@
|
|||
# - Try to find Opus
|
||||
# Once done this will define
|
||||
#
|
||||
# OPUS_FOUND - system has opus
|
||||
# OPUS_INCLUDE_DIRS - the opus include directory
|
||||
# OPUS_LIBRARIES - The opus libraries
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (OPUS opus)
|
||||
list(APPEND OPUS_INCLUDE_DIRS ${OPUS_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
if(NOT OPUS_FOUND)
|
||||
find_path(OPUS_INCLUDE_DIRS opus/opus.h)
|
||||
find_library(OPUS_LIBRARIES opus)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Opus DEFAULT_MSG OPUS_INCLUDE_DIRS OPUS_LIBRARIES)
|
||||
|
||||
mark_as_advanced(OPUS_INCLUDE_DIRS OPUS_LIBRARIES)
|
|
@ -1,22 +0,0 @@
|
|||
# - Try to find vorbis
|
||||
# Once done this will define
|
||||
#
|
||||
# VORBIS_FOUND - system has libvorbis
|
||||
# VORBIS_INCLUDE_DIRS - the libvorbis include directory
|
||||
# VORBIS_LIBRARIES - The libvorbis libraries
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (VORBIS vorbis)
|
||||
list(APPEND VORBIS_INCLUDE_DIRS ${VORBIS_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
if(NOT VORBIS_FOUND)
|
||||
find_path(VORBIS_INCLUDE_DIRS vorbis/vorbisenc.h)
|
||||
find_library(VORBIS_LIBRARIES vorbis)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Vorbis DEFAULT_MSG VORBIS_INCLUDE_DIRS VORBIS_LIBRARIES)
|
||||
|
||||
mark_as_advanced(VORBIS_INCLUDE_DIRS VORBIS_LIBRARIES)
|
|
@ -1,17 +0,0 @@
|
|||
# - Try to find vorbisenc
|
||||
# Once done this will define
|
||||
#
|
||||
# VORBISENC_FOUND - system has libvorbisenc
|
||||
# VORBISENC_INCLUDE_DIRS - the libvorbisenc include directory
|
||||
# VORBISENC_LIBRARIES - The libvorbisenc libraries
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (VORBISENC vorbisenc)
|
||||
list(APPEND VORBISENC_INCLUDE_DIRS ${VORBISENC_INCLUDEDIR})
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Vorbis DEFAULT_MSG VORBISENC_INCLUDE_DIRS VORBISENC_LIBRARIES)
|
||||
|
||||
mark_as_advanced(VORBISENC_INCLUDE_DIRS VORBISENC_LIBRARIES)
|
|
@ -28,24 +28,10 @@
|
|||
|
||||
#ifndef WINDOWS
|
||||
#include <sys/time.h>
|
||||
#else // from the GNU C library implementation of sys/time.h
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include <stdint.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
#define timersub(a, b, result) \
|
||||
do \
|
||||
{ \
|
||||
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
|
||||
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
|
||||
if ((result)->tv_usec < 0) \
|
||||
{ \
|
||||
--(result)->tv_sec; \
|
||||
(result)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLOCK_MONOTONIC 42 // discarded on windows plaforms
|
||||
#endif
|
||||
|
||||
namespace chronos
|
||||
|
@ -120,22 +106,6 @@ inline ToDuration diff(const timeval& tv1, const timeval& tv2)
|
|||
return std::chrono::duration_cast<ToDuration>(std::chrono::seconds(sec) + std::chrono::microseconds(usec));
|
||||
}
|
||||
|
||||
|
||||
inline static void addUs(timeval& tv, int us)
|
||||
{
|
||||
if (us < 0)
|
||||
{
|
||||
timeval t;
|
||||
t.tv_sec = -us / 1000000;
|
||||
t.tv_usec = (-us % 1000000);
|
||||
timersub(&tv, &t, &tv);
|
||||
return;
|
||||
}
|
||||
tv.tv_usec += us;
|
||||
tv.tv_sec += (tv.tv_usec / 1000000);
|
||||
tv.tv_usec %= 1000000;
|
||||
}
|
||||
|
||||
inline static long getTickCount()
|
||||
{
|
||||
#if defined (MACOS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue