* Remove all instances of wxLogDebug and replace them with LOG_W, LOG_D, LOG_E and LOG_D_IF as required.

* Add LOG_(D|W|I)_IF for conditional logging.

Originally committed to SVN as r4465.
This commit is contained in:
Amar Takhar 2010-06-08 23:21:39 +00:00
parent 653ce8b13d
commit 931cc7f461
21 changed files with 203 additions and 149 deletions

View File

@ -44,6 +44,9 @@
#define LOG_I(section) LOG_SINK(section, agi::log::Info)
#define LOG_D(section) LOG_SINK(section, agi::log::Debug)
#define LOG_W_IF(cond, section) if (cond) LOG_SINK(section, agi::log::Warning)
#define LOG_I_IF(cond, section) if (cond) LOG_SINK(section, agi::log::Info)
#define LOG_D_IF(cond, section) if (cond) LOG_SINK(section, agi::log::Debug)
namespace agi {
namespace log {

View File

@ -41,6 +41,8 @@
#include <wx/tokenzr.h>
#endif
#include <libaegisub/log.h>
#include "ass_dialogue.h"
#include "ass_override.h"
@ -620,7 +622,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
work = text.SubString(start, i-1);
work.Trim(true).Trim(false);
paramList.Add(work);
//wxLogDebug(_T("Got parameter: %s"), work.c_str());
//LOG_D("subtitle/ass/override" << "Got parameter: << work.c_str();
}
if (i+1 < textlen) {

View File

@ -48,6 +48,8 @@
#include <wx/laywin.h> // Keep this last so wxSW_3D is set.
#endif
#include <libaegisub/log.h>
#include "audio_box.h"
#include "audio_display.h"
#include "audio_karaoke.h"
@ -261,7 +263,7 @@ AudioBox::~AudioBox() {
/// @return
///
void AudioBox::SetFile(wxString file,bool FromVideo) {
wxLogDebug(_T("AudioBox::SetFile(file=%s, FromVideo=%d)"), file.c_str(), FromVideo?1:0);
LOG_D("audio/box") << "file=" << file << " FromVideo: " << FromVideo;
loaded = false;
if (FromVideo) {
@ -276,9 +278,9 @@ void AudioBox::SetFile(wxString file,bool FromVideo) {
audioName = file;
}
wxLogDebug(_T("AudioBox::SetFile: setting up accelerators in frameMain"));
LOG_D("audio/box") << "setting up acceleraters in frameMain";
frameMain->SetAccelerators();
wxLogDebug(_T("AudioBox::SetFile: returning"));
LOG_D("audio/box") << "finished setting up accelerators in frameMain";
}
@ -564,11 +566,11 @@ void AudioBox::OnPlayToEnd(wxCommandEvent &event) {
/// @return
///
void AudioBox::OnCommit(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnCommit"));
LOG_D("audio/box") << "OnCommit";
audioDisplay->SetFocus();
wxLogDebug(_T("AudioBox::OnCommit: has set focus, now committing changes"));
LOG_D("audio/box") << "has set focus, now committing changes";
audioDisplay->CommitChanges(true);
wxLogDebug(_T("AudioBox::OnCommit: returning"));
LOG_D("audio/box") << "returning";
}
@ -578,10 +580,10 @@ void AudioBox::OnCommit(wxCommandEvent &event) {
/// @return
///
void AudioBox::OnKaraoke(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnKaraoke"));
LOG_D("audio/box") << "OnKaraoke";
audioDisplay->SetFocus();
if (karaokeMode) {
wxLogDebug(_T("AudioBox::OnKaraoke: karaoke enabled, disabling"));
LOG_D("audio/box") << "karaoke enabled, disabling";
if (audioKaraoke->splitting) {
audioKaraoke->EndSplit(false);
}
@ -592,7 +594,7 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
}
else {
wxLogDebug(_T("AudioBox::OnKaraoke: karaoke disabled, enabling"));
LOG_D("audio/box") << "karaoke disabled, enabling";
karaokeMode = true;
audioKaraoke->enabled = true;
audioDisplay->SetDialogue();
@ -600,7 +602,7 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
SetKaraokeButtons();
wxLogDebug(_T("AudioBox::OnKaraoke: returning"));
LOG_D("audio/box") << "returning";
}
@ -634,7 +636,7 @@ void AudioBox::SetKaraokeButtons() {
/// @param event wxEvent
///
void AudioBox::OnJoin(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnJoin"));
LOG_D("audio/box") << "join";
audioDisplay->SetFocus();
audioKaraoke->Join();
}
@ -643,7 +645,7 @@ void AudioBox::OnJoin(wxCommandEvent &event) {
/// @param event wxEvent
///
void AudioBox::OnSplit(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnSplit"));
LOG_D("audio/box") << "split";
audioDisplay->SetFocus();
audioKaraoke->BeginSplit();
}
@ -652,7 +654,7 @@ void AudioBox::OnSplit(wxCommandEvent &event) {
/// @param event wxEvent
///
void AudioBox::OnCancel(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnCancel"));
LOG_D("audio/box") << "cancel";
audioDisplay->SetFocus();
audioKaraoke->EndSplit(true);
}
@ -661,7 +663,7 @@ void AudioBox::OnCancel(wxCommandEvent &event) {
/// @param event wxEvent
///
void AudioBox::OnAccept(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnAccept"));
LOG_D("audio/box") << "accept";
audioDisplay->SetFocus();
audioKaraoke->EndSplit(false);
}

View File

@ -86,7 +86,7 @@ AudioKaraokeSyllable::AudioKaraokeSyllable(const AssKaraokeSyllable &base)
AudioKaraoke::AudioKaraoke(wxWindow *parent)
: wxWindow (parent,-1,wxDefaultPosition,wxSize(10,5),wxTAB_TRAVERSAL|wxBORDER_SUNKEN)
{
LOG_D("karaoke") << "Constructor";
LOG_D("karaoke/audio") << "Constructor";
enabled = false;
splitting = false;
split_cursor_syl = -1;
@ -110,10 +110,10 @@ AudioKaraoke::~AudioKaraoke() {
/// @return
///
bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue(diag=%p)"), _diag);
LOG_D("karaoke/audio") << "diag=" << _diag;
// Make sure we're not in splitting-mode
if (splitting) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: is splitting, discarding splits"));
LOG_D("karaoke/audio") << "is splitting, discarding splits";
// Discard any splits and leave split-mode
EndSplit(false);
}
@ -122,13 +122,13 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
delete workDiag;
diag = _diag;
if (!diag) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: no diag, refreshing and returning false"));
LOG_D("karaoke/audio") << "no diag, refreshing and returning flase";
Refresh(false);
return false;
}
// Split
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: split"));
LOG_D("karaoke/audio") << "split";
workDiag = new AssDialogue(diag->GetEntryData(), false);
workDiag->ParseASSTags();
must_rebuild = false;
@ -136,7 +136,7 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
// No karaoke, autosplit
if (!hasKar) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: no existing karaoke, auto-splitting"));
LOG_D("karaoke/audio") << "no existing karaoke, auto-splitting";
AutoSplit();
}
@ -145,7 +145,7 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
//if (curSyllable >= (signed) syllables.size()) curSyllable = 0;
//SetSelection(curSyllable);
//Refresh(false);
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: returning %d"), hasKar?0:1);
LOG_D("karaoke/audio") << "returning " << hasKar;
return !hasKar;
}
@ -155,17 +155,17 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
/// @return
///
void AudioKaraoke::Commit() {
wxLogDebug(_T("AudioKaraoke::Commit"));
LOG_D("karaoke/audio") << "commit";
if (splitting) {
wxLogDebug(_T("AudioKaraoke::Commit: splitting, ending split"));
LOG_D("karaoke/audio") << "splitting, ending split";
EndSplit(true);
}
wxString finalText = _T("");
AudioKaraokeSyllable *syl;
size_t n = syllables.size();
wxLogDebug(_T("AudioKaraoke::Commit: syllables.size() = %u"), n);
LOG_D("karaoke/audio") << "syllabels.size() = " << n;
if (must_rebuild) {
wxLogDebug(_T("AudioKaraoke::Commit: must_rebuild"));
LOG_D("karaoke/audio") << "must_rebuild";
workDiag->ClearBlocks();
for (size_t i=0;i<n;i++) {
syl = &syllables.at(i);
@ -175,11 +175,11 @@ void AudioKaraoke::Commit() {
workDiag->ParseASSTags();
diag->Text = finalText;
} else {
wxLogDebug(_T("AudioKaraoke::Commit: Updating karaoke without rebuild"));
LOG_D("karaoke/audio") << "updating karaoke without rebuild";
for (size_t i = 0; i < n; i++) {
wxLogDebug(_T("AudioKaraoke::Commit: Updating syllable %d"), i);
LOG_D("karaoke/audio") << "updating syllabel: " << i;
syl = &syllables.at(i);
wxLogDebug(_T("AudioKaraoke::Commit: Syllable pointer: %p; tagdata pointer: %p; length: %d"), syl, syl->tag, syl->duration);
LOG_D("karaoke/audio") << "syllabel pointer: " << syl << "; tagdata pointer: " << syl->tag << "; length: " << syl->duration;
// Some weird people have text before the first karaoke tag on a line.
// Check that a karaoke tag actually exists for the (non-)syllable to avoid a crash.
if (syl->tag && syl->tag->Params.size()>0)
@ -187,13 +187,13 @@ void AudioKaraoke::Commit() {
// Of course, if the user changed the duration of such a non-syllable, its timing can't be updated and will stay zero.
// There is no way to check for that right now, and I can't bother to fix it.
}
wxLogDebug(_T("AudioKaraoke::Commit: Done updating syllables"));
LOG_D("karaoke/audio") << "done updating syllabels";
workDiag->UpdateText();
workDiag->ClearBlocks();
workDiag->ParseASSTags();
diag->Text = workDiag->Text;
}
wxLogDebug(_T("AudioKaraoke::Commit: returning"));
LOG_D("karaoke/audio") << "returning";
}
@ -202,7 +202,7 @@ void AudioKaraoke::Commit() {
/// @return
///
void AudioKaraoke::AutoSplit() {
wxLogDebug(_T("AudioKaraoke::AutoSplit"));
LOG_D("karaoke/audio") << "autosplit";
// Get lengths
int timeLen = (diag->End.GetMS() - diag->Start.GetMS())/10;
@ -250,7 +250,7 @@ void AudioKaraoke::AutoSplit() {
newDiag.ParseASSTags();
ParseDialogue(&newDiag);
wxLogDebug(_T("AudioKaraoke::AutoSplit: returning"));
LOG_D("karaoke/audio") << "returning";
}
@ -294,14 +294,14 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
/// @return
///
void AudioKaraoke::SetSyllable(int n) {
wxLogDebug(_T("AudioKaraoke::SetSyllable(n=%d)"), n);
LOG_D("karaoke/audio") << "n=" << n;
if (n == -1) n = syllables.size()-1;
if (n >= (signed) syllables.size()) n = 0;
curSyllable = n;
startClickSyl = n;
SetSelection(n);
Refresh(false);
wxLogDebug(_T("AudioKaraoke::SetSyllable: returning"));
LOG_D("karaoke/audio") << "returning";
}
@ -512,15 +512,15 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) {
int lastx = 0;
split_cursor_syl = syli;
for (unsigned int i = 0; i < widths.size(); i++) {
//wxLogDebug(_T("rx=%d, lastx=%d, widths[i]=%d, i=%d, widths.size()=%d, syli=%d"), rx, lastx, widths[i], i, widths.size(), syli);
//wx Log Debug(_T("rx=%d, lastx=%d, widths[i]=%d, i=%d, widths.size()=%d, syli=%d"), rx, lastx, widths[i], i, widths.size(), syli);
if (lastx - rx < widths[i] - rx) {
if (rx - lastx < widths[i] - rx) {
//wxLogDebug(_T("Found at PREV!"));
//wx Log Debug(_T("Found at PREV!"));
split_cursor_x = lastx;
split_cursor_char = i - 1;
break;
} else if (rx < widths[i]) {
//wxLogDebug(_T("Found at CURRENT!"));
//wx Log Debug(_T("Found at CURRENT!"));
split_cursor_x = widths[i];
split_cursor_char = i;
break;
@ -531,7 +531,7 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) {
// If no split-point was caught by the for-loop, it must be over the last character,
// ie. split at next-to-last position
if (split_cursor_x < 0) {
//wxLogDebug(_T("Emergency picking LAST!"));
//wx Log Debug(_T("Emergency picking LAST!"));
split_cursor_x = widths[widths.size()-1];
split_cursor_char = widths.size() - 1;
}
@ -539,12 +539,12 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) {
// Do something if there was a click and we're at a valid position
if (event.LeftDown() && split_cursor_char >= -1) {
//wxLogDebug(_T("A click!"));
//wx Log Debug(_T("A click!"));
int num_removed = 0;
std::vector<int>::iterator i = syl.pending_splits.begin();
while (i != syl.pending_splits.end()) {
if (split_cursor_char == *i) {
//wxLogDebug(_T("Erasing entry"));
//wx Log Debug(_T("Erasing entry"));
num_removed++;
syl.pending_splits.erase(i);
break;
@ -597,7 +597,7 @@ int AudioKaraoke::GetSylAtX(int x) {
/// @param end
///
void AudioKaraoke::SetSelection(int start,int end) {
wxLogDebug(_T("AudioKaraoke::SetSelection(start=%d, end=%d)"), start, end);
LOG_D("karaoke/audio") << "start=" << start << " end=" << end;
// Default end
if (end == -1) end = start;
@ -609,7 +609,7 @@ void AudioKaraoke::SetSelection(int start,int end) {
max = min;
min = temp;
}
wxLogDebug(_T("AudioKaraoke::SetSelection: min=%d, max=%d"), min, max);
LOG_D("karaoke/audio") << "min=" << min << ", max=" << max;
// Set values
bool state;
@ -622,7 +622,7 @@ void AudioKaraoke::SetSelection(int start,int end) {
}
curSyllable = min;
selectionCount = max-min+1;
wxLogDebug(_T("AudioKaraoke::SetSelection: new curSyllable=%d, selectionCount=%d"), curSyllable, selectionCount);
LOG_D("karaoke/audio") << "new curSyllabel=" << curSyllable << ", selectionCount=" << selectionCount;
// Set box buttons
box->SetKaraokeButtons();
@ -634,7 +634,7 @@ void AudioKaraoke::SetSelection(int start,int end) {
/// @return
///
void AudioKaraoke::Join() {
wxLogDebug(_T("AudioKaraoke::Join"));
LOG_D("karaoke/audio") << "join";
// Variables
bool gotOne = false;
size_t syls = syllables.size();
@ -644,7 +644,7 @@ void AudioKaraoke::Join() {
// Loop
for (size_t i=0;i<syls;i++) {
curSyl = &syllables.at(i);
wxLogDebug(_T("AudioKaraoke::Join: syllable %d, text='%s', unstripped_text='%s', duration=%d"), i, curSyl->text.c_str(), curSyl->unstripped_text.c_str(), curSyl->duration);
LOG_D("karaoke/audio") << "syllabel " << i << ", text='" << curSyl->text.c_str() << "', unstripped_text='" << curSyl->unstripped_text.c_str() << "', duration=" << curSyl->duration;
if (curSyl->selected) {
if (!gotOne) {
gotOne = true;
@ -652,7 +652,7 @@ void AudioKaraoke::Join() {
}
else {
AudioKaraokeSyllable &work = syllables.at(first);
wxLogDebug(_T("AudioKaraoke::Join: worksyl %d, text='%s', unstripped_text='%s', duration=%d"), i, work.text.c_str(), work.unstripped_text.c_str(), work.duration);
LOG_D("karaoke/audio") << "worksyl " << work.text.c_str() << ", text='" << work.text.c_str() << ", unstripped_text='" << work.unstripped_text.c_str() << "', duration=" << work.duration;
work.duration += curSyl->duration;
work.text += curSyl->text;
work.unstripped_text += curSyl->unstripped_text;
@ -672,7 +672,7 @@ void AudioKaraoke::Join() {
display->Update();
Refresh(false);
wxLogDebug(_T("AudioKaraoke::Join: returning"));
LOG_D("karaoke/audio") << "returning";
}
@ -680,7 +680,7 @@ void AudioKaraoke::Join() {
/// @brief Enter splitting-mode
///
void AudioKaraoke::BeginSplit() {
wxLogDebug(_T("AudioKaraoke::BeginSplit"));
LOG_D("karaoke/audio") << "beginsplit";
splitting = true;
split_cursor_syl = -1;
split_cursor_x = -1;
@ -695,7 +695,7 @@ void AudioKaraoke::BeginSplit() {
/// @return
///
void AudioKaraoke::EndSplit(bool commit) {
wxLogDebug(_T("AudioKaraoke::EndSplit(commit=%d)"), commit?1:0);
LOG_D("karaoke/audio") << "endsplit, commit=" << commit;
splitting = false;
bool hasSplit = false;
size_t first_sel = ~0U;
@ -714,7 +714,7 @@ void AudioKaraoke::EndSplit(bool commit) {
// Update
if (hasSplit) {
wxLogDebug(_T("AudioKaraoke::EndSplit: hasSplit"));
LOG_D("karaoke/audio") << "hassplit";
must_rebuild = true;
display->NeedCommit = true;
SetSelection(first_sel);
@ -724,7 +724,7 @@ void AudioKaraoke::EndSplit(bool commit) {
box->SetKaraokeButtons();
Refresh(false);
wxLogDebug(_T("AudioKaraoke::EndSplit: returning"));
LOG_D("karaoke/audio") << "returning";
}
@ -734,14 +734,14 @@ void AudioKaraoke::EndSplit(bool commit) {
/// @return
///
int AudioKaraoke::SplitSyl (unsigned int n) {
wxLogDebug(_T("AudioKaraoke::SplitSyl(n=%u)"), n);
LOG_D("karaoke/audio") << "splitsyl, n=" << n;
// Avoid multiple vector resizes (this must be first)
syllables.reserve(syllables.size() + syllables[n].pending_splits.size());
// The syllable we're splitting
AudioKaraokeSyllable &basesyl = syllables[n];
wxLogDebug(_T("AudioKaraoke::SplitSyl: basesyl. contents='%s' selected=%d"), basesyl.unstripped_text.c_str(), basesyl.selected?1:0);
LOG_D("karaoke/audio") << "basesyl, contents='" << basesyl.unstripped_text.c_str() << "', selected=" << basesyl.selected;
// Start by sorting the split points
std::sort(basesyl.pending_splits.begin(), basesyl.pending_splits.end());
@ -771,7 +771,7 @@ int AudioKaraoke::SplitSyl (unsigned int n) {
newsyl.start_time = curpos;
newsyl.type = basesyl.type;
newsyl.selected = false;//basesyl.selected;
wxLogDebug(_T("AudioKaraoke::SplitSyl: newsyl. contents='%s' selected=%d"), newsyl.text.c_str(), newsyl.selected?1:0);
LOG_D("karaoke/audio") << "splitsyl: newsyl, contents='" << newsyl.text.c_str() << "', selected=" << newsyl.selected;
curpos += newsyl.duration;
syllables.insert(syllables.begin()+n+i+1, newsyl);
}
@ -808,7 +808,7 @@ int AudioKaraoke::SplitSyl (unsigned int n) {
/// @return
///
bool AudioKaraoke::SyllableDelta(int n,int delta,int mode) {
wxLogDebug(_T("AudioKaraoke::SyllableDelta(n=%d, delta=%d, mode=%d)"), n, delta, mode);
LOG_D("karaoke/audio") << "n=" << n << ", delta=" << delta << ", mode=" << mode;
// Get syllable and next
AudioKaraokeSyllable *curSyl=NULL,*nextSyl=NULL;
curSyl = &syllables.at(n);
@ -825,33 +825,33 @@ bool AudioKaraoke::SyllableDelta(int n,int delta,int mode) {
if (len + delta < minLen) delta = minLen-len;
if (mode == 0 && nextSyl && (nextSyl->duration - delta) < minLen) delta = nextSyl->duration - minLen;
wxLogDebug(_T("AudioKaraoke::SyllableDelta: nkar=%d, len=%d, minLen=%d, delta=%d"), nkar, len, minLen, delta);
LOG_D("karaoke/audio") << "nkar=" << nkar << ", len=" << len << ", minLen=" << minLen << ", delta=" << delta;
// Apply
if (delta != 0) {
wxLogDebug(_T("AudioKaraoke::SyllableDelta: delta != 0"));
LOG_D("karaoke/audio") << "delta != 0";
curSyl->duration += delta;
// Normal mode
if (mode == 0 && nextSyl) {
wxLogDebug(_T("AudioKaraoke::SyllableDelta: normal mode"));
LOG_D("karaoke/audio") << "normal mode";
nextSyl->duration -= delta;
nextSyl->start_time += delta;
}
// Shift mode
if (mode == 1) {
wxLogDebug(_T("AudioKaraoke::SyllableDelta: shift mode"));
LOG_D("karaoke/audio") << "shift mode";
for (int i=n+1;i<nkar;i++) {
syllables.at(i).start_time += delta;
}
}
// Flag update
wxLogDebug(_T("AudioKaraoke::SyllableDelta: return true"));
LOG_D("karaoke/audio") << "return true";
return true;
}
wxLogDebug(_T("AudioKaraoke::SyllableDelta: return false"));
LOG_D("karaoke/audio") << "return false";
return false;
}

View File

@ -37,11 +37,14 @@
#include "config.h"
#ifdef WITH_ALSA
///////////
// Headers
#include <libaegisub/log.h>
#include "audio_player_alsa.h"
#include "audio_player_manager.h"
#include "audio_provider_manager.h"
@ -151,12 +154,11 @@ void AlsaPlayer::SetUpHardware()
if (snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &real_rate, 0) < 0) {
throw _T("ALSA player: Could not set sample rate");
}
if (rate != real_rate) {
wxLogDebug(_T("ALSA player: Could not set ideal sample rate %d, using %d instead"), rate, real_rate);
}
LOG_D_IF(rate != real_rate, "player/audio/alsa") << "ALSA player: Could not set ideal sample rate " << rate << "using " << real_rate << "instead";
// Set number of channels
if (snd_pcm_hw_params_set_channels(pcm_handle, hwparams, provider->GetChannels()) < 0) {
LOG_E("player/audio/alsa") << "Could not set number of channels";
throw _T("ALSA player: Could not set number of channels");
}
printf("ALSA player: Set sample rate %u (wanted %u)\n", real_rate, rate);
@ -165,12 +167,13 @@ void AlsaPlayer::SetUpHardware()
unsigned int wanted_buflen = 1000000; // microseconds
buflen = wanted_buflen;
if (snd_pcm_hw_params_set_buffer_time_near(pcm_handle, hwparams, &buflen, &dir) < 0) {
LOG_E("player/audio/alsa") << "Couldn't set buffer length";
throw _T("ALSA player: Couldn't set buffer length");
}
if (buflen != wanted_buflen) {
wxLogDebug(_T("ALSA player: Couldn't get wanted buffer size of %u, got %u instead"), wanted_buflen, buflen);
}
LOG_D_IF(buflen != wanted_buflen, "player/audio/alsa") << "Couldn't get wanted buffer size of " << wanted_buflen << ", got " << buflen << "instead";
if (snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize) < 0) {
LOG_E("player/audio/alsa") << "Couldn't get buffer size";
throw _T("ALSA player: Couldn't get buffer size");
}
printf("ALSA player: Buffer size: %lu\n", bufsize);
@ -182,16 +185,17 @@ void AlsaPlayer::SetUpHardware()
if (snd_pcm_hw_params_set_period_time_near(pcm_handle, hwparams, &period_len, &dir) < 0) {
throw _T("ALSA player: Couldn't set period length");
}
if (period_len != wanted_period) {
wxLogDebug(_T("ALSA player: Couldn't get wanted period size of %d, got %d instead"), wanted_period, period_len);
}
LOG_D_IF(period_len != wanted_period, "player/audio/alsa") << Couldn't get wanted period size of " << wanted_period" << ", got " << period_len << " instead";
if (snd_pcm_hw_params_get_period_size(hwparams, &period, &dir) < 0) {
LOG_E("player/audio/alsa") << "Couldn't get period size";
throw _T("ALSA player: Couldn't get period size");
}
printf("ALSA player: Period size: %lu\n", period);
// Apply parameters
if (snd_pcm_hw_params(pcm_handle, hwparams) < 0) {
LOG_E("player/audio/alsa") << "Failed applying sound hardware settings";
throw _T("ALSA player: Failed applying sound hardware settings");
}
@ -211,21 +215,25 @@ void AlsaPlayer::SetUpAsync()
// Get current parameters
if (snd_pcm_sw_params_current(pcm_handle, sw_params) < 0) {
LOG_E("player/audio/alsa") << "Couldn't get current SW params";
throw _T("ALSA player: Couldn't get current SW params");
}
// How full the buffer must be before playback begins
if (snd_pcm_sw_params_set_start_threshold(pcm_handle, sw_params, bufsize - period) < 0) {
LOG_E("player/audio/alsa") << "Failed setting start threshold";
throw _T("ALSA player: Failed setting start threshold");
}
// The the largest write guaranteed never to block
if (snd_pcm_sw_params_set_avail_min(pcm_handle, sw_params, period) < 0) {
LOG_E("player/audio/alsa") << "Failed setting min available buffer";
throw _T("ALSA player: Failed setting min available buffer");
}
// Apply settings
if (snd_pcm_sw_params(pcm_handle, sw_params) < 0) {
LOG_E("player/audio/alsa") << "Failed applying SW params";
throw _T("ALSA player: Failed applying SW params");
}
@ -237,6 +245,7 @@ void AlsaPlayer::SetUpAsync()
// Attach async handler
if (snd_async_add_pcm_handler(&pcm_callback, pcm_handle, async_write_handler, this) < 0) {
LOG_E("player/audio/alsa") << "Failed attaching async handler";
throw _T("ALSA player: Failed attaching async handler");
}
}

View File

@ -41,6 +41,7 @@
#ifdef WITH_DIRECTSOUND
#include <libaegisub/log.h>
#include "audio_player_dsound.h"
#include "frame_main.h"
@ -206,7 +207,7 @@ RetryLock:
// Buffer lost?
if (res == DSERR_BUFFERLOST) {
wxLogDebug(_T("Lost DSound buffer"));
LOG_D("audio/player/dsound1") << "lost dsound buffer";
buffer->Restore();
goto RetryLock;
}
@ -218,9 +219,9 @@ RetryLock:
unsigned long int count1 = size1 / bytesps;
unsigned long int count2 = size2 / bytesps;
if (count1) wxLogDebug(_T("DS fill: %05lu -> %05lu"), (unsigned long)playPos, (unsigned long)playPos+count1);
if (count2) wxLogDebug(_T("DS fill: %05lu => %05lu"), (unsigned long)playPos+count1, (unsigned long)playPos+count1+count2);
if (!count1 && !count2) wxLogDebug(_T("DS fill: nothing"));
LOG_D_IF(count1, "audio/player/dsound1") << "DS fill: " << (unsigned long)playPos << " -> " << (unsigned long)playPos+count1;
LOG_D_IF(count2, "audio/player/dsound1") << "DS fill: " << (unsigned long)playPos+count1 << " -> " << (unsigned long)playPos+count1+count2;
LOG_D_IF(!count1 && !count2, "audio/player/dsound1") << "DS fill: nothing";
// Get source wave
if (count1) provider->GetAudioWithVolume(ptr1, playPos, count1, volume);
@ -378,7 +379,7 @@ wxThread::ExitCode DirectSoundPlayerThread::Entry() {
while (WaitForSingleObject(stopnotify, 50) == WAIT_TIMEOUT) {
if (!parent->FillBuffer(false)) {
// FillBuffer returns false when end of stream is reached
wxLogDebug(_T("DS thread hit end of stream"));
LOG_D("audio/player/dsound1") << "DS thread hit end of stream";
break;
}
}
@ -398,8 +399,8 @@ wxThread::ExitCode DirectSoundPlayerThread::Entry() {
if (FAILED(res)) break;
if (size1) memset(buf1, 0, size1);
if (size2) memset(buf2, 0, size2);
if (size1) wxLogDebug(_T("DS blnk: %05ld -> %05ld"), (unsigned long)parent->playPos+bytesFilled, (unsigned long)parent->playPos+bytesFilled+size1);
if (size2) wxLogDebug(_T("DS blnk: %05ld => %05ld"), (unsigned long)parent->playPos+bytesFilled+size1, (unsigned long)parent->playPos+bytesFilled+size1+size2);
LOG_D_IF(size1, "audio/player/dsound1") << "DS blnk:" << (unsigned long)parent->playPos+bytesFilled << " -> " << (unsigned long)parent->playPos+bytesFilled+size1;
LOG_D_IF(size2, "audio/player/dsound1") << "DS blnk:" << (unsigned long)parent->playPos+bytesFilled+size1 << " -> " << (unsigned long)parent->playPos+bytesFilled+size1+size2;
bytesFilled += size1 + size2;
parent->buffer->Unlock(buf1, size1, buf2, size2);
if (bytesFilled > parent->bufSize) break;
@ -408,7 +409,7 @@ wxThread::ExitCode DirectSoundPlayerThread::Entry() {
WaitForSingleObject(stopnotify, 150);
wxLogDebug(_T("DS thread dead"));
LOG_D("audio/player/dsound1") << "DS thread dead";
parent->playing = false;
parent->buffer->Stop();

View File

@ -47,6 +47,8 @@
#include <process.h>
#include <dsound.h>
#include <libaegisub/log.h>
#include "audio_player_dsound2.h"
#include "frame_main.h"
#include "include/aegisub/audio_provider.h"
@ -311,7 +313,7 @@ void DirectSoundPlayer2Thread::Run()
bfr7->Release();
bfr7 = 0;
//wxLogDebug(_T("DirectSoundPlayer2: Created buffer of %d bytes, supposed to be %d milliseconds or %d frames"), bufSize, WANTED_LATENCY*BUFFER_LENGTH, bufSize/provider->GetBytesPerSample());
//wx Log Debug(_T("DirectSoundPlayer2: Created buffer of %d bytes, supposed to be %d milliseconds or %d frames"), bufSize, WANTED_LATENCY*BUFFER_LENGTH, bufSize/provider->GetBytesPerSample());
// Now we're ready to roll!
@ -501,7 +503,7 @@ do_fill_buffer:
SUCCEEDED(bfr->Lock(0, bufSize, &buf1, &buf1sz, &buf2, &buf2sz, 0)) &&
SUCCEEDED(bfr->Play(0, 0, DSBPLAY_LOOPING)))
{
wxLogDebug(_T("DirectSoundPlayer2: Lost and restored buffer"));
LOG_D("audio/player/dsound") << "Lost and restored buffer";
break;
}
REPORT_ERROR("Lost buffer and could not restore it.")
@ -914,6 +916,7 @@ void DirectSoundPlayer2::OpenStream()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
thread = 0;
}
@ -932,6 +935,7 @@ void DirectSoundPlayer2::CloseStream()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
thread = 0;
@ -957,6 +961,7 @@ void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -977,6 +982,7 @@ void DirectSoundPlayer2::Play(int64_t start,int64_t count)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -998,6 +1004,7 @@ void DirectSoundPlayer2::Stop(bool timerToo)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -1015,6 +1022,7 @@ bool DirectSoundPlayer2::IsPlaying()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
return false;
}
@ -1035,6 +1043,7 @@ int64_t DirectSoundPlayer2::GetStartPosition()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
return 0;
}
@ -1055,6 +1064,7 @@ int64_t DirectSoundPlayer2::GetEndPosition()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
return 0;
}
@ -1075,6 +1085,7 @@ int64_t DirectSoundPlayer2::GetCurrentPosition()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
return 0;
}
@ -1092,6 +1103,7 @@ void DirectSoundPlayer2::SetEndPosition(int64_t pos)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -1110,6 +1122,7 @@ void DirectSoundPlayer2::SetCurrentPosition(int64_t pos)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -1126,6 +1139,7 @@ void DirectSoundPlayer2::SetVolume(double vol)
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
}
}
@ -1143,6 +1157,7 @@ double DirectSoundPlayer2::GetVolume()
}
catch (const wxChar *msg)
{
LOG_E("audio/player/dsound") << msg;
wxLogError(msg);
return 0;
}

View File

@ -42,6 +42,8 @@
///////////
// Headers
#include <libaegisub/log.h>
#include "audio_player_manager.h"
#include "audio_player_openal.h"
#include "audio_provider_manager.h"
@ -236,7 +238,7 @@ void OpenALPlayer::Stop(bool timerToo)
///
void OpenALPlayer::FillBuffers(ALsizei count)
{
wxLogDebug(_T("FillBuffers: count=%d, buffers_free=%d"), count, buffers_free);
LOG_D("player/audio/openal") << "count=" << count << " " << "buffers_free=" << buffers_free;
if (count > buffers_free) count = buffers_free;
if (count < 1) count = 1;
@ -249,7 +251,7 @@ void OpenALPlayer::FillBuffers(ALsizei count)
ALsizei fill_len = buffer_length;
if (fill_len > (ALsizei)(end_frame - cur_frame)) fill_len = (ALsizei)(end_frame - cur_frame);
if (fill_len < 0) fill_len = 0;
wxLogDebug(_T("buffer_length=%d, fill_len=%d, end_frame-cur_frame=%d"), buffer_length, fill_len, end_frame-cur_frame);
LOG_D("player/audio/openal") << "buffer_length=" << buffer_length << " fill_len=" << fill_len << " end_frame-cur-frame=" << end_frame-cur_frame;
if (fill_len > 0)
// Get fill_len frames of audio
@ -280,7 +282,7 @@ void OpenALPlayer::Notify()
ALsizei newplayed;
alGetSourcei(source, AL_BUFFERS_PROCESSED, &newplayed);
wxLogDebug(_T("OpenAL Player notify: buffers_played=%d, newplayed=%d, playeddiff=%d"), buffers_played, newplayed);
LOG_D("player/audio/openal") << "buffers_played=" << buffers_played << " newplayed=" << newplayed;
if (newplayed > 0) {
// Reclaim buffers
@ -302,7 +304,7 @@ void OpenALPlayer::Notify()
FillBuffers(newplayed);
}
wxLogDebug(_T("frames played=%d, num frames=%d"), (buffers_played - num_buffers) * buffer_length, end_frame - start_frame);
LOG_D("player/audio/openal") << "frames played=" << (buffers_played - num_buffers) * buffer_length << " num frames=" << end_frame - start_frame;
// Check that all of the selected audio plus one full set of buffers has been queued
if ((buffers_played - num_buffers) * buffer_length > (ALsizei)(end_frame - start_frame)) {
// Then stop

View File

@ -39,6 +39,8 @@
///////////
// Headers
#include <libaegisub/log.h>
#include "audio_player_manager.h"
#include "audio_player_oss.h"
#include "audio_provider_manager.h"
@ -279,8 +281,7 @@ int64_t OSSPlayer::GetCurrentPosition()
#else
played_frames = pos.samples + pos.fifo_samples;
#endif
wxLogDebug("OSS player: played_frames %d fifo %d", played_frames,
pos.fifo_samples);
LOG_D("player/audio/oss") << "played_frames: " << played_frames << " fifo " << pos.fifo_samples;
if (start_frame + played_frames >= end_frame) {
if (displayTimer)
displayTimer->Stop();
@ -293,7 +294,8 @@ int64_t OSSPlayer::GetCurrentPosition()
int delay = 0;
if (ioctl(dspdev, SNDCTL_DSP_GETODELAY, &delay) >= 0) {
delay /= bpf;
wxLogDebug("OSS player: cur_frame %d delay %d", cur_frame, delay);
LOG_D("player/audio/oss") << "cur_frame: " << cur_frame << " delay " << delay;
// delay can jitter a bit at the end, detect that
if (cur_frame == end_frame && delay < rate / 20) {
if (displayTimer)
@ -337,7 +339,7 @@ wxThread::ExitCode OSSPlayerThread::Entry() {
free(buf);
parent->cur_frame = parent->end_frame;
wxLogDebug(_T("OSS player thread dead"));
LOG_D("player/audio/oss") << "Thread dead";
return 0;
}

View File

@ -41,6 +41,8 @@
// Headers
#include <libaegisub/log.h>
#include "audio_player_portaudio.h"
#include "audio_provider_manager.h"
#include "charset_conv.h"
@ -90,10 +92,10 @@ void PortAudioPlayer::OpenStream() {
if (pa_config_default < 0) {
pa_device = Pa_GetDefaultOutputDevice();
wxLogDebug(_T("PortAudioPlayer::OpenStream Using Default Output Device: %d"), pa_device);
LOG_D("audio/player/portaudio") << "using default output device:" << pa_device;
} else {
pa_device = pa_config_default;
wxLogDebug(_T("PortAudioPlayer::OpenStream Using Config Device: %d"), pa_device);
LOG_D("audio/player/portaudio") << "using config device: " << pa_device;
}
pa_output_p.device = pa_device;
@ -102,17 +104,15 @@ void PortAudioPlayer::OpenStream() {
pa_output_p.suggestedLatency = Pa_GetDeviceInfo(pa_device)->defaultLowOutputLatency;
pa_output_p.hostApiSpecificStreamInfo = NULL;
wxLogDebug(_T("PortAudioPlayer::OpenStream Output channels: %d, Latency: %f Sample Rate: %ld\n"),
pa_output_p.channelCount, pa_output_p.suggestedLatency, pa_output_p.sampleFormat);
LOG_D("audio/player/portaudio") << "output channels: " << pa_output_p.channelCount << ", latency: " << pa_output_p.suggestedLatency << " sample rate: " << pa_output_p.sampleFormat;
PaError err = Pa_OpenStream(&stream, NULL, &pa_output_p, provider->GetSampleRate(), 256, paPrimeOutputBuffersUsingStreamCallback, paCallback, this);
if (err != paNoError) {
const PaHostErrorInfo *pa_err = Pa_GetLastHostErrorInfo();
if (pa_err->errorCode != 0) {
wxLogDebug(_T("PortAudioPlayer::OpenStream HostError: API: %d, %s (%ld)\n"), pa_err->hostApiType, pa_err->errorText, pa_err->errorCode);
}
LOG_D_IF(pa_err->errorCode != 0, "audio/player/portaudio") << "HostError: API: " << pa_err->hostApiType << ", " << pa_err->errorText << ", " << pa_err->errorCode;
LOG_D("audio/player/portaudio") << "Failed initializing PortAudio stream with error: " << Pa_GetErrorText(err);
throw wxString(_T("Failed initializing PortAudio stream with error: ") + wxString(Pa_GetErrorText(err),csConvLocal));
}
}
@ -133,8 +133,7 @@ void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
if (player->displayTimer) {
player->displayTimer->Stop();
}
wxLogDebug(_T("PortAudioPlayer::paStreamFinishedCallback Stopping stream."));
LOG_D("audio/player/portaudio") << "stopping stream";
}
@ -155,14 +154,14 @@ void PortAudioPlayer::Play(int64_t start,int64_t count) {
err = Pa_SetStreamFinishedCallback(stream, paStreamFinishedCallback);
if (err != paNoError) {
wxLogDebug(_T("PortAudioPlayer::Play Could not set FinishedCallback.\n"));
LOG_D("audio/player/portaudio") << "could not set FinishedCallback";
return;
}
err = Pa_StartStream(stream);
if (err != paNoError) {
wxLogDebug(_T("PortAudioPlayer::Play Error playing stream.\n"));
LOG_D("audio/player/portaudio") << "error playing stream";
return;
}
}

View File

@ -51,6 +51,8 @@
#include <wx/log.h>
#endif
#include <libaegisub/log.h>
#include "aegisub_endian.h"
#include "audio_provider_pcm.h"
#include "utils.h"
@ -681,8 +683,8 @@ AudioProvider *CreatePCMAudioProvider(const wxString &filename)
return provider;
}
catch (const wxChar *msg) {
LOG_E("audio/provider/pcm") << "Creating PCM WAV reader failed with message: '" << msg << "' Trying other providers";
provider = 0;
wxLogDebug(_T("Creating PCM WAV reader failed with message: %s\nProceeding to try other providers."), msg);
}
// Try Sony Wave64
@ -691,8 +693,8 @@ AudioProvider *CreatePCMAudioProvider(const wxString &filename)
return provider;
}
catch (const wxChar *msg) {
LOG_E("audio/provider/pcm") << "Creating Wave64 reader failed with message: '" << msg << "' Trying other providers";
provider = 0;
wxLogDebug(_T("Creating Wave64 reader failed with message: %s\nProceeding to try other providers."), msg);
}
// no providers could be created

View File

@ -39,6 +39,8 @@
#ifdef WITH_QUICKTIME
#include <libaegisub/log.h>
#include "audio_provider_quicktime.h"
@ -194,9 +196,7 @@ void QuickTimeAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
qt_status = MovieAudioExtractionFillBuffer(extract_ref, &decode_count, &dst_buflist, &flags);
QTCheckError(qt_status, wxString(_T("QuickTime audio provider: Failed to decode audio")));
if (count != decode_count)
wxLogDebug(_T("QuickTime audio provider: GetAudio: Warning: decoded samplecount %d not same as requested count %d"),
decode_count, (uint32_t)count);
LOG_W_IF(count != decode_count, "audio/provider/quicktime") << "decoded samplecount " << decode_count << "not same as requested count" << (uint32_t)count);
}

View File

@ -51,6 +51,8 @@
#include <wx/log.h>
#endif
#include <libaegisub/log.h>
#include "audio_renderer_spectrum.h"
#include "colorspace.h"
#include "fft.h"
@ -507,7 +509,7 @@ public:
/// until the total number of lines stored in the tree is less than the maximum.
void Age()
{
wxLogDebug(_T("AudioSpectrumCacheManager stats: hits=%u, misses=%u, misses%%=%f, managed lines=%u (max=%u)"), cache_hits, cache_misses, cache_misses/float(cache_hits+cache_misses)*100, cache_root->GetManagedLineCount(), max_lines_cached);
LOG_D("audio/renderer/spectrum/cache") << "stats: hits=" << cache_hits << " misses=" << cache_misses << " misses%=" << cache_misses/float(cache_hits+cache_misses)*100 << " managed lines=" << cache_root->GetManagedLineCount() << "(max=" << max_lines_cached << ")";
// 0 means no limit
if (max_lines_cached == 0)
@ -531,7 +533,7 @@ public:
// Find the point where we have too many lines cached
while (cumulative_lines < max_lines_cached) {
if (it == ages.rend()) {
wxLogDebug(_T("AudioSpectrumCacheManager done aging did not exceed max_lines_cached"));
LOG_D("audio/renderer/spectrum/") << "done aging did not exeed max_lines_cached";
return;
}
cumulative_lines += it->num_lines;
@ -546,7 +548,7 @@ public:
cache_root->KillLine(it->first_line);
}
wxLogDebug(_T("AudioSpectrumCacheManager done aging, managed lines now=%u (max=%u)"), cache_root->GetManagedLineCount(), max_lines_cached);
LOG_D("audio/renderer/spectrum/") << "done aging, managed lines now=" << cache_root->GetManagedLineCount() << " (max=" << max_lines_cached << ")";
assert(cache_root->GetManagedLineCount() < max_lines_cached);
}

View File

@ -51,6 +51,8 @@
#include <wx/window.h>
#endif
#include <libaegisub/log.h>
#include "ass_dialogue.h"
#include "ass_file.h"
#include "ass_override.h"
@ -89,7 +91,7 @@ namespace Automation4 {
{
int top = lua_gettop(L);
if (top - additional != startstack) {
wxLogDebug(_T("Lua stack size mismatch."));
LOG_D("automation/lua") << "lua stack size mismatch.";
dump();
assert(top - additional == startstack);
}
@ -97,18 +99,18 @@ namespace Automation4 {
void dump()
{
int top = lua_gettop(L);
wxLogDebug(_T("Dumping Lua stack..."));
LOG_D("automation/lua/stackdump") << "--- dumping lua stack...";
for (int i = top; i > 0; i--) {
lua_pushvalue(L, i);
wxString type(lua_typename(L, lua_type(L, -1)), wxConvUTF8);
if (lua_isstring(L, i)) {
wxLogDebug(type + _T(": ") + wxString(lua_tostring(L, -1), wxConvUTF8));
LOG_D("automation/lua/stackdump") << type << ": " << luatostring(L, -1);
} else {
wxLogDebug(type);
LOG_D("automation/lua/stackdump") << type;
}
lua_pop(L, 1);
}
wxLogDebug(_T("--- end dump"));
LOG_D("automation/lua") << "--- end dump";
}
LuaStackcheck(lua_State *_L) : L(_L) { startstack = lua_gettop(L); }
~LuaStackcheck() { check_stack(0); }

View File

@ -46,6 +46,8 @@
#include <wx/log.h>
#endif
#include <libaegisub/log.h>
#include "ass_dialogue.h"
#include "ass_file.h"
#include "ass_override.h"
@ -822,7 +824,7 @@ namespace Automation4 {
{
LuaAssFile *laf = GetObjPointer(L, 1);
delete laf;
wxLogDebug(_T(">>gc<< Garbage collected LuaAssFile"));
LOG_D("automation/lua") << "Garbage collected LuaAssFile";
return 0;
}

View File

@ -54,6 +54,8 @@
#include <wx/window.h>
#endif
#include <libaegisub/log.h>
#include "ass_style.h"
#include "auto4_lua.h"
#include "colour_button.h"
@ -136,7 +138,7 @@ namespace Automation4 {
}
lua_pop(L, 1);
wxLogDebug(_T("created control: '%s', (%d,%d)(%d,%d), '%s'"), name.c_str(), x, y, width, height, hint.c_str());
LOG_D("automation/lua/dialog") << "created control: '" << name.c_str() << "', (" << x << "," << y << ")(" << width << "," << height << ", "<< hint.c_str();
}
@ -889,7 +891,7 @@ nospin:
LuaConfigDialog::LuaConfigDialog(lua_State *L, bool include_buttons)
: use_buttons(include_buttons)
{
wxLogDebug(_T("creating LuaConfigDialog, this addr is %p"), this);
LOG_D("automation/lua/dialog") << "creating LuaConfigDialoug, addr: " << this;
button_pushed = 0;
if (include_buttons) {
@ -1003,13 +1005,14 @@ badcontrol:
if (use_buttons) {
wxStdDialogButtonSizer *bs = new wxStdDialogButtonSizer();
if (buttons.size() > 0) {
wxLogDebug(_T("creating user buttons"));
LOG_D("automation/lua/dialog") << "creating user buttons";
for (size_t i = 0; i < buttons.size(); ++i) {
wxLogDebug(_T("button '%s' gets id %d"), buttons[i].c_str(), 1001+(wxWindowID)i);
LOG_D("automation/lua/dialog") << "button '" << buttons[i].c_str() << "' gets id " << 1001+(wxWindowID)i;
bs->Add(new wxButton(w, 1001+(wxWindowID)i, buttons[i]));
}
} else {
wxLogDebug(_T("creating default buttons"));
LOG_D("automation/lua/dialog") << "creating default buttons";
bs->Add(new wxButton(w, wxID_OK));
bs->Add(new wxButton(w, wxID_CANCEL));
}
@ -1019,7 +1022,7 @@ badcontrol:
button_event->button_pushed = &button_pushed;
// passing button_event as userdata because wx will then delete it
w->Connect(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(LuaConfigDialog::ButtonEventHandler::OnButtonPush), button_event, button_event);
wxLogDebug(_T("set event handler, this addr is %p"), this);
LOG_D("automation/lua/dialog") << "set event handler, addr: " << this;
wxBoxSizer *ms = new wxBoxSizer(wxVERTICAL);
ms->Add(s, 0, wxBOTTOM, 5);
@ -1041,17 +1044,17 @@ badcontrol:
{
// First read back which button was pressed, if any
if (use_buttons) {
wxLogDebug(_T("reading back button_pushed"));
LOG_D("automation/lua/dialog") << "reading back button_pushed";
int btn = button_pushed;
if (btn == 0) {
wxLogDebug(_T("was zero, cancelled"));
LOG_D("automation/lua/dialog") << "was zero, cancelled";
// Always cancel/closed
lua_pushboolean(L, 0);
} else if (buttons.size() == 0 && btn == 1) {
wxLogDebug(_T("default buttons, button 1 pushed, Ok button"));
LOG_D("automation/lua/dialog") << "default buttons, button 1 bushed, Ok button";
lua_pushboolean(L, 1);
} else {
wxLogDebug(_T("user button: %s"), buttons.at(btn-1).c_str());
LOG_D("automation/lua/dialog") << "user button: " << buttons.at(btn-1).c_str();
// button_pushed is index+1 to reserve 0 for Cancel
lua_pushstring(L, buttons.at(btn-1).mb_str(wxConvUTF8));
}
@ -1140,13 +1143,13 @@ badcontrol:
// Let button_pushed == 0 mean "cancelled", such that pushing Cancel or closing the dialog
// will both result in button_pushed == 0
if (evt.GetId() == wxID_OK) {
wxLogDebug(_T("was wxID_OK"));
LOG_D("automation/lua/dialog") << "was wxID_OK";
*button_pushed = 1;
} else if (evt.GetId() == wxID_CANCEL) {
wxLogDebug(_T("was wxID_CANCEL"));
LOG_D("automation/lua/dialog") << "was wxID_CANCEL";
*button_pushed = 0;
} else {
wxLogDebug(_T("was user button"));
LOG_D("automation/lua/dialog") << "was user button";
// Therefore, when buttons are numbered from 1001 to 1000+n, make sure to set it to i+1
*button_pushed = evt.GetId() - 1000;
@ -1156,7 +1159,7 @@ badcontrol:
if (button) return;
evt.SetId(wxID_OK);
}
wxLogDebug(_T("button_pushed set to %d"), *button_pushed);
LOG_D("automation/lua/dialog") << "button_pushed set to: " << *button_pushed;
evt.Skip();
}

View File

@ -46,6 +46,8 @@
#include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
#endif
#include <libaegisub/log.h>
#include "compat.h"
#include "ffmpegsource_common.h"
#include "frame_main.h"
@ -260,24 +262,24 @@ wxString FFmpegSourceProvider::GetCacheFilename(const wxString& _filename)
/// @brief Starts the cache cleaner thread
/// @return True on success, false if the thread could not be started.
bool FFmpegSourceProvider::CleanCache() {
wxLogDebug(_T("FFmpegSourceCacheCleaner: attempting to start thread"));
LOG_D("provider/ffmpegsource/cache") << "attempting to start thread";
FFmpegSourceCacheCleaner *CleaningThread = new FFmpegSourceCacheCleaner(this);
if (CleaningThread->Create() != wxTHREAD_NO_ERROR) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: thread creation failed"));
LOG_D("provider/ffmpegsource/cache") << "thread creation failed";
delete CleaningThread;
CleaningThread = NULL;
return false;
}
if (CleaningThread->Run() != wxTHREAD_NO_ERROR) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: failed to start thread"));
LOG_D("provider/ffmpegsource/cache") << "failed to start thread";
delete CleaningThread;
CleaningThread = NULL;
return false;
}
wxLogDebug(_T("FFmpegSourceCacheCleaner: thread started successfully"));
LOG_D("provider/ffmpegsource/cache") << "thread started successfully";
return true;
}
@ -295,14 +297,14 @@ FFmpegSourceCacheCleaner::FFmpegSourceCacheCleaner(FFmpegSourceProvider *par) :
wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
wxMutexLocker lock(FFmpegSourceProvider::CleaningInProgress);
if (!lock.IsOk()) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: cleaning already in progress, thread exiting"));
LOG_D("provider/ffmpegsource/cache") << "cleaning already in progress, thread exiting";
return (wxThread::ExitCode)1;
}
wxString cachedirname = StandardPaths::DecodePath(_T("?user/ffms2cache/"));
wxDir cachedir;
if (!cachedir.Open(cachedirname)) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: couldn't open cache directory %s"), cachedirname.c_str());
LOG_D("provider/ffmpegsource/cache") << "couldn't open cache directory " << cachedirname.c_str();
return (wxThread::ExitCode)1;
}
@ -316,7 +318,7 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
int maxfiles = OPT_GET("Provider/FFmpegSource/Cache/Files")->GetInt();
if (!cachedir.HasFiles(_T("*.ffindex"))) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: no index files in cache folder, exiting"));
LOG_D("provider/ffmpegsource/cache") << "no index files in cache folder, exiting";
return (wxThread::ExitCode)0;
}
@ -330,7 +332,7 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
// unusually paranoid sanity check
// (someone might have deleted the file(s) after we did HasFiles() above; does wxDir.Open() lock the dir?)
if (!cachedir.GetFirst(&curfn_str, _T("*.ffindex"), wxDIR_FILES)) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: insanity/race condition/index dir fuckery detected, exiting"));
LOG_D("provider/ffmpegsource/cache") << "undefined error";
return (wxThread::ExitCode)1;
}
@ -350,8 +352,7 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
}
if (numfiles <= maxfiles && cursize <= maxsize) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: cache does not need cleaning (maxsize=%d, cursize=%d; maxfiles=%d, numfiles=%d), exiting"),
(int)maxsize, (int)cursize, maxfiles, numfiles);
LOG_D("provider/ffmpegsource/cache") << "cache does not need cleaning (maxsize=" << (int)maxsize << ", cursize=" << (int)cursize << "; maxfiles=" << maxfiles << "numfiles=" << numfiles << ",exiting";
return (wxThread::ExitCode)0;
}
@ -359,10 +360,10 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
// stop cleaning?
if ((cursize <= maxsize && numfiles <= maxfiles) || numfiles <= 1)
break;
int64_t fsize = i->second.GetSize().GetValue();
if (!wxRemoveFile(i->second.GetFullPath())) {
wxLogDebug(_T("FFmpegSourceCacheCleaner: failed to remove file %s"),i->second.GetFullPath().c_str());
LOG_D("provider/ffmpegsource/cache") << "failed to remove file " << i->second.GetFullPath().c_str();
continue;
}
cursize -= fsize;
@ -372,8 +373,7 @@ wxThread::ExitCode FFmpegSourceCacheCleaner::Entry() {
wxThread::This()->Sleep(250);
}
wxLogDebug(_T("FFmpegSourceCacheCleaner: deleted %d files"), deleted);
wxLogDebug(_T("FFmpegSourceCacheCleaner: done, exiting"));
LOG_D("provider/ffmpegsource/cache") << "deleted " << deleted << " files, exiting";
return (wxThread::ExitCode)0;
}

View File

@ -45,6 +45,8 @@
#include <wx/log.h>
#endif
#include <libaegisub/log.h>
#include "compat.h"
#include "mythes.hxx"
#include "main.h"
@ -164,7 +166,7 @@ void MySpellThesaurus::SetLanguage(wxString language) {
// Check if language is available
if (!wxFileExists(idxpath) || !wxFileExists(datpath)) return;
wxLogDebug(_("Using thesarus: %ls"), datpath.c_str());
LOG_I("thesaurus/file") << "Using thesaurus: " << datpath.c_str();
// Load
mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal));

View File

@ -44,6 +44,8 @@
#include <unistd.h>
#endif
#include <libaegisub/log.h>
#include <wx/dcmemory.h>
#include <wx/filename.h>
#include <wx/log.h>
@ -459,7 +461,7 @@ void RestartAegisub() {
char *support_path = OSX_GetBundleSupportFilesDirectory();
if (!bundle_path || !support_path) return; // oops
wxString exec = wxString::Format(_T("\"%s/MacOS/restart-helper\" /usr/bin/open -n \"%s\"'"), wxString(support_path, wxConvUTF8).c_str(), wxString(bundle_path, wxConvUTF8).c_str());
wxLogDebug("RestartAegisub: (%s)", exec);
LOG_I("util/restart/exec") << exec;
wxExecute(exec);
free(bundle_path);
free(support_path);

View File

@ -39,6 +39,8 @@
// Headers
#include "config.h"
#include <libaegisub/log.h>
#include "compat.h"
#include "main.h"
#include "options.h"
@ -75,10 +77,10 @@ VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video) {
return y4m_provider;
}
catch (wxString temp) {
wxLogDebug(_T("YUV4MPEG provider creation failed with reason: %s; trying other providers"), temp.c_str());
LOG_E("manager/video/provider/yuv4mpeg") << "Provider creation failed with reason: "<< temp.c_str() << " trying other providers";
}
catch (...) {
wxLogDebug(_T("YUV4MPEG provider creation failed for unknown reasons, trying other providers"));
LOG_E("manager/video/provider/yuv4mpeg") << "Provider creation failed (uknown reason) trying other providers";
}
// List of providers

View File

@ -36,6 +36,8 @@
#include "config.h"
#include <libaegisub/log.h>
#include "video_provider_yuv4mpeg.h"
// All of this cstdio bogus is because of one reason and one reason only:
@ -113,7 +115,7 @@ void YUV4MPEGVideoProvider::LoadVideo(const wxString _filename) {
if (fps_rat.num <= 0 || fps_rat.den <= 0) {
fps_rat.num = 25;
fps_rat.den = 1;
wxLogDebug(_T("YUV4MPEG video provider: framerate info unavailable, assuming 25fps"));
LOG_D("provider/video/yuv4mpeg") << "framerate info unavailable, assuming 25fps";
}
if (pixfmt == Y4M_PIXFMT_NONE)
pixfmt = Y4M_PIXFMT_420JPEG;
@ -187,7 +189,7 @@ std::vector<wxString> YUV4MPEGVideoProvider::ReadHeader(int64_t startpos, bool r
if (feof(sf)) {
// you know, this is one of the places where it would be really nice
// to be able to throw an exception object that tells the caller that EOF was reached
wxLogDebug(_T("YUV4MPEG video provider: ReadHeader: Reached EOF, returning"));
LOG_D("provider/video/yuv4mpeg") << "ReadHeader: Reached EOF, returning";
break;
}
@ -281,7 +283,7 @@ void YUV4MPEGVideoProvider::ParseFileHeader(const std::vector<wxString>& tags) {
throw wxString(_T("ParseFileHeader: invalid or unknown interlacing mode"));
}
else
wxLogDebug(_T("ParseFileHeader: unparsed tag: %s"), tags.at(i).c_str());
LOG_D("provider/video/yuv4mpeg") << "Unparsed tag: " << tags.at(i).c_str();
}
// The point of all this is to allow multiple YUV4MPEG2 headers in a single file