Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Jan 4, 2019
1 parent 9552b27 commit 80f15e1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
8 changes: 5 additions & 3 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ void parse_general_audio_options(void) {
config.audio_backend_buffer_desired_length = dvalue;
}
}

/* Get the minumum buffer size for fancy interpolation setting in seconds. */
if (config_lookup_float(config.cfg, "general.audio_backend_buffer_interpolation_threshold_in_seconds",
if (config_lookup_float(config.cfg,
"general.audio_backend_buffer_interpolation_threshold_in_seconds",
&dvalue)) {
if ((dvalue < 0) || (dvalue > config.audio_backend_buffer_desired_length)) {
die("Invalid audio_backend_buffer_interpolation_threshold_in_seconds value: \"%f\". It "
"should be between 0 and "
"audio_backend_buffer_desired_length_in_seconds of %.3f, default is %.3f seconds",
dvalue, config.audio_backend_buffer_desired_length,config.audio_backend_buffer_interpolation_threshold_in_seconds);
dvalue, config.audio_backend_buffer_desired_length,
config.audio_backend_buffer_interpolation_threshold_in_seconds);
} else {
config.audio_backend_buffer_interpolation_threshold_in_seconds = dvalue;
}
Expand Down
21 changes: 12 additions & 9 deletions audio_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,8 @@ static int init(int argc, char **argv) {

config.audio_backend_latency_offset = 0;
config.audio_backend_buffer_desired_length = 0.15;
config.audio_backend_buffer_interpolation_threshold_in_seconds = 0.050; // below this, basic interpolation will be used to save time.
config.audio_backend_buffer_interpolation_threshold_in_seconds =
0.050; // below this, basic interpolation will be used to save time.
config.alsa_maximum_stall_time = 0.200; // 200 milliseconds -- if it takes longer, it's a problem

// get settings from settings file first, allow them to be overridden by
Expand Down Expand Up @@ -1145,11 +1146,12 @@ int untimed_play(void *buf, int samples) {
if (ret == 0) { // will be non-zero if an error or a stall

if ((samples != 0) && (buf != NULL)) {

// jut check the state of the DAC

if ((state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING) && (state != SND_PCM_STATE_XRUN)) {
debug(1,"alsa: DAC in odd SND_PCM_STATE_* %d prior to writing.",state);

if ((state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING) &&
(state != SND_PCM_STATE_XRUN)) {
debug(1, "alsa: DAC in odd SND_PCM_STATE_* %d prior to writing.", state);
}

// debug(3, "write %d frames.", samples);
Expand Down Expand Up @@ -1188,16 +1190,17 @@ int untimed_play(void *buf, int samples) {
if (ret == -EPIPE) { /* underrun */
ret = snd_pcm_recover(alsa_handle, ret, debuglev > 0 ? 1 : 0);
if (ret < 0) {
debug(1, "alsa: failed to recover from SND_PCM_STATE_XRUN with snd_pcm_recover(); trying snd_pcm_prepare().");
debug(1, "alsa: failed to recover from SND_PCM_STATE_XRUN with snd_pcm_recover(); "
"trying snd_pcm_prepare().");
ret = snd_pcm_prepare(alsa_handle);
if (ret < 0)
warn("alsa: can't recover from SND_PCM_STATE_XRUN, snd_pcm_recover() and "
"snd_pcm_prepare() failed: %s.",
snd_strerror(ret));
}
} else if (ret == -ESTRPIPE) { /* suspended */
while ((ret = snd_pcm_resume(alsa_handle)) == -EAGAIN) {
sleep(1); /* wait until the suspend flag is released */
while ((ret = snd_pcm_resume(alsa_handle)) == -EAGAIN) {
sleep(1); /* wait until the suspend flag is released */
if (ret < 0) {
ret = snd_pcm_prepare(alsa_handle);
if (ret < 0)
Expand All @@ -1209,7 +1212,7 @@ int untimed_play(void *buf, int samples) {
}
}
}
} else {
} else {
debug(1, "alsa: device status %d faulty for play.", state);
frame_index = 0;
measurement_data_is_valid = 0;
Expand Down
4 changes: 3 additions & 1 deletion audio_jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ void *open_client_if_necessary_thread_function(void *arg) {
int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) {
config.audio_backend_latency_offset = 0;
config.audio_backend_buffer_desired_length = 0.500;
config.audio_backend_buffer_interpolation_threshold_in_seconds = 0.25; // below this, soxr interpolation will not occur -- it'll be basic interpolation instead.
config.audio_backend_buffer_interpolation_threshold_in_seconds =
0.25; // below this, soxr interpolation will not occur -- it'll be basic interpolation
// instead.
config.jack_auto_client_open_interval = 1; // check every second

// get settings from settings file first, allow them to be overridden by
Expand Down
4 changes: 3 additions & 1 deletion audio_pa.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *

// set up default values first
config.audio_backend_buffer_desired_length = 0.35;
config.audio_backend_buffer_interpolation_threshold_in_seconds = 0.02; // below this, soxr interpolation will not occur -- it'll be basic interpolation instead.
config.audio_backend_buffer_interpolation_threshold_in_seconds =
0.02; // below this, soxr interpolation will not occur -- it'll be basic interpolation
// instead.

config.audio_backend_latency_offset = 0;

Expand Down
4 changes: 3 additions & 1 deletion audio_sndio.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ static int init(int argc, char **argv) {
devname = SIO_DEVANY;

config.audio_backend_buffer_desired_length = 1.0;
config.audio_backend_buffer_interpolation_threshold_in_seconds = 0.25; // below this, soxr interpolation will not occur -- it'll be basic interpolation instead.
config.audio_backend_buffer_interpolation_threshold_in_seconds =
0.25; // below this, soxr interpolation will not occur -- it'll be basic interpolation
// instead.
config.audio_backend_latency_offset = 0;

// get settings from settings file
Expand Down
4 changes: 3 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ typedef struct {
int interface_index; // only valid if the interface string is non-NULL
double audio_backend_buffer_desired_length; // this will be the length in seconds of the
// audio backend buffer -- the DAC buffer for ALSA
double audio_backend_buffer_interpolation_threshold_in_seconds; // below this, soxr interpolation will not occur -- it'll be basic interpolation instead.
double audio_backend_buffer_interpolation_threshold_in_seconds; // below this, soxr interpolation
// will not occur -- it'll be
// basic interpolation instead.
double audio_backend_latency_offset; // this will be the offset in seconds to compensate for any
// fixed latency there might be in the audio path
double audio_backend_silent_lead_in_time; // the length of the silence that should precede a play.
Expand Down
10 changes: 5 additions & 5 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ void *player_thread_func(void *arg) {
conn->first_packet_timestamp = 0;
conn->flush_requested = 0;
conn->fix_volume = 0x10000;

if (conn->latency == 0) {
debug(3, "No latency has (yet) been specified. Setting 88,200 (2 seconds) frames "
"as a default.");
Expand Down Expand Up @@ -1551,9 +1551,10 @@ void *player_thread_func(void *arg) {

debug(3, "Output frame bytes is %d.", conn->output_bytes_per_frame);

conn->dac_buffer_queue_minimum_length = (int64_t)(config.audio_backend_buffer_interpolation_threshold_in_seconds *
config.output_rate);
debug(1,"dac_buffer_queue_minimum_length is %" PRId64 " frames.", conn->dac_buffer_queue_minimum_length);
conn->dac_buffer_queue_minimum_length = (int64_t)(
config.audio_backend_buffer_interpolation_threshold_in_seconds * config.output_rate);
debug(1, "dac_buffer_queue_minimum_length is %" PRId64 " frames.",
conn->dac_buffer_queue_minimum_length);

conn->session_corrections = 0;
// conn->play_segment_reference_frame = 0; // zero signals that we are not in a play segment
Expand Down Expand Up @@ -2835,4 +2836,3 @@ int player_stop(rtsp_conn_info *conn) {
return -1;
}
}

0 comments on commit 80f15e1

Please sign in to comment.