[haiku-commits] haiku: hrev48760 - in src: add-ons/kernel/drivers/midi/usb_midi tests/kits/midi

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 2 Feb 2015 08:56:38 +0100 (CET)

hrev48760 adds 2 changesets to branch 'master'
old head: 7e8f38e0f5f5495f43a061ff87ef1f969931601a
new head: 578e26c0d3e7fe4ed03bfcf3bd336a26aff8c767
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=578e26c0d3e7+%5E7e8f38e0f5f5

----------------------------------------------------------------------------

ed00de38d9d4: Midi test1: style fixes.

578e26c0d3e7: usb_midi: fix KDL when there is no in or out endpoint
  
  usb_midi devices can be input-only or output-only. We failed to check
  for this in some places leading to KDL on devices that are not
  bidirectional.
  
  Should fix #11810.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 19 insertions(+), 14 deletions(-)
.../kernel/drivers/midi/usb_midi/usb_midi.cpp    | 23 ++++++++++++--------
src/tests/kits/midi/test1.cpp                    | 10 ++++-----

############################################################################

Commit:      ed00de38d9d4b9af2d544d4ac724f5eacaf02551
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ed00de38d9d4
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Sun Feb  1 10:00:30 2015 UTC

Midi test1: style fixes.

----------------------------------------------------------------------------

diff --git a/src/tests/kits/midi/test1.cpp b/src/tests/kits/midi/test1.cpp
index f1e8622..8749bab 100644
--- a/src/tests/kits/midi/test1.cpp
+++ b/src/tests/kits/midi/test1.cpp
@@ -4,14 +4,14 @@
 #include <iostream.h>
 
 int main(int argc, char * argv[]) {
-       if(argc < 2) {
+       if (argc < 2) {
                cerr << "Must supply a filename (*.mid)!" << endl;
                return 1;
        }
        BMidiText * text = new BMidiText();
        BMidiStore * store = new BMidiStore();
-       BEntry entry(argv[1],true);
-       if(!entry.Exists()) {
+       BEntry entry(argv[1], true);
+       if (!entry.Exists()) {
                cerr << "File does not exist." << endl;
                return 2;
        }
@@ -21,7 +21,7 @@ int main(int argc, char * argv[]) {
        store->Connect(text);
        uint32 start_time = B_NOW;
        store->Start();
-       while(store->IsRunning()) {
+       while (store->IsRunning()) {
                snooze(100000);
        }
        store->Stop();
@@ -29,7 +29,7 @@ int main(int argc, char * argv[]) {
        cout << "Start Time: " << dec << start_time << "ms" << endl;
        cout << "Stop Time: " << dec << stop_time << "ms" << endl;
        cout << "Total time: " << dec << stop_time - start_time << "ms" << endl;
-       
+
        store->Disconnect(text);
        delete store;
        delete text;

############################################################################

Revision:    hrev48760
Commit:      578e26c0d3e7fe4ed03bfcf3bd336a26aff8c767
URL:         http://cgit.haiku-os.org/haiku/commit/?id=578e26c0d3e7
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Mon Feb  2 07:53:19 2015 UTC

Ticket:      https://dev.haiku-os.org/ticket/11810

usb_midi: fix KDL when there is no in or out endpoint

usb_midi devices can be input-only or output-only. We failed to check
for this in some places leading to KDL on devices that are not
bidirectional.

Should fix #11810.

----------------------------------------------------------------------------

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 3facd1a..589905e 100644
--- a/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp
+++ b/src/add-ons/kernel/drivers/midi/usb_midi/usb_midi.cpp
@@ -431,13 +431,15 @@ got_one:
        }
 
        /* issue bulk transfer */
-       DPRINTF_DEBUG((MY_ID "queueing bulk xfer IN endpoint\n"));
-       status = usb->queue_bulk(midiDevice->ept_in->handle, midiDevice->buffer,
-               midiDevice->inMaxPkt,
-               (usb_callback_func)midi_usb_read_callback, midiDevice);
-       if (status != B_OK) {
-               DPRINTF_ERR((MY_ID "queue_bulk() error 0x%" B_PRIx32 "\n", 
status));
-               return B_ERROR;
+       if (midiDevice->ept_in != NULL) {
+               DPRINTF_DEBUG((MY_ID "queueing bulk xfer IN endpoint\n"));
+               status = usb->queue_bulk(midiDevice->ept_in->handle, 
midiDevice->buffer,
+                       midiDevice->inMaxPkt,
+                       (usb_callback_func)midi_usb_read_callback, midiDevice);
+               if (status != B_OK) {
+                       DPRINTF_ERR((MY_ID "queue_bulk() error 0x%" B_PRIx32 
"\n", status));
+                       return B_ERROR;
+               }
        }
 
        *cookie = midiDevice;
@@ -471,8 +473,11 @@ usb_midi_removed(void* cookie)
                }
                remove_port(port);
        }
-       usb->cancel_queued_transfers(midiDevice->ept_in->handle);
-       usb->cancel_queued_transfers(midiDevice->ept_out->handle);
+
+       if (midiDevice->ept_in != NULL)
+               usb->cancel_queued_transfers(midiDevice->ept_in->handle);
+       if (midiDevice->ept_out != NULL)
+               usb->cancel_queued_transfers(midiDevice->ept_out->handle);
        DPRINTF_DEBUG((MY_ID "usb_midi_removed: doing remove: %s\n",
                midiDevice->name));
        remove_device(midiDevice);


Other related posts:

  • » [haiku-commits] haiku: hrev48760 - in src: add-ons/kernel/drivers/midi/usb_midi tests/kits/midi - pulkomandy