Logging system rework

* use one central unified log with channels/priorities ad-hoc listener registration and de-registration
* disable buffering by default
* add multi-threaded ringbuffer implementation
* use buffered listener for the gui (using the ringbuffer)
This commit is contained in:
Peter Tissen 2014-06-17 17:44:03 +02:00 committed by Bigpet
parent 394b698e92
commit 21da317453
165 changed files with 1731 additions and 1519 deletions

View file

@ -1,5 +1,5 @@
#include "stdafx.h"
#include "Emu/ConLog.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUThread.h"
@ -36,7 +36,7 @@ next:
{
if (Emu.IsStopped())
{
ConLog.Warning("adecRawRead(): aborted");
LOG_WARNING(HLE, "adecRawRead(): aborted");
return 0;
}
Sleep(1);
@ -53,7 +53,7 @@ next:
{
if (!Memory.CopyToReal(buf, adec.reader.addr, adec.reader.size))
{
ConLog.Error("adecRawRead(): data reading failed (reader.size=0x%x)", adec.reader.size);
LOGF_ERROR(HLE, "adecRawRead(): data reading failed (reader.size=0x%x)", adec.reader.size);
Emu.Pause();
return 0;
}
@ -68,11 +68,11 @@ next:
adec.reader.addr = adec.task.au.addr;
adec.reader.size = adec.task.au.size;
//ConLog.Write("Audio AU: size = 0x%x, pts = 0x%llx", adec.task.au.size, adec.task.au.pts);
//LOGF_NOTICE(HLE, "Audio AU: size = 0x%x, pts = 0x%llx", adec.task.au.size, adec.task.au.pts);
}
break;
default:
ConLog.Error("adecRawRead(): sequence error (task %d)", adec.job.Peek().type);
LOGF_ERROR(HLE, "adecRawRead(): sequence error (task %d)", adec.job.Peek().type);
return -1;
}
@ -89,7 +89,7 @@ next:
}
else if (!Memory.CopyToReal(buf, adec.reader.addr, buf_size))
{
ConLog.Error("adecRawRead(): data reading failed (buf_size=0x%x)", buf_size);
LOGF_ERROR(HLE, "adecRawRead(): data reading failed (buf_size=0x%x)", buf_size);
Emu.Pause();
return 0;
}
@ -111,7 +111,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
{
if (buf_size < (int)adec.reader.rem_size)
{
ConLog.Error("adecRead(): too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size);
LOGF_ERROR(HLE, "adecRead(): too small buf_size (rem_size = %d, buf_size = %d)", adec.reader.rem_size, buf_size);
Emu.Pause();
return 0;
}
@ -131,7 +131,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
if (adecRawRead(opaque, header, 8) < 8) break;
if (header[0] != 0x0f || header[1] != 0xd0)
{
ConLog.Error("adecRead(): 0x0FD0 header not found");
LOGF_ERROR(HLE, "adecRead(): 0x0FD0 header not found");
Emu.Pause();
return -1;
}
@ -141,7 +141,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
OMAHeader oma(1 /* atrac3p id */, header[2], header[3]);
if (buf_size < sizeof(oma) + 8)
{
ConLog.Error("adecRead(): OMAHeader writing failed");
LOGF_ERROR(HLE, "adecRead(): OMAHeader writing failed");
Emu.Pause();
return 0;
}
@ -159,7 +159,7 @@ int adecRead(void* opaque, u8* buf, int buf_size)
u32 size = (((header[2] & 0x3) << 8) | header[3]) * 8 + 8; // data to be read before next header
//ConLog.Write("*** audio block read: size = 0x%x", size);
//LOGF_NOTICE(HLE, "*** audio block read: size = 0x%x", size);
if (buf_size < (int)size)
{
@ -198,7 +198,7 @@ u32 adecOpen(AudioDecoder* data)
thread t("Audio Decoder[" + std::to_string(adec_id) + "] Thread", [&]()
{
ConLog.Write("Audio Decoder thread started");
LOGF_NOTICE(HLE, "Audio Decoder thread started");
AdecTask& task = adec.task;
@ -231,7 +231,7 @@ u32 adecOpen(AudioDecoder* data)
case adecStartSeq:
{
// TODO: reset data
ConLog.Warning("adecStartSeq:");
LOGF_WARNING(HLE, "adecStartSeq:");
adec.reader.addr = 0;
adec.reader.size = 0;
@ -247,7 +247,7 @@ u32 adecOpen(AudioDecoder* data)
case adecEndSeq:
{
// TODO: finalize
ConLog.Warning("adecEndSeq:");
LOGF_WARNING(HLE, "adecEndSeq:");
/*Callback cb;
cb.SetAddr(adec.cbFunc);
@ -268,7 +268,7 @@ u32 adecOpen(AudioDecoder* data)
adec.reader.addr = task.au.addr;
adec.reader.size = task.au.size;
//ConLog.Write("Audio AU: size = 0x%x, pts = 0x%llx", task.au.size, task.au.pts);
//LOGF_NOTICE(HLE, "Audio AU: size = 0x%x, pts = 0x%llx", task.au.size, task.au.pts);
if (adec.just_started)
{
@ -317,33 +317,33 @@ u32 adecOpen(AudioDecoder* data)
err = avformat_open_input(&adec.fmt, NULL, av_find_input_format("oma"), NULL);
if (err)
{
ConLog.Error("adecDecodeAu: avformat_open_input() failed");
LOGF_ERROR(HLE, "adecDecodeAu: avformat_open_input() failed");
Emu.Pause();
break;
}
AVCodec* codec = avcodec_find_decoder(AV_CODEC_ID_ATRAC3P); // ???
if (!codec)
{
ConLog.Error("adecDecodeAu: avcodec_find_decoder() failed");
LOGF_ERROR(HLE, "adecDecodeAu: avcodec_find_decoder() failed");
Emu.Pause();
break;
}
/*err = avformat_find_stream_info(adec.fmt, NULL);
if (err)
{
ConLog.Error("adecDecodeAu: avformat_find_stream_info() failed");
LOGF_ERROR(HLE, "adecDecodeAu: avformat_find_stream_info() failed");
Emu.Pause();
break;
}
if (!adec.fmt->nb_streams)
{
ConLog.Error("adecDecodeAu: no stream found");
LOGF_ERROR(HLE, "adecDecodeAu: no stream found");
Emu.Pause();
break;
}*/
if (!avformat_new_stream(adec.fmt, codec))
{
ConLog.Error("adecDecodeAu: avformat_new_stream() failed");
LOGF_ERROR(HLE, "adecDecodeAu: avformat_new_stream() failed");
Emu.Pause();
break;
}
@ -358,7 +358,7 @@ u32 adecOpen(AudioDecoder* data)
}
if (err)
{
ConLog.Error("adecDecodeAu: avcodec_open2() failed");
LOGF_ERROR(HLE, "adecDecodeAu: avcodec_open2() failed");
Emu.Pause();
break;
}
@ -371,7 +371,7 @@ u32 adecOpen(AudioDecoder* data)
{
if (Emu.IsStopped())
{
ConLog.Warning("adecDecodeAu: aborted");
LOGF_WARNING(HLE, "adecDecodeAu: aborted");
return;
}
@ -420,7 +420,7 @@ u32 adecOpen(AudioDecoder* data)
if (!frame.data)
{
ConLog.Error("adecDecodeAu: av_frame_alloc() failed");
LOGF_ERROR(HLE, "adecDecodeAu: av_frame_alloc() failed");
Emu.Pause();
break;
}
@ -433,7 +433,7 @@ u32 adecOpen(AudioDecoder* data)
{
if (!last_frame && decode < 0)
{
ConLog.Error("adecDecodeAu: AU decoding error(0x%x)", decode);
LOGF_ERROR(HLE, "adecDecodeAu: AU decoding error(0x%x)", decode);
}
if (!got_frame && adec.reader.size == 0) break;
}
@ -460,18 +460,18 @@ u32 adecOpen(AudioDecoder* data)
if (frame.data->format != AV_SAMPLE_FMT_FLTP)
{
ConLog.Error("adecDecodeaAu: unsupported frame format(%d)", frame.data->format);
LOGF_ERROR(HLE, "adecDecodeaAu: unsupported frame format(%d)", frame.data->format);
Emu.Pause();
break;
}
if (frame.data->channels != 2)
{
ConLog.Error("adecDecodeAu: unsupported channel count (%d)", frame.data->channels);
LOGF_ERROR(HLE, "adecDecodeAu: unsupported channel count (%d)", frame.data->channels);
Emu.Pause();
break;
}
//ConLog.Write("got audio frame (pts=0x%llx, nb_samples=%d, ch=%d, sample_rate=%d, nbps=%d)",
//LOGF_NOTICE(HLE, "got audio frame (pts=0x%llx, nb_samples=%d, ch=%d, sample_rate=%d, nbps=%d)",
//frame.pts, frame.data->nb_samples, frame.data->channels, frame.data->sample_rate,
//av_get_bytes_per_sample((AVSampleFormat)frame.data->format));
@ -497,16 +497,16 @@ u32 adecOpen(AudioDecoder* data)
case adecClose:
{
adec.is_finished = true;
ConLog.Write("Audio Decoder thread ended");
LOGF_NOTICE(HLE, "Audio Decoder thread ended");
return;
}
default:
ConLog.Error("Audio Decoder thread error: unknown task(%d)", task.type);
LOGF_ERROR(HLE, "Audio Decoder thread error: unknown task(%d)", task.type);
}
}
adec.is_finished = true;
ConLog.Warning("Audio Decoder thread aborted");
LOGF_WARNING(HLE, "Audio Decoder thread aborted");
});
t.detach();
@ -518,8 +518,8 @@ bool adecCheckType(AudioCodecType type)
{
switch (type)
{
case CELL_ADEC_TYPE_ATRACX: ConLog.Write("*** (?) type: ATRAC3plus"); break;
case CELL_ADEC_TYPE_ATRACX_2CH: ConLog.Write("*** type: ATRAC3plus 2ch"); break;
case CELL_ADEC_TYPE_ATRACX: LOGF_NOTICE(HLE, "*** (?) type: ATRAC3plus"); break;
case CELL_ADEC_TYPE_ATRACX_2CH: LOGF_NOTICE(HLE, "*** type: ATRAC3plus 2ch"); break;
case CELL_ADEC_TYPE_ATRACX_6CH:
case CELL_ADEC_TYPE_ATRACX_8CH:
@ -609,7 +609,7 @@ int cellAdecClose(u32 handle)
{
if (Emu.IsStopped())
{
ConLog.Warning("cellAdecClose(%d) aborted", handle);
LOGF_WARNING(HLE, "cellAdecClose(%d) aborted", handle);
break;
}
Sleep(1);
@ -732,7 +732,7 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
if (!swr)
{
ConLog.Error("cellAdecGetPcm(%d): swr_alloc_set_opts() failed", handle);
LOGF_ERROR(HLE, "cellAdecGetPcm(%d): swr_alloc_set_opts() failed", handle);
Emu.Pause();
free(out);
if (af.data)
@ -759,7 +759,7 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
if (!Memory.CopyFromReal(outBuffer_addr, out, af.size))
{
ConLog.Error("cellAdecGetPcm(%d): data copying failed (addr=0x%x)", handle, outBuffer_addr);
LOGF_ERROR(HLE, "cellAdecGetPcm(%d): data copying failed (addr=0x%x)", handle, outBuffer_addr);
Emu.Pause();
}