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
|
|
19 | 19 | |
20 | 20 | /* #define DEBUG 1 */ /* Define this to enable DPRINTF_DEBUG statements */ |
21 | 21 | /* (Other categories of printout set in usb_midi.h) */ |
| 22 | #define DEBUG 1 |
22 | 23 | |
23 | 24 | #include "usb_midi.h" |
24 | 25 | |
… |
… |
usb_midi_read(driver_cookie* cookie, off_t position,
|
575 | 576 | DPRINTF_DEBUG((MY_ID "usb_midi_read: (%" B_PRIuSIZE " byte buffer at %" |
576 | 577 | B_PRIdOFF " cookie %p)\n", *num_bytes, position, cookie)); |
577 | 578 | 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")); |
579 | 580 | err = acquire_sem_etc(cookie->sem_cb, 1, |
580 | 581 | B_RELATIVE_TIMEOUT, 1000000); |
581 | 582 | 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")); |
583 | 584 | continue; /* see if we're still active */ |
584 | 585 | } |
585 | 586 | if (err != B_OK) { |
586 | 587 | *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")); |
588 | 589 | break; |
589 | 590 | } |
590 | | DPRINTF_DEBUG((MY_ID "reading from ringbuffer\n")); |
| 591 | DPRINTF_DEBUG((MY_ID "usb_midi_read: reading from ringbuffer\n")); |
591 | 592 | acquire_sem(midiDevice->sem_lock); |
592 | 593 | /* a global semaphore -- OK, I think */ |
593 | 594 | ring_buffer_user_read(port->rbuf, (uint8*)buf, 1); |
594 | 595 | release_sem(midiDevice->sem_lock); |
595 | 596 | *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", |
597 | 598 | *(uint8*)buf, cookie)); |
598 | 599 | return B_OK; |
599 | 600 | } |
… |
… |
usb_midi_write(driver_cookie* cookie, off_t position,
|
638 | 639 | usbmidi_port_info* port = cookie->port; |
639 | 640 | usbmidi_device_info* midiDevice = cookie->device; |
640 | 641 | |
| 642 | DPRINTF_DEBUG((MY_ID "usb_midi_write: (%" B_PRIuSIZE " byte buffer at %" |
| 643 | B_PRIdOFF " cookie %p)\n", *num_bytes, position, cookie)); |
| 644 | |
641 | 645 | if (!midiDevice || !midiDevice->active) |
642 | 646 | return B_ERROR; /* already unplugged */ |
643 | 647 | |
644 | 648 | buff_lim = midiDevice->outMaxPkt * 3 / 4; |
645 | 649 | /* max MIDI bytes buffer space */ |
646 | 650 | |
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 |
648 | 652 | ")\n", *num_bytes, position)); |
649 | 653 | 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" |
651 | 655 | " -- too big to handle\n", *num_bytes)); |
652 | 656 | return B_ERROR; |
653 | 657 | } |
… |
… |
usb_midi_write(driver_cookie* cookie, off_t position,
|
663 | 667 | if (status != B_OK) |
664 | 668 | return status; |
665 | 669 | |
| 670 | DPRINTF_DEBUG((MY_ID "usb_midi_write: ======== begin xfer of %" B_PRIuSIZE " bytes\n", xfer_bytes)); |
666 | 671 | while (xfer_bytes) { |
667 | 672 | uint8 pkt_bytes = CINbytes[cin]; |
| 673 | DPRINTF_DEBUG((MY_ID "usb_midi_write: = pointer of pkt is %p\n", pkt)); |
668 | 674 | memset(pkt, 0, sizeof(usb_midi_event_packet)); |
669 | 675 | pkt->cin = cin; |
670 | 676 | 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)" |
672 | 678 | " %x %x %x\n", pkt->cin, CINbytes[pkt->cin], |
673 | 679 | midiseq[0], midiseq[1], midiseq[2])); |
674 | 680 | 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", |
676 | 682 | pkt, pkt->cin, pkt->cn, |
677 | 683 | pkt->midi[0], pkt->midi[1], pkt->midi[2])); |
678 | 684 | xfer_bytes -= pkt_bytes; |
… |
… |
usb_midi_write(driver_cookie* cookie, off_t position,
|
680 | 686 | midiseq += pkt_bytes; |
681 | 687 | packet_count++; |
682 | 688 | pkt++; |
| 689 | DPRINTF_DEBUG((MY_ID "usb_midi_write: === continue xfer of %" B_PRIuSIZE " bytes\n", xfer_bytes)); |
683 | 690 | if (midicode == 0xF0 && bytes_left < 4) cin = 4 + bytes_left; |
684 | 691 | /* see USB-MIDI Spec */ |
685 | 692 | } |
… |
… |
usb_midi_write(driver_cookie* cookie, off_t position,
|
688 | 695 | * packet_count, (usb_callback_func)midi_usb_write_callback, |
689 | 696 | midiDevice); |
690 | 697 | 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 |
692 | 699 | "\n", status)); |
693 | 700 | return B_ERROR; |
694 | 701 | } |