support for vorbis and tremor (-DHAS_TREMOR)

This commit is contained in:
badaix 2016-04-10 22:52:02 +02:00
parent ae557f0d79
commit 73175adedf
4 changed files with 21 additions and 6 deletions

View file

@ -24,7 +24,7 @@ OBJ += player/openslPlayer.o
else ifeq ($(TARGET), OPENWRT) else ifeq ($(TARGET), OPENWRT)
STRIP = echo STRIP = echo
CXXFLAGS += -DIS_BIG_ENDIAN -DNO_CPP11_STRING -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON CXXFLAGS += -DIS_BIG_ENDIAN -DNO_CPP11_STRING -DHAS_TREMOR -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lasound -logg -lvorbisidec -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 OBJ += player/alsaPlayer.o decoder/oggDecoder.o browseAvahi.o
@ -33,7 +33,7 @@ else
CXX = /usr/bin/g++ CXX = /usr/bin/g++
STRIP = strip STRIP = strip
CXXFLAGS += -static-libgcc -static-libstdc++ -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON CXXFLAGS += -static-libgcc -static-libstdc++ -DHAS_OGG -DHAS_ALSA -DHAS_AVAHI -DHAS_DAEMON
LDFLAGS = -lrt -lasound -logg -lvorbisidec -lFLAC -lavahi-client -lavahi-common LDFLAGS = -lrt -lasound -logg -lvorbis -lFLAC -lavahi-client -lavahi-common
OBJ += player/alsaPlayer.o decoder/oggDecoder.o browseAvahi.o OBJ += player/alsaPlayer.o decoder/oggDecoder.o browseAvahi.o
endif endif

View file

@ -19,7 +19,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <memory> #include <memory>
#ifdef HAS_OGG #if defined(HAS_OGG) || defined(HAS_TREMOR)
#include "decoder/oggDecoder.h" #include "decoder/oggDecoder.h"
#endif #endif
#include "decoder/pcmDecoder.h" #include "decoder/pcmDecoder.h"
@ -97,7 +97,7 @@ void Controller::onMessageReceived(ClientConnection* connection, const msg::Base
if (headerChunk_->codec == "pcm") if (headerChunk_->codec == "pcm")
decoder_.reset(new PcmDecoder()); decoder_.reset(new PcmDecoder());
#ifdef HAS_OGG #if defined(HAS_OGG) || defined(HAS_TREMOR)
else if (headerChunk_->codec == "ogg") else if (headerChunk_->codec == "ogg")
decoder_.reset(new OggDecoder()); decoder_.reset(new OggDecoder());
#endif #endif

View file

@ -19,7 +19,6 @@
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <cmath> #include <cmath>
//#include <tremor/ivorbisfile.h>
#include "oggDecoder.h" #include "oggDecoder.h"
#include "common/snapException.h" #include "common/snapException.h"
@ -92,7 +91,11 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
continue; /* missing or corrupt data at this page position */ continue; /* missing or corrupt data at this page position */
/* no reason to complain; already complained above */ /* no reason to complain; already complained above */
/* we have a packet. Decode it */ /* we have a packet. Decode it */
#ifdef HAS_TREMOR
ogg_int32_t **pcm; ogg_int32_t **pcm;
#else
float **pcm;
#endif
int samples; int samples;
if (vorbis_synthesis(&vb,&op) == 0) /* test for success! */ if (vorbis_synthesis(&vb,&op) == 0) /* test for success! */
@ -113,10 +116,18 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
for(int i=0; i<vi.channels; i++) for(int i=0; i<vi.channels; i++)
{ {
ogg_int16_t *ptr=convbuffer+i; ogg_int16_t *ptr=convbuffer+i;
#ifdef HAS_TREMOR
ogg_int32_t *mono=pcm[i]; ogg_int32_t *mono=pcm[i];
#else
float *mono=pcm[i];
#endif
for (int j=0; j<bout; j++) for (int j=0; j<bout; j++)
{ {
ogg_int32_t val = mono[j] >> 9;//floor(mono[j]*32767.f+.5f); #ifdef HAS_TREMOR
ogg_int32_t val = mono[j] >> 9;
#else
ogg_int32_t val = floor(mono[j]*32767.f+.5f);
#endif
/* might as well guard against clipping */ /* might as well guard against clipping */
if(val>32767) if(val>32767)
val=32767; val=32767;

View file

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