Index: /branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp =================================================================== --- /branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 809) +++ /branches/api-cleanup/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 811) @@ -656,5 +656,5 @@ debugError("bad type: %d\n", p->getDataType()); return -1; - case Port::E_Midi: + case Port::E_MidiEvent: { quadlet_t *buffer = (quadlet_t *)(p->getBufferAddress()); @@ -734,7 +734,6 @@ debugError("bad type: %d\n", p->getDataType()); return -1; - case Port::E_Midi: - { - assert(nevents + offset <= p->getBufferSize()); + case Port::E_MidiEvent: + { for ( j = location; j < nevents; j += 8 ) { Index: /branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp =================================================================== --- /branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 809) +++ /branches/api-cleanup/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 811) @@ -421,6 +421,6 @@ sample_int=(sample_int >> 16) & 0x000000FF; sample_int |= 0x01000000; // flag that there is a midi event present + *buffer = sample_int; } - *buffer = sample_int; buffer += 8; // skip 8 frames } Index: /branches/api-cleanup/src/libstreaming/generic/PortManager.cpp =================================================================== --- /branches/api-cleanup/src/libstreaming/generic/PortManager.cpp (revision 809) +++ /branches/api-cleanup/src/libstreaming/generic/PortManager.cpp (revision 811) @@ -40,4 +40,5 @@ PortManager::~PortManager() { + flushDebugOutput(); // delete all ports that are still registered to the manager for ( PortVectorIterator it = m_Ports.begin(); @@ -45,5 +46,7 @@ ++it ) { - delete *it; + debugOutput( DEBUG_LEVEL_VERBOSE, "deleting port %s at %p\n", (*it)->getName().c_str(), *it); + flushDebugOutput(); + delete *it; //FIXME } } @@ -104,5 +107,5 @@ { assert(port); - debugOutput( DEBUG_LEVEL_VERBOSE, "deleting port %s\n",port->getName().c_str()); + debugOutput( DEBUG_LEVEL_VERBOSE, "unregistering port %s\n",port->getName().c_str()); for ( PortVectorIterator it = m_Ports.begin(); Index: /branches/api-cleanup/src/libstreaming/generic/Port.cpp =================================================================== --- /branches/api-cleanup/src/libstreaming/generic/Port.cpp (revision 809) +++ /branches/api-cleanup/src/libstreaming/generic/Port.cpp (revision 811) @@ -49,4 +49,5 @@ Port::~Port() { + debugOutput( DEBUG_LEVEL_VERBOSE, "deleting port %s\n", getName().c_str()); m_manager.unregisterPort(this); } @@ -66,6 +67,11 @@ } - if (m_buffersize==0) { + if (m_buffersize == 0) { debugFatal("Cannot initialize a port with buffersize=0\n"); + return false; + } + + if (m_buffer == NULL) { + debugFatal("Cannot initialize a port with no attached buffer\n"); return false; } Index: /branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp =================================================================== --- /branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp (revision 809) +++ /branches/api-cleanup/src/libstreaming/generic/StreamProcessor.cpp (revision 811) @@ -88,8 +88,10 @@ debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister stream processor with the Iso manager\n"); } + sem_destroy(&m_signal_semaphore); + + // FIXME: how do we ensure that nobody is using us? if (m_data_buffer) delete m_data_buffer; if (m_scratch_buffer) delete[] m_scratch_buffer; - sem_destroy(&m_signal_semaphore); } Index: /branches/api-cleanup/src/ffado.cpp =================================================================== --- /branches/api-cleanup/src/ffado.cpp (revision 809) +++ /branches/api-cleanup/src/ffado.cpp (revision 811) @@ -184,5 +184,5 @@ if(!dev->m_deviceManager->prepareStreaming()) { debugFatal("Could not prepare the streaming system\n"); - return 0; + return -1; } return 0; @@ -405,18 +405,18 @@ int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int i, char *buff) { - Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); - // use an assert here performancewise, - // it should already have failed before, if not correct - assert(p); - p->setBufferAddress((void *)buff); - return 0; + Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Capture); + // use an assert here performancewise, + // it should already have failed before, if not correct + assert(p); + p->setBufferAddress((void *)buff); + return 0; } int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int i, char *buff) { - Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); - // use an assert here performancewise, - // it should already have failed before, if not correct - assert(p); - p->setBufferAddress((void *)buff); - return 0; -} + Streaming::Port *p = dev->m_deviceManager->getStreamProcessorManager().getPortByIndex(i, Streaming::Port::E_Playback); + // use an assert here performancewise, + // it should already have failed before, if not correct + assert(p); + p->setBufferAddress((void *)buff); + return 0; +} Index: /branches/api-cleanup/tests/streaming/teststreaming3.cpp =================================================================== --- /branches/api-cleanup/tests/streaming/teststreaming3.cpp (revision 809) +++ /branches/api-cleanup/tests/streaming/teststreaming3.cpp (revision 811) @@ -354,4 +354,5 @@ case ffado_stream_type_midi: ffado_streaming_set_playback_buffer_type(dev, i, ffado_buffer_type_midi); + ffado_streaming_set_playback_stream_buffer(dev, i, (char *)(audiobuffers_out[i])); ffado_streaming_playback_stream_onoff(dev, i, 0); default: @@ -391,5 +392,9 @@ // start the streaming layer - ffado_streaming_prepare(dev); + if (ffado_streaming_prepare(dev)) { + debugFatal("Could not prepare streaming system\n"); + ffado_streaming_finish(dev); + return -1; + } start_flag = ffado_streaming_start(dev); @@ -435,6 +440,6 @@ uint32_t midievent = *(midibuffer + idx); if(midievent & 0xFF000000) { - debugOutput(DEBUG_LEVEL_NORMAL, " Received midi event %08X on idx %d of period %d\n", - midievent, idx, nb_periods); + debugOutput(DEBUG_LEVEL_NORMAL, " Received midi event %08X at idx %d of period %d on port %d\n", + midievent, idx, nb_periods, i); } }