[PATCH] Improve MIDI tracing

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


- Move MIDI IRQ & register read/write trace output to separate
  "midi_raw" option, as that output being triggered just by moving
  mouse messes up debugging rest of MIDI funcionality
- Log PortMidi device open failures
---
 src/debug/log.c |  1 +
 src/debug/log.h |  2 ++
 src/midi.c      | 14 +++++++++-----
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/debug/log.c b/src/debug/log.c
index be2e1ef6..3e8aeef6 100644
--- a/src/debug/log.c
+++ b/src/debug/log.c
@@ -122,6 +122,7 @@ static flagname_t TraceFlags[] = {
 	{ TRACE_MFP_WRITE	 , "mfp_write" },
 
 	{ TRACE_MIDI		 , "midi" },
+	{ TRACE_MIDI_RAW	 , "midi_raw" },
 
 	{ TRACE_NATFEATS	 , "natfeats" },
 
diff --git a/src/debug/log.h b/src/debug/log.h
index 892f0a6c..b8a5794f 100644
--- a/src/debug/log.h
+++ b/src/debug/log.h
@@ -151,6 +151,7 @@ enum {
 	TRACE_BIT_MFP_WRITE,
 
 	TRACE_BIT_MIDI,
+	TRACE_BIT_MIDI_RAW,
 
 	TRACE_BIT_NATFEATS,
 
@@ -234,6 +235,7 @@ enum {
 #define TRACE_MFP_WRITE          (1ll<<TRACE_BIT_MFP_WRITE)
 
 #define TRACE_MIDI               (1ll<<TRACE_BIT_MIDI)
+#define TRACE_MIDI_RAW           (1ll<<TRACE_BIT_MIDI_RAW)
 
 #define TRACE_NATFEATS           (1ll<<TRACE_BIT_NATFEATS)
 
diff --git a/src/midi.c b/src/midi.c
index 2f8ef8b6..9b751feb 100644
--- a/src/midi.c
+++ b/src/midi.c
@@ -161,7 +161,7 @@ static void	MIDI_UpdateIRQ ( void )
 	/* Update SR and IRQ line if a change happened */
 	if ( ( MidiStatusRegister & ACIA_SR_INTERRUPT_REQUEST ) != irq_bit_new )
 	{
-		LOG_TRACE ( TRACE_MIDI, "midi update irq irq_new=%d VBL=%d HBL=%d\n" , irq_bit_new?1:0 , nVBLs , nHBL );
+		LOG_TRACE ( TRACE_MIDI_RAW, "midi update irq irq_new=%d VBL=%d HBL=%d\n" , irq_bit_new?1:0 , nVBLs , nHBL );
 
 		if ( irq_bit_new )
 		{
@@ -202,7 +202,7 @@ void Midi_Control_ReadByte(void)
 
 	IoMem[0xfffc04] = MidiStatusRegister;
 
-	LOG_TRACE ( TRACE_MIDI, "midi read fffc04 sr=0x%02x VBL=%d HBL=%d\n" , MidiStatusRegister , nVBLs , nHBL );
+	LOG_TRACE ( TRACE_MIDI_RAW, "midi read fffc04 sr=0x%02x VBL=%d HBL=%d\n" , MidiStatusRegister , nVBLs , nHBL );
 }
 
 
@@ -215,7 +215,7 @@ void Midi_Control_WriteByte(void)
 
 	MidiControlRegister = IoMem[0xfffc04];
 
-	LOG_TRACE ( TRACE_MIDI, "midi write fffc04 cr=0x%02x VBL=%d HBL=%d\n" , MidiControlRegister , nVBLs , nHBL );
+	LOG_TRACE ( TRACE_MIDI_RAW, "midi write fffc04 cr=0x%02x VBL=%d HBL=%d\n" , MidiControlRegister , nVBLs , nHBL );
 
 	MIDI_UpdateIRQ ();
 }
@@ -226,7 +226,7 @@ void Midi_Control_WriteByte(void)
  */
 void Midi_Data_ReadByte(void)
 {
-	LOG_TRACE ( TRACE_MIDI, "midi read fffc06 rdr=0x%02x VBL=%d HBL=%d\n" , nRxDataByte , nVBLs , nHBL );
+	LOG_TRACE ( TRACE_MIDI_RAW, "midi read fffc06 rdr=0x%02x VBL=%d HBL=%d\n" , nRxDataByte , nVBLs , nHBL );
 //fprintf ( stderr , "midi rx %x\n" , nRxDataByte);
 
 	ACIA_AddWaitCycles ();						/* Additional cycles when accessing the ACIA */
@@ -268,7 +268,7 @@ void Midi_Data_WriteByte(void)
 		TSR_Complete_Time += MIDI_TRANSFER_BYTE_CYCLE;
 	}
 
-	LOG_TRACE ( TRACE_MIDI, "midi write fffc06 tdr=0x%02x VBL=%d HBL=%d\n" , nTxDataByte , nVBLs , nHBL );
+	LOG_TRACE ( TRACE_MIDI_RAW, "midi write fffc06 tdr=0x%02x VBL=%d HBL=%d\n" , nTxDataByte , nVBLs , nHBL );
 //fprintf ( stderr , "midi tx %x sr=%x\n" , nTxDataByte , MidiStatusRegister );
 
 	MidiStatusRegister &= ~ACIA_SR_TX_EMPTY;
@@ -525,7 +525,11 @@ static bool Midi_Host_SwitchPort(const char* portName, bool forInput)
 		}
 	}
 	if (i >= count)
+	{
+		LOG_TRACE(TRACE_MIDI, "MIDI: no %s ports matching '%s'\n",
+			  forInput ? "input" : "output", portName);
 		return false;
+	}
 
 	// -- close current port in any case, then try open new one
 	if (forInput == true)
-- 
2.30.2


--------------D46473D5EDAB8A7F2FE14647--



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/