diff --git a/client/Makefile b/client/Makefile
index 31f68edc..3a1c7faa 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -10,7 +10,7 @@ else
endif
-CXXFLAGS += $(ADD_CFLAGS) -std=c++0x -Wall -Wno-unused-function -O3 -pthread -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I. -I.. -I../externals/asio/asio/include -I../externals/popl/include
+CXXFLAGS += $(ADD_CFLAGS) -std=c++0x -Wall -Wno-unused-function -O3 -DASIO_STANDALONE -DVERSION=\"$(VERSION)\" -I. -I.. -I../externals/asio/asio/include -I../externals/popl/include
OBJ = snapClient.o stream.o clientConnection.o timeProvider.o player/player.o decoder/pcmDecoder.o decoder/oggDecoder.o decoder/flacDecoder.o controller.o ../message/pcmChunk.o ../common/log.o ../common/sampleFormat.o
ifeq ($(ENDIAN), BIG)
@@ -21,22 +21,30 @@ ifeq ($(TARGET), ANDROID)
CXX = $(NDK_DIR)/bin/arm-linux-androideabi-g++
STRIP = $(NDK_DIR)/bin/arm-linux-androideabi-strip
-CXXFLAGS += -DANDROID -DNO_CPP11_STRING -fPIC -DHAS_TREMOR -DHAS_OPENSL -I$(NDK_DIR)/include
+CXXFLAGS += -pthread -DANDROID -DNO_CPP11_STRING -fPIC -DHAS_TREMOR -DHAS_OPENSL -I$(NDK_DIR)/include
LDFLAGS = -L$(NDK_DIR)/lib -pie -lvorbisidec -logg -lFLAC -lOpenSLES
OBJ += player/openslPlayer.o
else ifeq ($(TARGET), OPENWRT)
STRIP = echo
-CXXFLAGS += -DNO_CPP11_STRING -DHAS_TREMOR -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
+CXXFLAGS += -pthread -DNO_CPP11_STRING -DHAS_TREMOR -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lasound -lvorbisidec -logg -lFLAC -lavahi-client -lavahi-common -latomic
OBJ += player/alsaPlayer.o browseAvahi.o
+else ifeq ($(TARGET), MAC)
+
+CXX = /usr/bin/g++
+STRIP = strip
+CXXFLAGS += -DHAS_TREMOR -DHAS_COREAUDIO -DFREEBSD -I/usr/local/include -Wno-unused-local-typedef
+LDFLAGS = -logg -lvorbisidec -lFLAC -L/usr/local/lib -framework AudioToolbox -framework CoreFoundation
+OBJ += player/coreAudioPlayer.o
+
else
CXX = /usr/bin/g++
STRIP = strip
-CXXFLAGS += -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
+CXXFLAGS += -pthread -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lrt -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common -static-libgcc -static-libstdc++
OBJ += player/alsaPlayer.o browseAvahi.o
diff --git a/client/controller.cpp b/client/controller.cpp
index 4f9e91ee..dbd7d302 100644
--- a/client/controller.cpp
+++ b/client/controller.cpp
@@ -116,6 +116,8 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
player_.reset(new AlsaPlayer(pcmDevice_, stream_.get()));
#elif HAS_OPENSL
player_.reset(new OpenslPlayer(pcmDevice_, stream_.get()));
+#elif HAS_COREAUDIO
+ player_.reset(new CoreAudioPlayer(pcmDevice_, stream_.get()));
#else
throw SnapException("No ALSA or OPENSL support");
#endif
diff --git a/client/controller.h b/client/controller.h
index 039e529f..8680abed 100644
--- a/client/controller.h
+++ b/client/controller.h
@@ -29,6 +29,8 @@
#include "player/alsaPlayer.h"
#elif HAS_OPENSL
#include "player/openslPlayer.h"
+#elif HAS_COREAUDIO
+#include "player/coreAudioPlayer.h"
#endif
#include "clientConnection.h"
#include "stream.h"
diff --git a/client/player/coreAudioPlayer.cpp b/client/player/coreAudioPlayer.cpp
new file mode 100644
index 00000000..6413b032
--- /dev/null
+++ b/client/player/coreAudioPlayer.cpp
@@ -0,0 +1,50 @@
+/***
+ This file is part of snapcast
+ Copyright (C) 2014-2016 Johannes Pohl
+
+ This program 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.
+
+ This program 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+***/
+
+#include
+
+#include
+#include
+#include
+
+#include "coreAudioPlayer.h"
+
+
+//http://stackoverflow.com/questions/4863811/how-to-use-audioqueue-to-play-a-sound-for-mac-osx-in-c
+//https://gist.github.com/andormade/1360885
+
+
+CoreAudioPlayer::CoreAudioPlayer(const PcmDevice& pcmDevice, Stream* stream) : Player(pcmDevice, stream)
+{
+}
+
+
+CoreAudioPlayer::~CoreAudioPlayer()
+{
+}
+
+
+void CoreAudioPlayer::worker()
+{
+ while (active_)
+ {
+ usleep(100*1000);
+ }
+}
+
+
diff --git a/client/player/coreAudioPlayer.h b/client/player/coreAudioPlayer.h
new file mode 100644
index 00000000..6b8a350e
--- /dev/null
+++ b/client/player/coreAudioPlayer.h
@@ -0,0 +1,42 @@
+/***
+ This file is part of snapcast
+ Copyright (C) 2014-2016 Johannes Pohl
+
+ This program 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.
+
+ This program 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+***/
+
+#ifndef CORE_AUDIO_PLAYER_H
+#define CORE_AUDIO_PLAYER_H
+
+#include "player.h"
+
+
+/// Audio Player
+/**
+ * Audio player implementation using CoreAudio
+ */
+class CoreAudioPlayer : public Player
+{
+public:
+ CoreAudioPlayer(const PcmDevice& pcmDevice, Stream* stream);
+ virtual ~CoreAudioPlayer();
+
+protected:
+ virtual void worker();
+
+};
+
+
+#endif
+
diff --git a/client/timeProvider.cpp b/client/timeProvider.cpp
index 3b17e758..15177592 100644
--- a/client/timeProvider.cpp
+++ b/client/timeProvider.cpp
@@ -41,7 +41,7 @@ void TimeProvider::setDiffToServer(double ms)
gettimeofday(&now, NULL);
/// clear diffBuffer if last update is older than a minute
- if (!diffBuffer_.empty() && (abs(now.tv_sec - lastTimeSync) > 60))
+ if (!diffBuffer_.empty() && (std::abs(now.tv_sec - lastTimeSync) > 60))
{
logO << "Last time sync older than a minute. Clearing time buffer\n";
diffToServer_ = ms*1000;
diff --git a/common/timeDefs.h b/common/timeDefs.h
index 64866b98..2e021c98 100644
--- a/common/timeDefs.h
+++ b/common/timeDefs.h
@@ -48,9 +48,15 @@ namespace chronos
inline static long getTickCount()
{
+#ifdef __MACH__
+ struct timeval now;
+ gettimeofday(&now, NULL);
+ return now.tv_sec*1000 + now.tv_usec / 1000;
+#else
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec*1000 + now.tv_nsec / 1000000;
+#endif
}
template
diff --git a/notes.txt b/notes.txt
index 7924554b..f072ef08 100644
--- a/notes.txt
+++ b/notes.txt
@@ -91,3 +91,7 @@ libflac8
libogg0
libvorbis0a
libvorbisenc2
+
+
+*Mac
+brew install autoconf automake pkg-config libtool