Ticket #15562: additional-usb_midi-logs.patch

File additional-usb_midi-logs.patch, 4.3 KB (added by nilsding, 4 years ago)

additional log statements for usb_midi

  • src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp

    diff --git a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp
    index 5656fec2c8..0f2bdc7f74 100644
    a b  
    1919
    2020/* #define DEBUG 1 */   /* Define this to enable DPRINTF_DEBUG statements */
    2121/* (Other categories of printout set in usb_midi.h) */
     22#define DEBUG 1
    2223
    2324#include "usb_midi.h"
    2425
    usb_midi_read(driver_cookie* cookie, off_t position,  
    575576    DPRINTF_DEBUG((MY_ID "usb_midi_read: (%" B_PRIuSIZE " byte buffer at %"
    576577        B_PRIdOFF " cookie %p)\n", *num_bytes, position, cookie));
    577578    while (midiDevice && midiDevice->active) {
    578         ZDPRINTF_DEBUG((MY_ID "waiting on acquire_sem_etc\n"));
     579        ZDPRINTF_DEBUG((MY_ID "usb_midi_read: waiting on acquire_sem_etc\n"));
    579580        err = acquire_sem_etc(cookie->sem_cb, 1,
    580581             B_RELATIVE_TIMEOUT, 1000000);
    581582        if (err == B_TIMED_OUT) {
    582             ZDPRINTF_DEBUG((MY_ID "acquire_sem_etc timed out\n"));
     583            ZDPRINTF_DEBUG((MY_ID "usb_midi_read: acquire_sem_etc timed out\n"));
    583584            continue;   /* see if we're still active */
    584585        }
    585586        if (err != B_OK) {
    586587            *num_bytes = 0;
    587             DPRINTF_DEBUG((MY_ID "acquire_sem_etc aborted\n"));
     588            DPRINTF_DEBUG((MY_ID "usb_midi_read: acquire_sem_etc aborted\n"));
    588589            break;
    589590        }
    590         DPRINTF_DEBUG((MY_ID "reading from ringbuffer\n"));
     591        DPRINTF_DEBUG((MY_ID "usb_midi_read: reading from ringbuffer\n"));
    591592        acquire_sem(midiDevice->sem_lock);
    592593            /* a global semaphore -- OK, I think */
    593594        ring_buffer_user_read(port->rbuf, (uint8*)buf, 1);
    594595        release_sem(midiDevice->sem_lock);
    595596        *num_bytes = 1;
    596         DPRINTF_DEBUG((MY_ID "read byte %x -- cookie %p)\n",
     597        DPRINTF_DEBUG((MY_ID "usb_midi_read: read byte %x -- cookie %p)\n",
    597598            *(uint8*)buf, cookie));
    598599        return B_OK;
    599600    }
    usb_midi_write(driver_cookie* cookie, off_t position,  
    638639    usbmidi_port_info* port = cookie->port;
    639640    usbmidi_device_info* midiDevice = cookie->device;
    640641
     642    DPRINTF_DEBUG((MY_ID "usb_midi_write: (%" B_PRIuSIZE " byte buffer at %"
     643        B_PRIdOFF " cookie %p)\n", *num_bytes, position, cookie));
     644
    641645    if (!midiDevice || !midiDevice->active)
    642646        return B_ERROR;     /* already unplugged */
    643647
    644648    buff_lim = midiDevice->outMaxPkt * 3 / 4;
    645649        /* max MIDI bytes buffer space */
    646650
    647     DPRINTF_DEBUG((MY_ID "MIDI write (%" B_PRIuSIZE " bytes at %" B_PRIdOFF
     651    DPRINTF_DEBUG((MY_ID "usb_midi_write: MIDI write (%" B_PRIuSIZE " bytes at %" B_PRIdOFF
    648652        ")\n", *num_bytes, position));
    649653    if (*num_bytes > 3 && midicode != 0xF0) {
    650         DPRINTF_ERR((MY_ID "Non-SysEx packet of %ld bytes"
     654        DPRINTF_ERR((MY_ID "usb_midi_write: Non-SysEx packet of %ld bytes"
    651655            " -- too big to handle\n", *num_bytes));
    652656        return B_ERROR;
    653657    }
    usb_midi_write(driver_cookie* cookie, off_t position,  
    663667        if (status != B_OK)
    664668            return status;
    665669
     670        DPRINTF_DEBUG((MY_ID "usb_midi_write: ======== begin xfer of %" B_PRIuSIZE " bytes\n", xfer_bytes));
    666671        while (xfer_bytes) {
    667672            uint8 pkt_bytes = CINbytes[cin];
     673            DPRINTF_DEBUG((MY_ID "usb_midi_write: = pointer of pkt is %p\n", pkt));
    668674            memset(pkt, 0, sizeof(usb_midi_event_packet));
    669675            pkt->cin = cin;
    670676            pkt->cn = port->cable;
    671             DPRINTF_DEBUG((MY_ID "using packet data (code %x -- %d bytes)"
     677            DPRINTF_DEBUG((MY_ID "usb_midi_write: using packet data (code %x -- %d bytes)"
    672678                " %x %x %x\n", pkt->cin, CINbytes[pkt->cin],
    673679                midiseq[0], midiseq[1], midiseq[2]));
    674680            memcpy(pkt->midi, midiseq, pkt_bytes);
    675             DPRINTF_DEBUG((MY_ID "built packet %p %x:%d %x %x %x\n",
     681            DPRINTF_DEBUG((MY_ID "usb_midi_write: built packet %p %x:%d %x %x %x\n",
    676682                pkt, pkt->cin, pkt->cn,
    677683                pkt->midi[0], pkt->midi[1], pkt->midi[2]));
    678684            xfer_bytes -= pkt_bytes;
    usb_midi_write(driver_cookie* cookie, off_t position,  
    680686            midiseq += pkt_bytes;
    681687            packet_count++;
    682688            pkt++;
     689            DPRINTF_DEBUG((MY_ID "usb_midi_write: === continue xfer of %" B_PRIuSIZE " bytes\n", xfer_bytes));
    683690            if (midicode == 0xF0 && bytes_left < 4) cin = 4 + bytes_left;
    684691                /* see USB-MIDI Spec */
    685692        }
    usb_midi_write(driver_cookie* cookie, off_t position,  
    688695            * packet_count, (usb_callback_func)midi_usb_write_callback,
    689696            midiDevice);
    690697        if (status != B_OK) {
    691             DPRINTF_ERR((MY_ID "midi write queue_bulk() error 0x%" B_PRIx32
     698            DPRINTF_ERR((MY_ID "usb_midi_write: midi write queue_bulk() error 0x%" B_PRIx32
    692699                "\n", status));
    693700            return B_ERROR;
    694701        }