char *device_name; /* name of the PCM device */
char *control_device; /* name of the control device */
- pa_bool_t use_mmap:1, use_tsched:1, deferred_volume:1, fixed_latency_range:1;
+ bool use_mmap:1, use_tsched:1, deferred_volume:1, fixed_latency_range:1;
- pa_bool_t first, after_rewind;
+ bool first, after_rewind;
pa_rtpoll_item *alsa_rtpoll_item;
static void userdata_free(struct userdata *u);
/* FIXME: Is there a better way to do this than device names? */
-static pa_bool_t is_iec958(struct userdata *u) {
+static bool is_iec958(struct userdata *u) {
return (strncmp("iec958", u->device_name, 6) == 0);
}
-static pa_bool_t is_hdmi(struct userdata *u) {
+static bool is_hdmi(struct userdata *u) {
return (strncmp("hdmi", u->device_name, 4) == 0);
}
pa_log_debug("Suspending sink %s, because another application requested us to release the device.", u->sink->name);
- if (pa_sink_suspend(u->sink, TRUE, PA_SUSPEND_APPLICATION) < 0)
+ if (pa_sink_suspend(u->sink, true, PA_SUSPEND_APPLICATION) < 0)
return PA_HOOK_CANCEL;
return PA_HOOK_OK;
return -1;
}
- u->first = TRUE;
+ u->first = true;
u->since_start = 0;
return 0;
}
-static size_t check_left_to_play(struct userdata *u, size_t n_bytes, pa_bool_t on_timeout) {
+static size_t check_left_to_play(struct userdata *u, size_t n_bytes, bool on_timeout) {
size_t left_to_play;
- pa_bool_t underrun = FALSE;
+ bool underrun = false;
/* We use <= instead of < for this check here because an underrun
* only happens after the last sample was processed, not already when
/* We got a dropout. What a mess! */
left_to_play = 0;
- underrun = TRUE;
+ underrun = true;
#if 0
PA_DEBUG_TRAP;
#endif
if (u->use_tsched) {
- pa_bool_t reset_not_before = TRUE;
+ bool reset_not_before = true;
if (!u->first && !u->after_rewind) {
if (underrun || left_to_play < u->watermark_inc_threshold)
increase_watermark(u);
else if (left_to_play > u->watermark_dec_threshold) {
- reset_not_before = FALSE;
+ reset_not_before = false;
/* We decrease the watermark only if have actually
* been woken up by a timeout. If something else woke
return left_to_play;
}
-static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled, pa_bool_t on_timeout) {
- pa_bool_t work_done = FALSE;
+static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, bool polled, bool on_timeout) {
+ bool work_done = false;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_play, input_underrun;
unsigned j = 0;
snd_pcm_sframes_t n;
size_t n_bytes;
int r;
- pa_bool_t after_avail = TRUE;
+ bool after_avail = true;
/* First we determine how many samples are missing to fill the
* buffer up to 100% */
#endif
left_to_play = check_left_to_play(u, n_bytes, on_timeout);
- on_timeout = FALSE;
+ on_timeout = false;
if (u->use_tsched)
}
n_bytes -= u->hwbuf_unused;
- polled = FALSE;
+ polled = false;
#ifdef DEBUG_TIMING
pa_log_debug("Filling up");
break;
pa_assert(frames > 0);
- after_avail = FALSE;
+ after_avail = false;
/* Check these are multiples of 8 bit */
pa_assert((areas[0].first & 7) == 0);
p = (uint8_t*) areas[0].addr + (offset * u->frame_size);
written = frames * u->frame_size;
- chunk.memblock = pa_memblock_new_fixed(u->core->mempool, p, written, TRUE);
+ chunk.memblock = pa_memblock_new_fixed(u->core->mempool, p, written, true);
chunk.length = pa_memblock_get_length(chunk.memblock);
chunk.index = 0;
return r;
}
- work_done = TRUE;
+ work_done = true;
u->write_count += written;
u->since_start += written;
return work_done ? 1 : 0;
}
-static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled, pa_bool_t on_timeout) {
- pa_bool_t work_done = FALSE;
+static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, bool polled, bool on_timeout) {
+ bool work_done = false;
pa_usec_t max_sleep_usec = 0, process_usec = 0;
size_t left_to_play, input_underrun;
unsigned j = 0;
snd_pcm_sframes_t n;
size_t n_bytes;
int r;
- pa_bool_t after_avail = TRUE;
+ bool after_avail = true;
if (PA_UNLIKELY((n = pa_alsa_safe_avail(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
#endif
left_to_play = check_left_to_play(u, n_bytes, on_timeout);
- on_timeout = FALSE;
+ on_timeout = false;
if (u->use_tsched)
}
n_bytes -= u->hwbuf_unused;
- polled = FALSE;
+ polled = false;
for (;;) {
snd_pcm_sframes_t frames;
break;
pa_assert(frames > 0);
- after_avail = FALSE;
+ after_avail = false;
written = frames * u->frame_size;
u->memchunk.index += written;
pa_memchunk_reset(&u->memchunk);
}
- work_done = TRUE;
+ work_done = true;
u->write_count += written;
u->since_start += written;
/* Let's update the time smoother */
- if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, status, &delay, u->hwbuf_size, &u->sink->sample_spec, FALSE)) < 0)) {
+ if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, status, &delay, u->hwbuf_size, &u->sink->sample_spec, false)) < 0)) {
pa_log_warn("Failed to query DSP status data: %s", pa_alsa_strerror(err));
return;
}
/* Called from IO Context on unsuspend or from main thread when creating sink */
static void reset_watermark(struct userdata *u, size_t tsched_watermark, pa_sample_spec *ss,
- pa_bool_t in_thread) {
+ bool in_thread) {
u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, ss),
&u->sink->sample_spec);
static int unsuspend(struct userdata *u) {
pa_sample_spec ss;
int err;
- pa_bool_t b, d;
+ bool b, d;
snd_pcm_uframes_t period_size, buffer_size;
char *device_name = NULL;
b = u->use_mmap;
d = u->use_tsched;
- if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &period_size, &buffer_size, 0, &b, &d, TRUE)) < 0) {
+ if ((err = pa_alsa_set_hw_params(u->pcm_handle, &ss, &period_size, &buffer_size, 0, &b, &d, true)) < 0) {
pa_log("Failed to set hardware parameters: %s", pa_alsa_strerror(err));
goto fail;
}
goto fail;
u->write_count = 0;
- pa_smoother_reset(u->smoother, pa_rtclock_now(), TRUE);
+ pa_smoother_reset(u->smoother, pa_rtclock_now(), true);
u->smoother_interval = SMOOTHER_MIN_INTERVAL;
u->last_smoother_update = 0;
- u->first = TRUE;
+ u->first = true;
u->since_start = 0;
/* reset the watermark to the value defined when sink was created */
if (u->use_tsched)
- reset_watermark(u, u->tsched_watermark_ref, &u->sink->sample_spec, TRUE);
+ reset_watermark(u, u->tsched_watermark_ref, &u->sink->sample_spec, true);
pa_log_info("Resumed successfully...");
return 0;
if (u->sink->suspend_cause & PA_SUSPEND_SESSION) {
- pa_sink_set_mixer_dirty(u->sink, TRUE);
+ pa_sink_set_mixer_dirty(u->sink, true);
return 0;
}
if (mask & SND_CTL_EVENT_MASK_VALUE) {
- pa_sink_get_volume(u->sink, TRUE);
- pa_sink_get_mute(u->sink, TRUE);
+ pa_sink_get_volume(u->sink, true);
+ pa_sink_get_mute(u->sink, true);
}
return 0;
return 0;
if (u->sink->suspend_cause & PA_SUSPEND_SESSION) {
- pa_sink_set_mixer_dirty(u->sink, TRUE);
+ pa_sink_set_mixer_dirty(u->sink, true);
return 0;
}
struct userdata *u = s->userdata;
pa_cvolume r;
char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX];
- pa_bool_t deferred_volume = !!(s->flags & PA_SINK_DEFERRED_VOLUME);
+ bool deferred_volume = !!(s->flags & PA_SINK_DEFERRED_VOLUME);
pa_assert(u);
pa_assert(u->mixer_path);
if (u->mixer_path->has_dB) {
pa_cvolume new_soft_volume;
- pa_bool_t accurate_enough;
+ bool accurate_enough;
char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
/* Match exactly what the user requested by software */
/* Shift up by the base volume */
pa_sw_cvolume_divide_scalar(&hw_vol, &hw_vol, s->base_volume);
- if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &hw_vol, TRUE, TRUE) < 0)
+ if (pa_alsa_path_set_volume(u->mixer_path, u->mixer_handle, &s->channel_map, &hw_vol, true, true) < 0)
pa_log_error("Writing HW volume failed");
else {
pa_cvolume tmp_vol;
- pa_bool_t accurate_enough;
+ bool accurate_enough;
/* Shift down by the base volume, so that 0dB becomes maximum volume */
pa_sw_cvolume_multiply_scalar(&hw_vol, &hw_vol, s->base_volume);
static void sink_get_mute_cb(pa_sink *s) {
struct userdata *u = s->userdata;
- pa_bool_t b;
+ bool b;
pa_assert(u);
pa_assert(u->mixer_path);
pa_sink_set_write_volume_callback(u->sink, NULL);
if (u->mixer_path->has_dB) {
- pa_sink_enable_decibel_volume(u->sink, TRUE);
+ pa_sink_enable_decibel_volume(u->sink, true);
pa_log_info("Hardware volume ranges from %0.2f dB to %0.2f dB.", u->mixer_path->min_dB, u->mixer_path->max_dB);
u->sink->base_volume = pa_sw_volume_from_dB(-u->mixer_path->max_dB);
pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
} else {
- pa_sink_enable_decibel_volume(u->sink, FALSE);
+ pa_sink_enable_decibel_volume(u->sink, false);
pa_log_info("Hardware volume ranges from %li to %li.", u->mixer_path->min_volume, u->mixer_path->max_volume);
u->sink->base_volume = PA_VOLUME_NORM;
pa_assert(p);
pa_assert(u->ucm_context);
- return pa_alsa_ucm_set_port(u->ucm_context, p, TRUE);
+ return pa_alsa_ucm_set_port(u->ucm_context, p, true);
}
static int sink_set_port_cb(pa_sink *s, pa_device_port *p) {
return ret;
}
-static pa_bool_t sink_set_formats(pa_sink *s, pa_idxset *formats) {
+static bool sink_set_formats(pa_sink *s, pa_idxset *formats) {
struct userdata *u = s->userdata;
pa_format_info *f, *g;
uint32_t idx, n;
PA_IDXSET_FOREACH(f, formats, idx) {
if (is_iec958(u) && f->encoding == PA_ENCODING_EAC3_IEC61937)
/* EAC3 cannot be sent over over S/PDIF */
- return FALSE;
+ return false;
}
pa_idxset_free(u->formats, (pa_free_cb_t) pa_format_info_free);
}
}
- return TRUE;
+ return true;
}
-static pa_bool_t sink_update_rate_cb(pa_sink *s, uint32_t rate) {
+static bool sink_update_rate_cb(pa_sink *s, uint32_t rate) {
struct userdata *u = s->userdata;
int i;
- pa_bool_t supported = FALSE;
+ bool supported = false;
pa_assert(u);
for (i = 0; u->rates[i]; i++) {
if (u->rates[i] == rate) {
- supported = TRUE;
+ supported = true;
break;
}
}
if (!supported) {
pa_log_info("Sink does not support sample rate of %d Hz", rate);
- return FALSE;
+ return false;
}
if (!PA_SINK_IS_OPENED(s->state)) {
pa_log_info("Updating rate for device %s, new rate is %d",u->device_name, rate);
u->sink->sample_spec.rate = rate;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
static int process_rewind(struct userdata *u) {
pa_log_debug("Rewound %lu bytes.", (unsigned long) rewind_nbytes);
pa_sink_process_rewind(u->sink, rewind_nbytes);
- u->after_rewind = TRUE;
+ u->after_rewind = true;
return 0;
}
} else
if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
int work_done;
pa_usec_t sleep_usec = 0;
- pa_bool_t on_timeout = pa_rtpoll_timer_elapsed(u->rtpoll);
+ bool on_timeout = pa_rtpoll_timer_elapsed(u->rtpoll);
if (u->use_mmap)
work_done = mmap_write(u, &sleep_usec, revents & POLLOUT, on_timeout);
pa_log_info("Starting playback.");
snd_pcm_start(u->pcm_handle);
- pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE);
+ pa_smoother_resume(u->smoother, pa_rtclock_now(), true);
- u->first = FALSE;
+ u->first = false;
}
update_smoother(u);
rtpoll_sleep = PA_MIN(sleep_usec, cusec);
}
- u->after_rewind = FALSE;
+ u->after_rewind = false;
}
pa_rtpoll_set_timer_disabled(u->rtpoll);
/* Hmm, nothing to do. Let's sleep */
- if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
+ if ((ret = pa_rtpoll_run(u->rtpoll, true)) < 0)
goto fail;
if (rtpoll_sleep > 0) {
if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
goto fail;
- u->first = TRUE;
+ u->first = true;
u->since_start = 0;
revents = 0;
} else if (revents && u->use_tsched && pa_log_ratelimit(PA_LOG_DEBUG))
if ((n = pa_modargs_get_value(ma, "sink_name", NULL))) {
pa_sink_new_data_set_name(data, n);
- data->namereg_fail = TRUE;
+ data->namereg_fail = true;
return;
}
if ((n = pa_modargs_get_value(ma, "name", NULL)))
- data->namereg_fail = TRUE;
+ data->namereg_fail = true;
else {
n = device_id ? device_id : device_name;
- data->namereg_fail = FALSE;
+ data->namereg_fail = false;
}
if (mapping)
pa_xfree(t);
}
-static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, pa_bool_t ignore_dB) {
+static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, bool ignore_dB) {
snd_hctl_t *hctl;
if (!mapping && !element)
}
}
-static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
- pa_bool_t need_mixer_callback = FALSE;
+static int setup_mixer(struct userdata *u, bool ignore_dB) {
+ bool need_mixer_callback = false;
pa_assert(u);
PA_HASHMAP_FOREACH(p, u->mixer_path_set->paths, state) {
if (p->has_volume || p->has_mute)
- need_mixer_callback = TRUE;
+ need_mixer_callback = true;
}
}
else if (u->mixer_path)
uint32_t nfrags, frag_size, buffer_size, tsched_size, tsched_watermark, rewind_safeguard;
snd_pcm_uframes_t period_frames, buffer_frames, tsched_frames;
size_t frame_size;
- pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE, namereg_fail = FALSE, deferred_volume = FALSE, set_formats = FALSE, fixed_latency_range = FALSE;
+ bool use_mmap = true, b, use_tsched = true, d, ignore_dB = false, namereg_fail = false, deferred_volume = false, set_formats = false, fixed_latency_range = false;
pa_sink_new_data data;
pa_alsa_profile_set *profile_set = NULL;
void *state = NULL;
u->use_tsched = use_tsched;
u->deferred_volume = deferred_volume;
u->fixed_latency_range = fixed_latency_range;
- u->first = TRUE;
+ u->first = true;
u->rewind_safeguard = rewind_safeguard;
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
u->smoother = pa_smoother_new(
SMOOTHER_ADJUST_USEC,
SMOOTHER_WINDOW_USEC,
- TRUE,
- TRUE,
+ true,
+ true,
5,
pa_rtclock_now(),
- TRUE);
+ true);
u->smoother_interval = SMOOTHER_MIN_INTERVAL;
/* use ucm */
&ss, &map,
SND_PCM_STREAM_PLAYBACK,
&period_frames, &buffer_frames, tsched_frames,
- &b, &d, FALSE)))
+ &b, &d, false)))
goto fail;
}
if (use_mmap && !b) {
pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
- u->use_mmap = use_mmap = FALSE;
+ u->use_mmap = use_mmap = false;
}
if (use_tsched && (!b || !d)) {
pa_log_info("Cannot enable timer-based scheduling, falling back to sound IRQ scheduling.");
- u->use_tsched = use_tsched = FALSE;
+ u->use_tsched = use_tsched = false;
}
if (u->use_mmap)
}
if (is_iec958(u) || is_hdmi(u))
- set_formats = TRUE;
+ set_formats = true;
u->rates = pa_alsa_get_supported_rates(u->pcm_handle, ss.rate);
if (!u->rates) {
}
if (u->ucm_context)
- pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, TRUE, card);
+ pa_alsa_ucm_add_ports(&data.ports, data.proplist, u->ucm_context, true, card);
else if (u->mixer_path_set)
pa_alsa_add_ports(&data, u->mixer_path_set, card);
if (u->use_tsched) {
u->tsched_watermark_ref = tsched_watermark;
- reset_watermark(u, u->tsched_watermark_ref, &ss, FALSE);
+ reset_watermark(u, u->tsched_watermark_ref, &ss, false);
} else
pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->hwbuf_size, &ss));
goto fail;
if (u->ucm_context) {
- if (u->sink->active_port && pa_alsa_ucm_set_port(u->ucm_context, u->sink->active_port, TRUE) < 0)
+ if (u->sink->active_port && pa_alsa_ucm_set_port(u->ucm_context, u->sink->active_port, true) < 0)
goto fail;
} else if (setup_mixer(u, ignore_dB) < 0)
goto fail;