From: Markus G. <ger...@us...> - 2004-04-24 16:10:08
|
Update of /cvsroot/mpio/mpio/libmpio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30366/libmpio/src Modified Files: io.c mpio.c Log Message: further open/close fixes Index: mpio.c =================================================================== RCS file: /cvsroot/mpio/mpio/libmpio/src/mpio.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** mpio.c 23 Apr 2004 19:21:07 -0000 1.14 --- mpio.c 24 Apr 2004 16:09:58 -0000 1.15 *************** *** 96,102 **** "The selected directory is not empty." }, { MPIO_ERR_DEVICE_NOT_READY, ! "Could not open " MPIO_DEVICE "\n" ! "Verify that the mpio module is loaded and " ! "your MPIO is\nconnected and powered up.\n" }, { MPIO_ERR_OUT_OF_MEMORY, "Out of Memory." }, --- 96,102 ---- "The selected directory is not empty." }, { MPIO_ERR_DEVICE_NOT_READY, ! "Could not access the player\n" ! "Verify that the the player is\n" ! "connected and powered up.\n" }, { MPIO_ERR_OUT_OF_MEMORY, "Out of Memory." }, *************** *** 315,323 **** --- 315,326 ---- if (!new_mpio) { debug ("Error allocating memory for mpio_t"); + _mpio_errno = MPIO_ERR_OUT_OF_MEMORY; return NULL; } memset(new_mpio, 0, sizeof(mpio_t)); + new_mpio->fd=0; if (mpio_device_open(new_mpio) != MPIO_OK) { + free(new_mpio); _mpio_errno = MPIO_ERR_DEVICE_NOT_READY; return NULL; Index: io.c =================================================================== RCS file: /cvsroot/mpio/mpio/libmpio/src/io.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** io.c 23 Apr 2004 18:17:56 -0000 1.11 --- io.c 24 Apr 2004 16:09:58 -0000 1.12 *************** *** 512,515 **** --- 512,518 ---- m->use_libusb=1; + if (m->fd) + return MPIO_OK; + #ifdef USE_KMODULE debugn(2, "trying kernel module\n"); *************** *** 550,553 **** --- 553,557 ---- { debugn(2, "Error claiming device: %d \"%s\"\n", ret, usb_strerror()); + usb_close(m->usb_handle); return MPIO_ERR_PERMISSION_DENIED; } else { *************** *** 555,559 **** } - interface = dev->config->interface->altsetting; --- 559,562 ---- *************** *** 573,578 **** --- 576,583 ---- } + m->fd=1; if (!(m->usb_in_ep && m->usb_out_ep)) { debugn(2, "Did not find USB bulk endpoints.\n"); + mpio_device_close(m); return MPIO_ERR_PERMISSION_DENIED; } *************** *** 584,588 **** } } ! return MPIO_ERR_PERMISSION_DENIED; } --- 589,595 ---- } } ! ! if (m->usb_handle) ! usb_close(m->usb_handle); return MPIO_ERR_PERMISSION_DENIED; } *************** *** 591,603 **** mpio_device_close(mpio_t *m) { if(m->use_libusb) { ! debugn(2, "closing libusb\n"); ! usb_close(m->usb_handle); ! m->fd=0; } #ifdef USE_KMODULE else { ! debugn(2, "closing kernel module\n"); ! close(m->fd); ! m->fd=0; } #endif --- 598,614 ---- mpio_device_close(mpio_t *m) { if(m->use_libusb) { ! if (m->fd) { ! debugn(2, "closing libusb\n"); ! usb_close(m->usb_handle); ! m->fd=0; ! } } #ifdef USE_KMODULE else { ! if (m->fd) { ! debugn(2, "closing kernel module\n"); ! close(m->fd); ! m->fd=0; ! } } #endif |