Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions decode.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
Expand All @@ -7,7 +7,7 @@
* 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
Expand Down Expand Up @@ -52,7 +52,8 @@ static bool running = true;
#define MAY_PROCESS(x)
#endif

static void *decode_thread() {
// static void *decode_thread() {
static void *decode_thread(void *arg) {

while (running) {
size_t bytes, space, min_space;
Expand All @@ -70,7 +71,7 @@ static void *decode_thread() {
LOCK_D;

if (decode.state == DECODE_RUNNING && codec) {

LOG_SDEBUG("streambuf bytes: %u outputbuf space: %u", bytes, space);

IF_DIRECT(
Expand All @@ -79,9 +80,9 @@ static void *decode_thread() {
IF_PROCESS(
min_space = process.max_out_frames * BYTES_PER_FRAME;
);

if (space > min_space && (bytes > codec->min_read_bytes || toend)) {

decode.state = codec->decode();

IF_PROCESS(
Expand All @@ -108,7 +109,7 @@ static void *decode_thread() {
ran = true;
}
}

UNLOCK_D;

if (!ran) {
Expand Down Expand Up @@ -235,9 +236,9 @@ void codec_open(u8_t format, u8_t sample_size, u8_t sample_rate, u8_t channels,
LOG_INFO("closing codec: '%c'", codec->id);
codec->close();
}

codec = codecs[i];

codec->open(sample_size, sample_rate, channels, endianness);

decode.state = DECODE_READY;
Expand All @@ -251,4 +252,3 @@ void codec_open(u8_t format, u8_t sample_size, u8_t sample_rate, u8_t channels,

LOG_ERROR("codec not found");
}

32 changes: 19 additions & 13 deletions flac.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Squeezelite - lightweight headless squeezeplay emulator for linux
*
* (c) Adrian Smith 2012, triode1@btinternet.com
Expand All @@ -7,7 +7,7 @@
* 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
Expand Down Expand Up @@ -110,7 +110,7 @@ static FLAC__StreamDecoderWriteStatus write_cb(const FLAC__StreamDecoder *decode

FLAC__int32 *lptr = (FLAC__int32 *)buffer[0];
FLAC__int32 *rptr = (FLAC__int32 *)buffer[channels > 1 ? 1 : 0];

if (decode.new_stream) {
LOCK_O;
LOG_INFO("setting track_start");
Expand All @@ -122,7 +122,7 @@ static FLAC__StreamDecoderWriteStatus write_cb(const FLAC__StreamDecoder *decode
#define MARKER_OFFSET 2
#else
#define MARKER_OFFSET 1
#endif
#endif
if (bits_per_sample == 24 && is_stream_dop(((u8_t *)lptr) + MARKER_OFFSET, ((u8_t *)rptr) + MARKER_OFFSET, 4, frames)) {
LOG_INFO("file contains DOP");
if (output.dsdfmt == DOP_S24_LE || output.dsdfmt == DOP_S24_3LE)
Expand Down Expand Up @@ -151,9 +151,9 @@ static FLAC__StreamDecoderWriteStatus write_cb(const FLAC__StreamDecoder *decode
frames_t count;
s32_t *optr;

IF_DIRECT(
optr = (s32_t *)outputbuf->writep;
f = min(_buf_space(outputbuf), _buf_cont_write(outputbuf)) / BYTES_PER_FRAME;
IF_DIRECT(
optr = (s32_t *)outputbuf->writep;
f = min(_buf_space(outputbuf), _buf_cont_write(outputbuf)) / BYTES_PER_FRAME;
);
IF_PROCESS(
optr = (s32_t *)process.inbuf;
Expand Down Expand Up @@ -225,11 +225,11 @@ static void flac_close(void) {
static decode_state flac_decode(void) {
bool ok = FLAC(f, stream_decoder_process_single, f->decoder);
FLAC__StreamDecoderState state = FLAC(f, stream_decoder_get_state, f->decoder);

if (!ok && state != FLAC__STREAM_DECODER_END_OF_STREAM) {
LOG_INFO("flac error: %s", FLAC_A(f, StreamDecoderStateString)[state]);
};

if (state == FLAC__STREAM_DECODER_END_OF_STREAM) {
return DECODE_COMPLETE;
} else if (state > FLAC__STREAM_DECODER_END_OF_STREAM) {
Expand All @@ -241,9 +241,15 @@ static decode_state flac_decode(void) {

static bool load_flac() {
#if !LINKALL
void *handle = dlopen(LIBFLAC, RTLD_NOW);
void *handle = NULL;
char name[30];
char *err;

// sprintf(name, LIBFLAC, FLAC_API_VERSION_CURRENT < 12 ? 8 : 12);
sprintf(name, "libFLAC.so");

handle = dlopen(name, RTLD_NOW);

if (!handle) {
LOG_INFO("dlerror: %s", dlerror());
return false;
Expand All @@ -259,18 +265,18 @@ static bool load_flac() {
f->FLAC__stream_decoder_get_state = dlsym(handle, "FLAC__stream_decoder_get_state");

if ((err = dlerror()) != NULL) {
LOG_INFO("dlerror: %s", err);
LOG_INFO("dlerror: %s", err);
return false;
}

LOG_INFO("loaded "LIBFLAC);
LOG_INFO("loaded %s", name);
#endif

return true;
}

struct codec *register_flac(void) {
static struct codec ret = {
static struct codec ret = {
'f', // id
"flc", // types
8192, // min read
Expand Down
11 changes: 6 additions & 5 deletions output_stdout.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
Expand All @@ -7,7 +7,7 @@
* 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
Expand Down Expand Up @@ -50,7 +50,7 @@ static int _stdout_write_frames(frames_t out_frames, bool silence, s32_t gainL,
u8_t *obuf;

if (!silence) {

if (output.fade == FADE_ACTIVE && output.fade_dir == FADE_CROSS && *cross_ptr) {
_apply_cross(outputbuf, out_frames, cross_gain_in, cross_gain_out, cross_ptr);
}
Expand Down Expand Up @@ -81,7 +81,8 @@ static int _stdout_write_frames(frames_t out_frames, bool silence, s32_t gainL,
return (int)out_frames;
}

static void *output_thread() {
// static void *output_thread() {
static void *output_thread(void *arg) {

LOCK;

Expand All @@ -100,7 +101,7 @@ static void *output_thread() {
UNLOCK;

while (running) {

LOCK;

output.device_frames = 0;
Expand Down
20 changes: 10 additions & 10 deletions squeezelite.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
/*
* Squeezelite - lightweight headless squeezebox emulator
*
* (c) Adrian Smith 2012-2015, triode1@btinternet.com
*
*
* 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
Expand Down Expand Up @@ -138,7 +138,7 @@
// dynamically loaded libraries at run time

#if LINUX
#define LIBFLAC "libFLAC.so.8"
#define LIBFLAC "libFLAC.so.%d"
#define LIBMAD "libmad.so.0"
#define LIBMPG "libmpg123.so.0"
#define LIBVORBIS "libvorbisfile.so.3"
Expand All @@ -152,7 +152,7 @@
#endif

#if OSX
#define LIBFLAC "libFLAC.8.dylib"
#define LIBFLAC "libFLAC.%d.dylib"
#define LIBMAD "libmad.0.dylib"
#define LIBMPG "libmpg123.0.dylib"
#define LIBVORBIS "libvorbisfile.3.dylib"
Expand All @@ -178,7 +178,7 @@
#endif

#if FREEBSD
#define LIBFLAC "libFLAC.so.11"
#define LIBFLAC "libFLAC.so.%d"
#define LIBMAD "libmad.so.2"
#define LIBMPG "libmpg123.so.0"
#define LIBVORBIS "libvorbisfile.so.6"
Expand Down Expand Up @@ -325,7 +325,7 @@ typedef int sockfd;
#define wake_signal(e) write(e.fds[1], ".", 1)
#define wake_clear(e) char c[10]; read(e, &c, 10)
#define wake_close(e) close(e.fds[0]); close(e.fds[1])
struct wake {
struct wake {
int fds[2];
};
#endif
Expand Down Expand Up @@ -514,7 +514,7 @@ bool resample_init(char *opt);
#endif

// output.c output_alsa.c output_pa.c output_pack.c
typedef enum { OUTPUT_OFF = -1, OUTPUT_STOPPED = 0, OUTPUT_BUFFER, OUTPUT_RUNNING,
typedef enum { OUTPUT_OFF = -1, OUTPUT_STOPPED = 0, OUTPUT_BUFFER, OUTPUT_RUNNING,
OUTPUT_PAUSE_FRAMES, OUTPUT_SKIP_FRAMES, OUTPUT_START_AT } output_state;

#if DSD
Expand All @@ -539,7 +539,7 @@ struct outputstate {
unsigned buffer;
unsigned period;
#endif
bool track_started;
bool track_started;
#if PORTAUDIO
bool pa_reopen;
unsigned latency;
Expand Down Expand Up @@ -600,7 +600,7 @@ void list_devices(void);
void list_mixers(const char *output_device);
void set_volume(unsigned left, unsigned right);
bool test_open(const char *device, unsigned rates[]);
void output_init_alsa(log_level level, const char *device, unsigned output_buf_size, char *params, unsigned rates[],
void output_init_alsa(log_level level, const char *device, unsigned output_buf_size, char *params, unsigned rates[],
unsigned rate_delay, unsigned rt_priority, unsigned idle, char *volume_mixer, bool mixer_unmute);
void output_close_alsa(void);
#endif
Expand Down
Loading