Use NSDMIs where applicable

This commit is contained in:
Thomas Goyne 2013-12-11 16:29:48 -08:00
parent d6a5d9c458
commit 6fad60e58d
114 changed files with 285 additions and 572 deletions

View file

@ -20,14 +20,9 @@ TODO:
*/
namespace json
{
namespace json {
Writer::Writer(std::ostream& ostr)
: m_ostr(ostr)
, tab_depth(0)
{
}
Writer::Writer(std::ostream& ostr) : m_ostr(ostr) { }
void Writer::Write(Array const& array) {
if (array.empty())

View file

@ -285,9 +285,7 @@ namespace {
namespace agi { namespace charset {
IconvWrapper::IconvWrapper(const char* sourceEncoding, const char* destEncoding, bool enableSubst)
: toNulLen(0)
, fromNulLen(0)
, conv(get_converter(enableSubst, sourceEncoding, destEncoding))
: conv(get_converter(enableSubst, sourceEncoding, destEncoding))
{
// These need to be set only after we verify that the source and dest
// charsets are valid

View file

@ -23,15 +23,11 @@
namespace agi {
Color::Color() : r(0), g(0), b(0), a(0) { }
Color::Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
: r(r), g(g), b(b), a(a)
{ }
Color::Color(std::string const& str)
: r(0), g(0), b(0), a(0)
{
Color::Color(std::string const& str) {
parser::parse(*this, str);
}

View file

@ -44,10 +44,7 @@ LogSink *log;
/// Keep this ordered the same as Severity
const char *Severity_ID = "EAWID";
LogSink::LogSink()
: messages(250)
, queue(dispatch::Create())
{ }
LogSink::LogSink() : queue(dispatch::Create()) { }
LogSink::~LogSink() {
// The destructor for emitters may try to log messages, so disable all the
@ -86,13 +83,8 @@ decltype(LogSink::messages) LogSink::GetMessages() const {
Message::Message(const char *section, Severity severity, const char *file, const char *func, int line)
: msg(buffer, sizeof buffer)
, sm{section, severity, file, func, line, util::time_log(), ""}
{
sm.section = section;
sm.severity = severity;
sm.file = file;
sm.func = func;
sm.line = line;
sm.tv = util::time_log();
}
Message::~Message() {

View file

@ -151,8 +151,6 @@ namespace vfr {
Framerate::Framerate(double fps)
: denominator(default_denominator)
, numerator(int64_t(fps * denominator))
, last(0)
, drop(false)
{
if (fps < 0.) throw BadFPS("FPS must be greater than zero");
if (fps > 1000.) throw BadFPS("FPS must not be greater than 1000");
@ -162,7 +160,6 @@ Framerate::Framerate(double fps)
Framerate::Framerate(int64_t numerator, int64_t denominator, bool drop)
: denominator(denominator)
, numerator(numerator)
, last(0)
, drop(drop && numerator % denominator != 0)
{
if (numerator <= 0 || denominator <= 0)
@ -181,14 +178,12 @@ void Framerate::SetFromTimecodes() {
Framerate::Framerate(std::vector<int> timecodes)
: timecodes(std::move(timecodes))
, drop(false)
{
SetFromTimecodes();
}
Framerate::Framerate(std::initializer_list<int> timecodes)
: timecodes(timecodes)
, drop(false)
{
SetFromTimecodes();
}
@ -203,8 +198,6 @@ void Framerate::swap(Framerate &right) throw() {
Framerate::Framerate(fs::path const& filename)
: denominator(default_denominator)
, numerator(0)
, drop(false)
{
auto file = agi::io::Open(filename);
auto encoding = agi::charset::Detect(filename);

View file

@ -35,7 +35,7 @@ class Writer : private ConstVisitor {
void Visit(const Null& null) override;
std::ostream& m_ostr;
int tab_depth;
int tab_depth = 0;
public:
template <typename ElementTypeT>
@ -51,5 +51,4 @@ inline std::ostream& operator <<(std::ostream& ostr, UnknownElement const& eleme
return ostr;
}
} // End namespace

View file

@ -46,8 +46,8 @@ struct Converter {
/// @brief A C++ wrapper for iconv
class IconvWrapper {
size_t toNulLen;
size_t fromNulLen;
size_t toNulLen = 0;
size_t fromNulLen = 0;
std::unique_ptr<Converter> conv;
public:

View file

@ -18,12 +18,12 @@
namespace agi {
struct Color {
unsigned char r; ///< Red component
unsigned char g; ///< Green component
unsigned char b; ///< Blue component
unsigned char a; ///< Alpha component
unsigned char r = 0; ///< Red component
unsigned char g = 0; ///< Green component
unsigned char b = 0; ///< Blue component
unsigned char a = 0; ///< Alpha component
Color();
Color() { }
Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0);
Color(std::string const& str);

View file

@ -83,7 +83,7 @@ class Emitter;
/// Log sink, single destination for all messages
class LogSink {
boost::circular_buffer<SinkMessage> messages;
boost::circular_buffer<SinkMessage> messages{250};
std::unique_ptr<dispatch::Queue> queue;
/// List of pointers to emitters

View file

@ -64,24 +64,24 @@ class Framerate {
/// Denominator of the FPS
///
/// For v1 VFR, the assumed FPS is used, for v2 the average FPS
int64_t denominator;
int64_t denominator = 0;
/// Numerator of the FPS
///
/// For v1 VFR, the assumed FPS is used, for v2 the average FPS
int64_t numerator;
int64_t numerator = 0;
/// Unrounded frame-seconds of the final frame in timecodes. For CFR and v2,
/// this is simply frame count * denominator, but for v1 it's the
/// "unrounded" frame count, since override ranges generally don't exactly
/// cover timebase-unit ranges of time. This is needed to match mkvmerge's
/// rounding past the end of the final override range.
int64_t last;
int64_t last = 0;
/// Start time in milliseconds of each frame
std::vector<int> timecodes;
/// Does this frame rate need drop frames and have them enabled?
bool drop;
bool drop = false;
/// Set FPS properties from the timecodes vector
void SetFromTimecodes();

View file

@ -55,11 +55,6 @@ static int next_id = 0;
AssDialogue::AssDialogue()
: Id(++next_id)
, Comment(false)
, Layer(0)
, Start(0)
, End(5000)
, Style("Default")
{
memset(Margin, 0, sizeof Margin);
}

View file

@ -136,17 +136,17 @@ public:
const int Id;
/// Is this a comment line?
bool Comment;
bool Comment = false;
/// Layer number
int Layer;
int Layer = 0;
/// Margins: 0 = Left, 1 = Right, 2 = Top (Vertical)
int Margin[3];
/// Starting time
AssTime Start;
AssTime Start = 0;
/// Ending time
AssTime End;
AssTime End = 5000;
/// Style name
boost::flyweight<std::string> Style;
boost::flyweight<std::string> Style{ "Default" };
/// Actor name
boost::flyweight<std::string> Actor;
/// Effect name

View file

@ -45,11 +45,7 @@
#include <memory>
#include <wx/sizer.h>
AssExporter::AssExporter(agi::Context *c)
: c(c)
, is_default(true)
{
}
AssExporter::AssExporter(agi::Context *c) : c(c) { }
void AssExporter::DrawSettings(wxWindow *parent, wxSizer *target_sizer) {
is_default = false;

View file

@ -58,7 +58,7 @@ class AssExporter {
/// Have the config windows been created, or should filters simply use
/// their default settings
bool is_default;
bool is_default = true;
public:
AssExporter(agi::Context *c);

View file

@ -50,9 +50,7 @@ std::string AssKaraoke::Syllable::GetText(bool k_tag) const {
}
AssKaraoke::AssKaraoke(AssDialogue *line, bool auto_split, bool normalize)
: no_announce(false)
{
AssKaraoke::AssKaraoke(AssDialogue *line, bool auto_split, bool normalize) {
if (line) SetLine(line, auto_split, normalize);
}

View file

@ -50,7 +50,7 @@ public:
private:
std::vector<Syllable> syls;
bool no_announce;
bool no_announce = false;
agi::signal::Signal<> AnnounceSyllablesChanged;
void ParseSyllables(AssDialogue *line, Syllable &syl);

View file

@ -54,7 +54,6 @@ using namespace boost::adaptors;
AssOverrideParameter::AssOverrideParameter(VariableDataType type, AssParameterClass classification)
: type(type)
, classification(classification)
, omitted(true)
{
}

View file

@ -77,7 +77,7 @@ public:
AssParameterClass classification;
/// Is this parameter actually present?
bool omitted;
bool omitted = true;
VariableDataType GetType() const { return type; }
template<class T> void Set(T param);

View file

@ -31,7 +31,6 @@
AssParser::AssParser(AssFile *target, int version)
: target(target)
, version(version)
, attach(nullptr)
, state(&AssParser::ParseScriptInfoLine)
{
std::fill(begin(insertion_positions), end(insertion_positions), nullptr);

View file

@ -49,26 +49,7 @@
#include <wx/intl.h>
AssStyle::AssStyle()
: name("Default")
, font("Arial")
, fontsize(20.)
, primary(255, 255, 255)
, secondary(255, 0, 0)
, bold(false)
, italic(false)
, underline(false)
, strikeout(false)
, scalex(100.)
, scaley(100.)
, spacing(0.)
, angle(0.)
, borderstyle(1)
, outline_w(2.)
, shadow_w(2.)
, alignment(2)
, encoding(1)
{
AssStyle::AssStyle() {
std::fill(Margin.begin(), Margin.end(), 10);
UpdateData();

View file

@ -43,30 +43,30 @@ class AssStyle : public AssEntry {
std::string data;
public:
std::string name; ///< Name of the style; must be case-insensitively unique within a file despite being case-sensitive
std::string font; ///< Font face name
double fontsize; ///< Font size
std::string name = "Default"; ///< Name of the style; must be case-insensitively unique within a file despite being case-sensitive
std::string font = "Arial"; ///< Font face name
double fontsize = 20.; ///< Font size
agi::Color primary; ///< Default text color
agi::Color secondary; ///< Text color for not-yet-reached karaoke syllables
agi::Color outline; ///< Outline color
agi::Color shadow; ///< Shadow color
agi::Color primary{ 255, 255, 255 }; ///< Default text color
agi::Color secondary{ 255, 0, 0 }; ///< Text color for not-yet-reached karaoke syllables
agi::Color outline{ 0, 0, 0 }; ///< Outline color
agi::Color shadow{ 0, 0, 0 }; ///< Shadow color
bool bold;
bool italic;
bool underline;
bool strikeout;
bool bold = false;
bool italic = false;
bool underline = false;
bool strikeout = false;
double scalex; ///< Font x scale with 100 = 100%
double scaley; ///< Font y scale with 100 = 100%
double spacing; ///< Additional spacing between characters in pixels
double angle; ///< Counterclockwise z rotation in degrees
int borderstyle; ///< 1: Normal; 3: Opaque box; others are unused in Aegisub
double outline_w; ///< Outline width in pixels
double shadow_w; ///< Shadow distance in pixels
int alignment; ///< \an-style line alignment
std::array<int, 3> Margin; ///< Left/Right/Vertical
int encoding; ///< ASS font encoding needed for some non-unicode fonts
double scalex = 100.; ///< Font x scale with 100 = 100%
double scaley = 100.; ///< Font y scale with 100 = 100%
double spacing = 0.; ///< Additional spacing between characters in pixels
double angle = 0.1; ///< Counterclockwise z rotation in degrees
int borderstyle = 1; ///< 1: Normal; 3: Opaque box; others are unused in Aegisub
double outline_w = 2.; ///< Outline width in pixels
double shadow_w = 2.; ///< Shadow distance in pixels
int alignment = 2; ///< \an-style line alignment
std::array<int, 3> Margin; ///< Left / Right / Vertical
int encoding = 1; ///< ASS font encoding needed for some non-unicode fonts
/// Update the raw line data after one or more of the public members have been changed
void UpdateData();

View file

@ -35,9 +35,7 @@
AssTime::AssTime(int time) : time(mid(0, time, 10 * 60 * 60 * 1000 - 1)) { }
AssTime::AssTime(std::string const& text)
: time(0)
{
AssTime::AssTime(std::string const& text) {
int after_decimal = -1;
int current = 0;
for (char c : text | boost::adaptors::filtered(boost::is_any_of(",.0123456789:"))) {

View file

@ -27,7 +27,7 @@
class AssTime {
/// Time in milliseconds
int time;
int time = 0;
public:
AssTime(int ms = 0);

View file

@ -83,7 +83,6 @@ AudioBox::AudioBox(wxWindow *parent, agi::Context *context)
, HorizontalZoom(new wxSlider(panel, Audio_Horizontal_Zoom, -OPT_GET("Audio/Zoom/Horizontal")->GetInt(), -50, 30, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH))
, VerticalZoom(new wxSlider(panel, Audio_Vertical_Zoom, OPT_GET("Audio/Zoom/Vertical")->GetInt(), 0, 100, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE))
, VolumeBar(new wxSlider(panel, Audio_Volume, OPT_GET("Audio/Volume")->GetInt(), 0, 100, wxDefaultPosition, wxSize(-1, 20), wxSL_VERTICAL|wxSL_BOTH|wxSL_INVERSE))
, mouse_zoom_accum(0)
{
SetSashVisible(wxSASH_BOTTOM, true);
Bind(wxEVT_SASH_DRAGGED, &AudioBox::OnSashDrag, this);

View file

@ -74,7 +74,7 @@ class AudioBox : public wxSashWindow {
wxSlider *VolumeBar;
// Mouse wheel zoom accumulator
int mouse_zoom_accum;
int mouse_zoom_accum = 0;
void SetHorizontalZoom(int new_zoom);
void OnAudioOpen();

View file

@ -559,14 +559,6 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C
, controller(controller)
, scrollbar(agi::util::make_unique<AudioDisplayScrollbar>(this))
, timeline(agi::util::make_unique<AudioDisplayTimeline>(this))
, dragged_object(nullptr)
, scroll_left(0)
, pixel_audio_width(0)
, ms_per_pixel(0.0)
, scale_amplitude(1.0f)
, audio_top(0)
, audio_height(0)
, track_cursor_pos(-1)
{
style_ranges[0] = AudioStyle_Normal;

View file

@ -124,7 +124,7 @@ class AudioDisplay: public wxWindow {
/// Current object on display being dragged, if any
AudioDisplayInteractionObject *dragged_object;
AudioDisplayInteractionObject *dragged_object = nullptr;
/// Change the dragged object and update mouse capture
void SetDraggedObject(AudioDisplayInteractionObject *new_obj);
@ -133,22 +133,22 @@ class AudioDisplay: public wxWindow {
wxTimer scroll_timer;
/// Leftmost pixel in the virtual audio image being displayed
int scroll_left;
int scroll_left = 0;
/// Total width of the audio in pixels
int pixel_audio_width;
int pixel_audio_width = 0;
/// Horizontal zoom measured in millisecond per pixels
double ms_per_pixel;
double ms_per_pixel = 0.;
/// Amplitude scaling ("vertical zoom") as a factor, 1.0 is neutral
float scale_amplitude;
float scale_amplitude = 1.f;
/// Top of the main audio area in pixels
int audio_top;
int audio_top = 0;
/// Height of main audio area in pixels
int audio_height;
int audio_height = 0;
/// Width of the audio marker feet in pixels
static const int foot_size = 6;
@ -157,7 +157,7 @@ class AudioDisplay: public wxWindow {
int zoom_level;
/// Absolute pixel position of the tracking cursor (mouse or playback)
int track_cursor_pos;
int track_cursor_pos = -1;
/// Label to show by track cursor
wxString track_cursor_label;
/// Bounding rectangle last drawn track cursor label

View file

@ -68,15 +68,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
, audio_opened(c->audioController->AddAudioOpenListener(&AudioKaraoke::OnAudioOpened, this))
, audio_closed(c->audioController->AddAudioCloseListener(&AudioKaraoke::OnAudioClosed, this))
, active_line_changed(c->selectionController->AddActiveLineListener(&AudioKaraoke::OnActiveLineChanged, this))
, active_line(nullptr)
, kara(agi::util::make_unique<AssKaraoke>())
, scroll_x(0)
, scroll_dir(0)
, char_height(0)
, char_width(0)
, mouse_pos(0)
, click_will_remove_split(false)
, enabled(false)
{
using std::bind;

View file

@ -76,7 +76,7 @@ class AudioKaraoke : public wxWindow {
agi::signal::Connection active_line_changed;
/// Currently active dialogue line
AssDialogue *active_line;
AssDialogue *active_line = nullptr;
/// Karaoke data
std::unique_ptr<AssKaraoke> kara;
@ -101,18 +101,18 @@ class AudioKaraoke : public wxWindow {
/// Cached width of characters from GetTextExtent
std::unordered_map<std::string, int> char_widths;
int scroll_x; ///< Distance the display has been shifted to the left in pixels
int scroll_dir; ///< Direction the display will be scrolled on scroll_timer ticks (+/- 1)
int scroll_x = 0; ///< Distance the display has been shifted to the left in pixels
int scroll_dir = 0; ///< Direction the display will be scrolled on scroll_timer ticks (+/- 1)
wxTimer scroll_timer; ///< Timer to scroll every 50ms when user holds down scroll button
int char_height; ///< Maximum character height in pixels
int char_width; ///< Maximum character width in pixels
int mouse_pos; ///< Last x coordinate of the mouse
bool click_will_remove_split; ///< If true a click at mouse_pos will remove a split rather than adding one
int char_height = 0; ///< Maximum character height in pixels
int char_width = 0; ///< Maximum character width in pixels
int mouse_pos = 0; ///< Last x coordinate of the mouse
bool click_will_remove_split = false; ///< If true a click at mouse_pos will remove a split rather than adding one
wxFont split_font; ///< Font used in the split/join interface
bool enabled; ///< Is karaoke mode enabled?
bool enabled = false; ///< Is karaoke mode enabled?
wxButton *accept_button; ///< Accept pending splits button
wxButton *cancel_button; ///< Revert pending changes

View file

@ -52,20 +52,8 @@ DEFINE_SIMPLE_EXCEPTION(OpenALException, agi::AudioPlayerOpenError, "audio/open/
OpenALPlayer::OpenALPlayer(AudioProvider *provider)
: AudioPlayer(provider)
, playing(false)
, volume(1.f)
, samplerate(provider->GetSampleRate())
, bpf(provider->GetChannels() * provider->GetBytesPerSample())
, start_frame(0)
, cur_frame(0)
, end_frame(0)
, device(nullptr)
, context(nullptr)
, source(0)
, buf_first_free(0)
, buf_first_queued(0)
, buffers_free(0)
, buffers_played(0)
{
try {
// Open device

View file

@ -55,32 +55,32 @@ class OpenALPlayer : public AudioPlayer, wxTimer {
/// Number of OpenAL buffers to use
static const ALsizei num_buffers = 8;
bool playing; ///< Is audio currently playing?
bool playing = false; ///< Is audio currently playing?
float volume; ///< Current audio volume
float volume = 1.f; ///< Current audio volume
ALsizei samplerate; ///< Sample rate of the audio
int bpf; ///< Bytes per frame
int64_t start_frame; ///< First frame of playbacka
int64_t cur_frame; ///< Next frame to write to playback buffers
int64_t end_frame; ///< Last frame to play
int64_t start_frame = 0; ///< First frame of playbacka
int64_t cur_frame = 0; ///< Next frame to write to playback buffers
int64_t end_frame = 0; ///< Last frame to play
ALCdevice *device; ///< OpenAL device handle
ALCcontext *context; ///< OpenAL sound context
ALCdevice *device = nullptr; ///< OpenAL device handle
ALCcontext *context = nullptr; ///< OpenAL sound context
ALuint buffers[num_buffers]; ///< OpenAL sound buffers
ALuint source; ///< OpenAL playback source
ALuint source = 0; ///< OpenAL playback source
/// Index into buffers, first free (unqueued) buffer to be filled
ALsizei buf_first_free;
ALsizei buf_first_free = 0;
/// Index into buffers, first queued (non-free) buffer
ALsizei buf_first_queued;
ALsizei buf_first_queued = 0;
/// Number of free buffers
ALsizei buffers_free;
ALsizei buffers_free = 0;
/// Number of buffers which have been fully played since playback was last started
ALsizei buffers_played;
ALsizei buffers_played = 0;
wxStopWatch playback_segment_timer;

View file

@ -50,15 +50,6 @@ DEFINE_SIMPLE_EXCEPTION(OSSError, agi::AudioPlayerOpenError, "audio/player/open/
OSSPlayer::OSSPlayer(AudioProvider *provider)
: AudioPlayer(provider)
, rate(0)
, thread(0)
, playing(false)
, volume(1.0f)
, start_frame(0)
, cur_frame(0)
, end_frame(0)
, bpf(0)
, dspdev(0)
{
OpenStream();
}

View file

@ -69,31 +69,31 @@ class OSSPlayer : public AudioPlayer {
friend class OSSPlayerThread;
/// sample rate of audio
unsigned int rate;
unsigned int rate = 0;
/// Worker thread that does the actual writing
OSSPlayerThread *thread;
OSSPlayerThread *thread = nullptr;
/// Is the player currently playing?
volatile bool playing;
volatile bool playing = false;
/// Current volume level
volatile float volume;
volatile float volume = 1.f;
/// first frame of playback
volatile unsigned long start_frame;
volatile unsigned long start_frame = 0;
/// last written frame + 1
volatile unsigned long cur_frame;
volatile unsigned long cur_frame = 0;
/// last frame to play
volatile unsigned long end_frame;
volatile unsigned long end_frame = 0;
/// bytes per frame
unsigned long bpf;
unsigned long bpf = 0;
/// OSS audio device handle
volatile int dspdev;
volatile int dspdev = 0;
void OpenStream();

View file

@ -69,12 +69,7 @@ static const PaHostApiTypeId pa_host_api_priority[] = {
};
static const size_t pa_host_api_priority_count = sizeof(pa_host_api_priority) / sizeof(pa_host_api_priority[0]);
PortAudioPlayer::PortAudioPlayer(AudioProvider *provider)
: AudioPlayer(provider)
, volume(1.0f)
, pa_start(0.0)
, stream(0)
{
PortAudioPlayer::PortAudioPlayer(AudioProvider *provider) : AudioPlayer(provider) {
PaError err = Pa_Initialize();
if (err != paNoError)
@ -131,7 +126,7 @@ PortAudioPlayer::~PortAudioPlayer() {
}
void PortAudioPlayer::OpenStream() {
DeviceVec *device_ids = 0;
DeviceVec *device_ids = nullptr;
std::string device_name = OPT_GET("Player/Audio/PortAudio/Device Name")->GetString();
if (devices.count(device_name)) {

View file

@ -57,13 +57,13 @@ class PortAudioPlayer : public AudioPlayer {
/// The index of the default output devices sorted by host API priority
DeviceVec default_device;
float volume; ///< Current volume level
int64_t current; ///< Current position
int64_t start; ///< Start position
int64_t end; ///< End position
PaTime pa_start; ///< PortAudio internal start position
float volume = 1.f; ///< Current volume level
int64_t current = 0; ///< Current position
int64_t start = 0; ///< Start position
int64_t end = 0; ///< End position
PaTime pa_start; ///< PortAudio internal start position
PaStream *stream; ///< PortAudio stream
PaStream *stream = nullptr; ///< PortAudio stream
/// @brief PortAudio callback, used to fill buffer for playback, and prime the playback buffer.
/// @param inputBuffer Input buffer.

View file

@ -48,20 +48,7 @@
#include <libaegisub/log.h>
PulseAudioPlayer::PulseAudioPlayer(AudioProvider *provider)
: AudioPlayer(provider)
, volume(1.0f)
, is_playing(false)
, start_frame(0)
, cur_frame(0)
, end_frame(0)
, bpf(0)
, context_notify(0, 1)
, context_success(0, 1)
, stream_notify(0, 1)
, stream_success(0, 1)
, paerror(0)
{
PulseAudioPlayer::PulseAudioPlayer(AudioProvider *provider) : AudioPlayer(provider) {
// Initialise a mainloop
mainloop = pa_threaded_mainloop_new();
if (!mainloop)

View file

@ -40,34 +40,34 @@
class PulseAudioPlayer;
class PulseAudioPlayer : public AudioPlayer {
float volume;
bool is_playing;
float volume = 1.f;
bool is_playing = false;
volatile unsigned long start_frame;
volatile unsigned long cur_frame;
volatile unsigned long end_frame;
volatile unsigned long start_frame = 0;
volatile unsigned long cur_frame = 0;
volatile unsigned long end_frame = 0;
unsigned long bpf; // bytes per frame
unsigned long bpf = 0; // bytes per frame
wxSemaphore context_notify;
wxSemaphore context_success;
wxSemaphore context_notify{0, 1};
wxSemaphore context_success{0, 1};
volatile int context_success_val;
wxSemaphore stream_notify;
wxSemaphore stream_success;
wxSemaphore stream_notify{0, 1};
wxSemaphore stream_success{0, 1};
volatile int stream_success_val;
pa_threaded_mainloop *mainloop; // pulseaudio mainloop handle
pa_context *context; // connection context
pa_threaded_mainloop *mainloop = nullptr; // pulseaudio mainloop handle
pa_context *context = nullptr; // connection context
volatile pa_context_state_t cstate;
pa_stream *stream;
pa_stream *stream = nullptr;
volatile pa_stream_state_t sstate;
volatile pa_usec_t play_start_time; // timestamp when playback was started
int paerror;
int paerror = 0;
/// Called by PA to notify about contetxt operation completion
static void pa_context_success(pa_context *c, int success, PulseAudioPlayer *thread);

View file

@ -110,12 +110,10 @@ void AudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const {
namespace {
struct provider_creator {
bool found_file;
bool found_audio;
bool found_file = false;
bool found_audio = false;
std::string msg;
provider_creator() : found_file(false) , found_audio(false) { }
template<typename Factory>
std::unique_ptr<AudioProvider> try_create(std::string const& name, Factory&& create) {
try {

View file

@ -52,11 +52,8 @@
#endif
PCMAudioProvider::PCMAudioProvider(agi::fs::path const& filename)
: current_mapping(nullptr)
, mapping_start(0)
, mapping_length(0)
#ifdef _WIN32
, file_handle(0, CloseHandle)
: file_handle(0, CloseHandle)
, file_mapping(0, CloseHandle)
{
file_handle = CreateFile(
@ -81,7 +78,7 @@ PCMAudioProvider::PCMAudioProvider(agi::fs::path const& filename)
if (file_mapping == 0)
throw agi::AudioProviderOpenError("Failed creating file mapping", 0);
#else
, file_handle(open(filename.c_str(), O_RDONLY), close)
: file_handle(open(filename.c_str(), O_RDONLY), close)
{
if (file_handle == -1)
throw agi::fs::FileNotFound(filename.string());

View file

@ -44,17 +44,17 @@
#include <libaegisub/scoped_ptr.h>
class PCMAudioProvider : public AudioProvider {
mutable void *current_mapping;
mutable void *current_mapping = nullptr;
#ifdef _WIN32
mutable int64_t mapping_start;
mutable size_t mapping_length;
mutable int64_t mapping_start = 0;
mutable size_t mapping_length = 0;
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_handle;
agi::scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> file_mapping;
#else
mutable off_t mapping_start;
mutable size_t mapping_length;
mutable off_t mapping_start = 0;
mutable size_t mapping_length = 0;
agi::scoped_holder<int, int(*)(int)> file_handle;
#endif
@ -65,7 +65,7 @@ protected:
char * EnsureRangeAccessible(int64_t range_start, int64_t range_length) const; // Ensure that the given range of bytes are accessible in the file mapping and return a pointer to the first byte of the requested range
/// Size of the opened file
int64_t file_size;
int64_t file_size = 0;
struct IndexPoint {
int64_t start_byte;

View file

@ -65,14 +65,6 @@ size_t AudioRendererBitmapCacheBitmapFactory::GetBlockSize() const
AudioRenderer::AudioRenderer()
: pixel_ms(0)
, pixel_height(0)
, amplitude_scale(0)
, cache_bitmap_width(32) // arbitrary value for now
, cache_bitmap_maxsize(0)
, cache_renderer_maxsize(0)
, renderer(nullptr)
, provider(nullptr)
{
for (int i = 0; i < AudioStyle_MAX; ++i)
bitmaps.emplace_back(256, AudioRendererBitmapCacheBitmapFactory(this));

View file

@ -89,31 +89,31 @@ class AudioRenderer {
friend struct AudioRendererBitmapCacheBitmapFactory;
/// Horizontal zoom level, milliseconds per pixel
double pixel_ms;
double pixel_ms = 0.f;
/// Rendering height in pixels
int pixel_height;
int pixel_height = 0;
/// Vertical zoom level/amplitude scale
float amplitude_scale;
float amplitude_scale = 0.f;
/// Width of bitmaps to store in cache
const int cache_bitmap_width;
const int cache_bitmap_width = 32; // Completely arbitrary value
/// Cached bitmaps for audio ranges
std::vector<AudioRendererBitmapCache> bitmaps;
/// Number of blocks in the bitmap caches
size_t cache_numblocks;
size_t cache_numblocks = 0;
/// The maximum allowed size of each bitmap cache, in bytes
size_t cache_bitmap_maxsize;
size_t cache_bitmap_maxsize = 0;
/// The maximum allowed size of the renderer's cache, in bytes
size_t cache_renderer_maxsize;
size_t cache_renderer_maxsize = 0;
/// Do the caches need to be aged?
bool needs_age;
bool needs_age = false;
/// Actual renderer for bitmaps
AudioRendererBitmapProvider *renderer;
AudioRendererBitmapProvider *renderer = nullptr;
/// Audio provider to use as source
AudioProvider *provider;
AudioProvider *provider = nullptr;
/// @brief Make sure bitmap index i is in cache
/// @param i Index of bitmap to get into cache

View file

@ -97,13 +97,6 @@ public:
AudioSpectrumRenderer::AudioSpectrumRenderer(std::string const& color_scheme_name)
: derivation_size(8)
, derivation_dist(8)
#ifdef WITH_FFTW3
, dft_plan(nullptr)
, dft_input(nullptr)
, dft_output(nullptr)
#endif
{
colors.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)

View file

@ -62,10 +62,10 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
std::vector<AudioColorScheme> colors;
/// Binary logarithm of number of samples to use in deriving frequency-power data
size_t derivation_size;
size_t derivation_size = 0;
/// Binary logarithm of number of samples between the start of derivations
size_t derivation_dist;
size_t derivation_dist = 0;
/// @brief Reset in response to changing audio provider
///
@ -92,11 +92,11 @@ class AudioSpectrumRenderer : public AudioRendererBitmapProvider {
#ifdef WITH_FFTW3
/// FFTW plan data
fftw_plan dft_plan;
fftw_plan dft_plan = nullptr;
/// Pre-allocated input array for FFTW
double *dft_input;
double *dft_input = nullptr;
/// Pre-allocated output array for FFTW
fftw_complex *dft_output;
fftw_complex *dft_output = nullptr;
#else
/// Pre-allocated scratch area for doing FFT derivations
std::vector<float> fft_scratch;

View file

@ -55,8 +55,7 @@ enum {
};
AudioWaveformRenderer::AudioWaveformRenderer(std::string const& color_scheme_name)
: audio_buffer(nullptr)
, render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg)
: render_averages(OPT_GET("Audio/Display/Waveform Style")->GetInt() == Waveform_MaxAvg)
{
colors.reserve(AudioStyle_MAX);
for (int i = 0; i < AudioStyle_MAX; ++i)

View file

@ -45,7 +45,7 @@ class AudioWaveformRenderer : public AudioRendererBitmapProvider {
std::vector<AudioColorScheme> colors;
/// Pre-allocated buffer for audio fetched from provider
char *audio_buffer;
char *audio_buffer = nullptr;
/// Whether to render max+avg or just max
bool render_averages;

View file

@ -89,7 +89,7 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
AssDialogue *active_line; ///< Currently active line
AssKaraoke *kara; ///< Parsed karaoke model provided by karaoke controller
size_t cur_syl; ///< Index of currently selected syllable in the line
size_t cur_syl = 0; ///< Index of currently selected syllable in the line
/// Pen used for the mid-syllable markers
Pen separator_pen;
@ -114,8 +114,8 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
/// Labels containing the stripped text of each syllable
std::vector<AudioLabel> labels;
bool auto_commit; ///< Should changes be automatically commited?
int commit_id; ///< Last commit id used for an autocommit
bool auto_commit; ///< Should changes be automatically commited?
int commit_id = -1; ///< Last commit id used for an autocommit
bool pending_changes; ///< Are there any pending changes to be committed?
void OnAutoCommitChange(agi::OptionValue const& opt);
@ -160,7 +160,6 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
, c(c)
, active_line(c->selectionController->GetActiveLine())
, kara(kara)
, cur_syl(0)
, separator_pen("Colour/Audio Display/Syllable Boundaries", "Audio/Line Boundaries Thickness", wxPENSTYLE_DOT)
, start_pen("Colour/Audio Display/Line boundary Start", "Audio/Line Boundaries Thickness")
, end_pen("Colour/Audio Display/Line boundary End", "Audio/Line Boundaries Thickness")
@ -169,7 +168,6 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
, keyframes_provider(c, "Audio/Display/Draw/Keyframes in Karaoke Mode")
, video_position_provider(c)
, auto_commit(OPT_GET("Audio/Auto/Commit")->GetBool())
, commit_id(-1)
{
slots.push_back(kara->AddSyllablesChangedListener(&AudioTimingControllerKaraoke::Revert, this));
slots.push_back(OPT_SUB("Audio/Auto/Commit", &AudioTimingControllerKaraoke::OnAutoCommitChange, this));

View file

@ -100,16 +100,8 @@ namespace std {
BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, long style, const wxString& name)
: wxWindow(parent, -1, wxDefaultPosition, size, style, name)
, lineHeight(1) // non-zero to avoid div by 0
, holding(false)
, scrollBar(new wxScrollBar(this, GRID_SCROLLBAR, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL))
, byFrame(false)
, extendRow(-1)
, active_line(nullptr)
, batch_level(0)
, batch_active_line_changed(false)
, seek_listener(context->videoController->AddSeekListener(std::bind(&BaseGrid::Refresh, this, false, nullptr)))
, yPos(0)
, context(context)
{
scrollBar->SetScrollbar(0,10,100,10);

View file

@ -50,27 +50,27 @@ namespace agi {
class AssDialogue;
class BaseGrid : public wxWindow, public SubtitleSelectionController {
int lineHeight; ///< Height of a line in pixels in the current font
bool holding; ///< Is a drag selection in process?
int lineHeight = 1; ///< Height of a line in pixels in the current font
bool holding = false; ///< Is a drag selection in process?
wxFont font; ///< Current grid font
wxScrollBar *scrollBar; ///< The grid's scrollbar
bool byFrame; ///< Should times be displayed as frame numbers
bool byFrame = false; ///< Should times be displayed as frame numbers
wxBrush rowColors[7]; ///< Cached brushes used for row backgrounds
/// Row from which the selection shrinks/grows from when selecting via the
/// keyboard, shift-clicking or dragging
int extendRow;
int extendRow = -1;
Selection selection; ///< Currently selected lines
AssDialogue *active_line; ///< The currently active line or 0 if none
Selection selection; ///< Currently selected lines
AssDialogue *active_line = nullptr; ///< The currently active line or 0 if none
std::vector<AssDialogue*> index_line_map; ///< Row number -> dialogue line
std::map<AssDialogue*,int> line_index_map; ///< Dialogue line -> row number
/// Selection batch nesting depth; changes are commited only when this
/// hits zero
int batch_level;
int batch_level = 0;
/// Has the active line been changed in the current batch?
bool batch_active_line_changed;
bool batch_active_line_changed = false;
/// Lines which will be added to the selection when the current batch is
/// completed; should be disjoint from selection
Selection batch_selection_added;
@ -112,7 +112,7 @@ class BaseGrid : public wxWindow, public SubtitleSelectionController {
bool showCol[10]; ///< Column visibility mask
int yPos;
int yPos = 0;
void AdjustScrollbar();
void SetColumnWidths();