switched to ogg tremor decoder

This commit is contained in:
badaix 2016-04-01 23:50:50 +02:00
parent b29fadc465
commit c0ca0bef57
5 changed files with 128 additions and 12 deletions

116
Makefile.openwrt Executable file
View file

@ -0,0 +1,116 @@
#
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/target.mk
PKG_NAME := snapcast
PKG_VERSION := 0_5_0
PKG_RELEASE := $(PKG_SOURCE_VERSION)
PKG_USE_MIPS16 := 0
include $(INCLUDE_DIR)/package.mk
define Package/snapcast/Default
SECTION := sxx
CATEGORY := Sxx
TITLE := snapcast
DEPENDS := +libstdcpp +libavahi-client +libatomic +libogg +libflac
endef
define Package/snapcast/description/Default
A collection of multiroom functions
endef
define Package/snapcast
$(call Package/snapcast/Default)
TITLE += packages
endef
define Package/snapcast/description
$(call Package/snapcast/description/Default)
This Package provide for multiroom function
Include Server and Client
endef
define Package/snapserver
$(call Package/snapcast/Default)
TITLE += snapserver
HIDDEN := 1
endef
define Package/snapclient
$(call Package/snapcast/Default)
TILE += snapclient
DEPENDS += +alsa-lib +libvorbisidec
HIDDEN := 1
endef
define Package/snapserver/description
$(call Package/snapcast/description/Default)
Multiroom server program.
endef
define Package/snapclient/description
$(call Package/snapcast/description/Default)
Multiroom client program.
endef
define Package/snapcast/config
menu "Select snapcast Options"
depends on PACKAGE_snapcast
comment "Choose server or client to compile"
config PACKAGE_snapserver
prompt "Compile snapserver"
help
Compile multiroom server.
default n
config PACKAGE_snapclient
prompt "Compile snapclient."
help
Compile multiroom client.
default n
endmenu
endef
define Build/Prepare
$(call Build/Prepare/Default)
$(CP) -r src/common/ $(PKG_BUILD_DIR)
$(CP) -r src/message/ $(PKG_BUILD_DIR)
$(CP) -r src/externals/ $(PKG_BUILD_DIR)
$(if $(CONFIG_PACKAGE_snapserver), \
$(CP) -r src/server/ $(PKG_BUILD_DIR),)
$(if $(CONFIG_PACKAGE_snapclient), \
$(CP) -r src/client/ $(PKG_BUILD_DIR),)
endef
define Build/Compile
# $(if $(CONFIG_PACKAGE_snapserver), \
# $(call Build/Compile/Default, -C server),)
$(if $(CONFIG_PACKAGE_snapclient), \
$(call Build/Compile/Default, -C client TARGET=OPENWRT),)
endef
define Package/snapcast/Default/install
true
endef
define Package/snapserver/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/server/snapserver $(1)/usr/bin/
endef
define Package/snapclient/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/client/snapclient $(1)/usr/bin/
endef
#$(eval $(call BuildPackage,snapserver))
$(eval $(call BuildPackage,snapclient))
$(eval $(call BuildPackage,snapcast))

View file

@ -34,7 +34,7 @@ First install all packages needed to compile Snapcast
For Debian derivates (e.g. Raspbian, Debian, Ubuntu, Mint):
$ sudo apt-get install git build-essential
$ sudo apt-get install libasound2-dev libvorbis-dev libflac-dev alsa-utils libavahi-client-dev avahi-daemon
$ sudo apt-get install libasound2-dev libvorbisidec-dev libvorbis-dev libflac-dev alsa-utils libavahi-client-dev avahi-daemon
Compilation requires gcc 4.8 or higher, so it's highly recommended to use Debian (Respbian) Jessie.

View file

@ -31,7 +31,7 @@ OBJ += player/openslPlayer.o
else ifeq ($(TARGET), OPENWRT)
CXXFLAGS += -DIS_BIG_ENDIAN -DNO_TO_STRING -DNO_STOUL -DNO_STOI -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common -latomic
LDFLAGS = -lasound -logg -lvorbisidec -lFLAC -lavahi-client -lavahi-common -latomic
OBJ += player/alsaPlayer.o decoder/oggDecoder.o browseAvahi.o
else
@ -39,7 +39,7 @@ else
CXX = /usr/bin/g++
STRIP = strip
CXXFLAGS += -static-libgcc -static-libstdc++ -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lrt -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common
LDFLAGS = -lrt -lasound -logg -lvorbisidec -lFLAC -lavahi-client -lavahi-common
OBJ += player/alsaPlayer.o decoder/oggDecoder.o browseAvahi.o
endif

View file

@ -19,7 +19,7 @@
#include <iostream>
#include <cstring>
#include <cmath>
#include <vorbis/vorbisenc.h>
//#include <tremor/ivorbisfile.h>
#include "oggDecoder.h"
#include "common/snapException.h"
@ -42,8 +42,8 @@ OggDecoder::~OggDecoder()
{
std::lock_guard<std::mutex> lock(mutex_);
free(convbuffer);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
ogg_stream_clear(&os);
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi); /* must be called last */
@ -92,7 +92,7 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
continue; /* missing or corrupt data at this page position */
/* no reason to complain; already complained above */
/* we have a packet. Decode it */
float **pcm;
ogg_int32_t **pcm;
int samples;
if (vorbis_synthesis(&vb,&op) == 0) /* test for success! */
@ -113,17 +113,17 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
for(int i=0; i<vi.channels; i++)
{
ogg_int16_t *ptr=convbuffer+i;
float *mono=pcm[i];
ogg_int32_t *mono=pcm[i];
for (int j=0; j<bout; j++)
{
int val=floor(mono[j]*32767.f+.5f);
ogg_int32_t val = mono[j] >> 9;//floor(mono[j]*32767.f+.5f);
/* might as well guard against clipping */
if(val>32767)
val=32767;
else if(val<-32768)
val=-32768;
*ptr=SWAP_16(val);
ptr+=vi.channels;
*ptr = SWAP_16(val);
ptr += vi.channels;
}
}

View file

@ -19,7 +19,7 @@
#ifndef OGG_DECODER_H
#define OGG_DECODER_H
#include "decoder.h"
#include <vorbis/codec.h>
#include <tremor/ivorbiscodec.h>
class OggDecoder : public Decoder