From b24c6ad25c7ed0a08b13b8ee0648b5c6976eda18 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 3 Aug 2013 14:13:06 -0400 Subject: favor static_cast over c-style casts --- ponymix.cc | 2 +- pulse.cc | 34 +++++++++++++++------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/ponymix.cc b/ponymix.cc index 1e5afae..18ddd21 100644 --- a/ponymix.cc +++ b/ponymix.cc @@ -332,7 +332,7 @@ static int adj_volume(PulseClient& ponymix, // Allow setting the volume over 100, but don't "clip" the level back down to // 100 on adjustment. - ponymix.SetVolumeRange(0, std::max(device->Volume(), (int)opt_maxvolume)); + ponymix.SetVolumeRange(0, std::max(device->Volume(), static_cast(opt_maxvolume))); return !(ponymix.*adjust)(*device, delta); } diff --git a/pulse.cc b/pulse.cc index 87415c9..809083b 100644 --- a/pulse.cc +++ b/pulse.cc @@ -17,12 +17,12 @@ namespace { static void connect_state_cb(pa_context* context, void* raw) { - enum pa_context_state *state = (enum pa_context_state*)raw; + enum pa_context_state *state = static_cast(raw); *state = pa_context_get_state(context); } static void success_cb(pa_context* context, int success, void* raw) { - int *r = (int*)raw; + int *r = static_cast(raw); *r = success; if (!success) { fprintf(stderr, @@ -42,7 +42,7 @@ static void card_info_cb(pa_context* context, } if (!eol) { - vector* cards = (vector*)raw; + vector* cards = static_cast*>(raw); cards->push_back(info); } } @@ -59,7 +59,7 @@ static void device_info_cb(pa_context* context, } if (!eol) { - vector* devices_ = (vector*)raw; + vector* devices_ = static_cast*>(raw); devices_->push_back(info); } } @@ -67,14 +67,14 @@ static void device_info_cb(pa_context* context, static void server_info_cb(pa_context* context __attribute__((unused)), const pa_server_info* i, void* raw) { - ServerInfo* defaults = (ServerInfo*)raw; + ServerInfo* defaults = static_cast(raw); defaults->sink = i->default_sink_name; defaults->source = i->default_source_name; } static pa_cvolume* value_to_cvol(long value, pa_cvolume *cvol) { return pa_cvolume_set(cvol, cvol->channels, - fmax((double)(value + .5) * PA_VOLUME_NORM / 100, 0)); + fmax(static_cast(value + .5) * PA_VOLUME_NORM / 100, 0)); } static int volume_as_percent(const pa_cvolume* cvol) { @@ -288,7 +288,7 @@ void PulseClient::populate_cards() { cards_.clear(); pa_operation* op = pa_context_get_card_info_list(context_, card_info_cb, - (void*)&cards_); + static_cast(&cards_)); mainloop_iterate(op); pa_operation_unref(op); } @@ -303,32 +303,28 @@ void PulseClient::populate_server_info() { void PulseClient::populate_sinks() { sinks_.clear(); - pa_operation* op = pa_context_get_sink_info_list(context_, - device_info_cb, - (void*)&sinks_); + pa_operation* op = pa_context_get_sink_info_list( + context_, device_info_cb, static_cast(&sinks_)); mainloop_iterate(op); pa_operation_unref(op); sink_inputs_.clear(); - op = pa_context_get_sink_input_info_list(context_, - device_info_cb, - (void*)&sink_inputs_); + op = pa_context_get_sink_input_info_list( + context_, device_info_cb, static_cast(&sink_inputs_)); mainloop_iterate(op); pa_operation_unref(op); } void PulseClient::populate_sources() { sources_.clear(); - pa_operation* op = pa_context_get_source_info_list(context_, - device_info_cb, - (void*)&sources_); + pa_operation* op = pa_context_get_source_info_list( + context_, device_info_cb, static_cast(&sources_)); mainloop_iterate(op); pa_operation_unref(op); source_outputs_.clear(); - op = pa_context_get_source_output_info_list(context_, - device_info_cb, - (void*)&source_outputs_); + op = pa_context_get_source_output_info_list( + context_, device_info_cb, static_cast(&source_outputs_)); mainloop_iterate(op); pa_operation_unref(op); } -- cgit v1.2.3