Index: /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
===================================================================
--- /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 940)
+++ /trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (revision 967)
@@ -292,4 +292,10 @@
}
+void
+IsoHandlerManager::requestShadowMapUpdate()
+{
+ if(m_IsoTask) m_IsoTask->requestShadowMapUpdate();
+}
+
bool
IsoHandlerManager::setThreadParameters(bool rt, int priority) {
Index: /trunk/libffado/src/libieee1394/IsoHandlerManager.h
===================================================================
--- /trunk/libffado/src/libieee1394/IsoHandlerManager.h (revision 938)
+++ /trunk/libffado/src/libieee1394/IsoHandlerManager.h (revision 967)
@@ -107,4 +107,5 @@
friend class Streaming::StreamProcessorManager;
friend class IsoTask;
+ friend class IsoHandler;
public:
@@ -151,4 +152,7 @@
Ieee1394Service& get1394Service() {return m_service;};
+ protected:
+ void requestShadowMapUpdate();
+
// the state machine
private:
Index: /trunk/libffado/src/libieee1394/IsoHandler.cpp
===================================================================
--- /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 930)
+++ /trunk/libffado/src/libieee1394/IsoHandler.cpp (revision 967)
@@ -353,4 +353,14 @@
raw1394_read(m_handle, raw1394_get_local_id(m_handle),
CSR_REGISTER_BASE | CSR_CYCLE_TIME, 4, &buf);
+
+ // notify the client of the fact that we have died
+ m_Client->handlerDied();
+
+ if(!disable()) {
+ debugError("(%p) Could not disable IsoHandler\n", this);
+ }
+
+ // request the manager to update it's shadow map
+ m_manager.requestShadowMapUpdate();
return 0;
}
Index: /trunk/libffado/src/ffadodevice.cpp
===================================================================
--- /trunk/libffado/src/ffadodevice.cpp (revision 958)
+++ /trunk/libffado/src/ffadodevice.cpp (revision 967)
@@ -142,4 +142,5 @@
FFADODevice::setId( unsigned int id)
{
+ m_DeviceMutex.Lock();
bool retval;
// FIXME: decent ID system nescessary
@@ -149,4 +150,5 @@
retval=setOption("id",idstr.str());
+ m_DeviceMutex.Unlock();
return retval;
}
@@ -156,10 +158,12 @@
{
debugOutput( DEBUG_LEVEL_VERBOSE, "Handle bus reset...\n");
-
+
// update the config rom node id
sleep(1);
+
+ m_DeviceMutex.Lock();
getConfigRom().setVerboseLevel(getDebugLevel());
getConfigRom().updatedNodeId();
-
+ m_DeviceMutex.Unlock();
}
@@ -169,4 +173,5 @@
debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
setDebugLevel(l);
+ m_DeviceMutex.setVerboseLevel(l);
getConfigRom().setVerboseLevel(l);
}
Index: /trunk/libffado/src/devicemanager.h
===================================================================
--- /trunk/libffado/src/devicemanager.h (revision 960)
+++ /trunk/libffado/src/devicemanager.h (revision 967)
@@ -72,4 +72,5 @@
eWR_Xrun,
eWR_Error,
+ eWR_Shutdown,
};
Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
===================================================================
--- /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 918)
+++ /trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (revision 967)
@@ -47,4 +47,5 @@
, m_nominal_framerate ( 0 )
, m_xruns(0)
+ , m_shutdown_needed(false)
, m_nbperiods(0)
{
@@ -61,4 +62,5 @@
, m_nominal_framerate ( framerate )
, m_xruns(0)
+ , m_shutdown_needed(false)
, m_nbperiods(0)
{
@@ -67,4 +69,35 @@
StreamProcessorManager::~StreamProcessorManager() {
+}
+
+void
+StreamProcessorManager::handleBusReset()
+{
+ debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) Handle bus reset...\n", this);
+
+ // FIXME: we request shutdown for now.
+ m_shutdown_needed=true;
+
+ // note that all receive streams are gone once a device is unplugged
+
+ // synchronize with the wait lock
+ m_WaitLock.Lock();
+
+ debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) got wait lock...\n", this);
+ // cause all SP's to bail out
+ for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();
+ it != m_ReceiveProcessors.end();
+ ++it )
+ {
+ (*it)->handleBusReset();
+ }
+ for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();
+ it != m_TransmitProcessors.end();
+ ++it )
+ {
+ (*it)->handleBusReset();
+ }
+
+ m_WaitLock.Unlock();
}
@@ -151,9 +184,10 @@
debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");
-
m_is_slave=false;
if(!getOption("slaveMode", m_is_slave)) {
debugWarning("Could not retrieve slaveMode parameter, defaulting to false\n");
}
+
+ m_shutdown_needed=false;
// if no sync source is set, select one here
@@ -692,4 +726,8 @@
bool start_result = false;
for (int ntries=0; ntries < STREAMPROCESSORMANAGER_SYNCSTART_TRIES; ntries++) {
+ if(m_shutdown_needed) {
+ debugOutput(DEBUG_LEVEL_VERBOSE, "Shutdown requested...\n");
+ return true;
+ }
// put all SP's into dry-running state
if (!startDryRunning()) {
@@ -722,10 +760,14 @@
* ready to be transferred.
*
- * @return true if the period is ready, false if an xrun occurred
+ * @return true if the period is ready, false if not
*/
bool StreamProcessorManager::waitForPeriod() {
if(m_SyncSource == NULL) return false;
+ if(m_shutdown_needed) return false;
bool xrun_occurred = false;
bool period_not_ready = true;
+
+ // grab the wait lock
+ m_WaitLock.Lock();
while(period_not_ready) {
@@ -778,4 +820,7 @@
if(xrun_occurred) break;
// FIXME: make sure we also exit this loop when something else happens (e.g. signal, iso error)
+
+ // if we have to shutdown due to some async event (busreset), do so
+ if(m_shutdown_needed) break;
}
@@ -861,4 +906,6 @@
m_nbperiods++;
+
+ m_WaitLock.Unlock();
// now we can signal the client that we are (should be) ready
return !xrun_occurred;
@@ -1033,4 +1080,5 @@
void StreamProcessorManager::setVerboseLevel(int l) {
setDebugLevel(l);
+ m_WaitLock.setVerboseLevel(l);
debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");
Index: /trunk/libffado/src/libstreaming/StreamProcessorManager.h
===================================================================
--- /trunk/libffado/src/libstreaming/StreamProcessorManager.h (revision 864)
+++ /trunk/libffado/src/libstreaming/StreamProcessorManager.h (revision 967)
@@ -30,4 +30,5 @@
#include "debugmodule/debugmodule.h"
#include "libutil/Thread.h"
+#include "libutil/PosixMutex.h"
#include "libutil/OptionContainer.h"
@@ -58,4 +59,6 @@
StreamProcessorManager(unsigned int period, unsigned int rate, unsigned int nb_buffers);
virtual ~StreamProcessorManager();
+
+ void handleBusReset();
bool prepare(); ///< to be called after the processors are registered
@@ -102,4 +105,5 @@
int getDelayedUsecs() {return m_delayed_usecs;};
bool xrunOccurred();
+ bool shutdownNeeded() {return m_shutdown_needed;};
int getXrunCount() {return m_xruns;};
@@ -151,6 +155,9 @@
unsigned int m_nominal_framerate;
unsigned int m_xruns;
+ bool m_shutdown_needed;
unsigned int m_nbperiods;
+
+ Util::PosixMutex m_WaitLock;
DECLARE_DEBUG_MODULE;
Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.h
===================================================================
--- /trunk/libffado/src/libstreaming/generic/StreamProcessor.h (revision 930)
+++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.h (revision 967)
@@ -73,5 +73,4 @@
ePS_Invalid,
ePS_Created,
- // ePS_WaitingToStop, FIXME: this will be needed for the MOTU's
ePS_Stopped,
ePS_WaitingForStream,
@@ -131,4 +130,6 @@
bool init();
bool prepare();
+
+ void handleBusReset();
public: // constructor/destructor
@@ -294,4 +295,5 @@
// move to private?
bool xrunOccurred() { return m_in_xrun; };
+ void handlerDied();
// the ISO interface (can we get rid of this?)
Index: /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
===================================================================
--- /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 938)
+++ /trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (revision 967)
@@ -98,4 +98,22 @@
if (m_data_buffer) delete m_data_buffer;
if (m_scratch_buffer) delete[] m_scratch_buffer;
+}
+
+void
+StreamProcessor::handleBusReset()
+{
+ debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) handling busreset\n", this);
+ // for now, we try and make sure everything is cleanly shutdown
+ if(!stopRunning(-1)) {
+ debugError("Failed to stop SP\n");
+ }
+ SIGNAL_ACTIVITY;
+}
+
+void StreamProcessor::handlerDied()
+{
+ debugWarning("Handler died for %p\n", this);
+ m_state = ePS_Stopped;
+ m_in_xrun = true;
}
@@ -1208,4 +1226,8 @@
bool StreamProcessor::startDryRunning(int64_t t) {
+ if(getState() == ePS_DryRunning) {
+ // already in the correct state
+ return true;
+ }
if(!scheduleStartDryRunning(t)) {
debugError("Could not schedule transition\n");
@@ -1220,4 +1242,8 @@
bool StreamProcessor::startRunning(int64_t t) {
+ if(getState() == ePS_Running) {
+ // already in the correct state
+ return true;
+ }
if(!scheduleStartRunning(t)) {
debugError("Could not schedule transition\n");
@@ -1232,4 +1258,8 @@
bool StreamProcessor::stopDryRunning(int64_t t) {
+ if(getState() == ePS_Stopped) {
+ // already in the correct state
+ return true;
+ }
if(!scheduleStopDryRunning(t)) {
debugError("Could not schedule transition\n");
@@ -1244,4 +1274,8 @@
bool StreamProcessor::stopRunning(int64_t t) {
+ if(getState() == ePS_DryRunning) {
+ // already in the correct state
+ return true;
+ }
if(!scheduleStopRunning(t)) {
debugError("Could not schedule transition\n");
Index: /trunk/libffado/src/ffadodevice.h
===================================================================
--- /trunk/libffado/src/ffadodevice.h (revision 958)
+++ /trunk/libffado/src/ffadodevice.h (revision 967)
@@ -27,4 +27,6 @@
#include "libutil/OptionContainer.h"
+#include "libutil/PosixMutex.h"
+
#include "libcontrol/BasicElements.h"
@@ -438,4 +440,5 @@
protected:
DECLARE_DEBUG_MODULE;
+ Util::PosixMutex m_DeviceMutex;
};
Index: /trunk/libffado/src/SConscript
===================================================================
--- /trunk/libffado/src/SConscript (revision 959)
+++ /trunk/libffado/src/SConscript (revision 967)
@@ -75,4 +75,5 @@
libutil/PacketBuffer.cpp \
libutil/OptionContainer.cpp \
+ libutil/PosixMutex.cpp \
libutil/PosixThread.cpp \
libutil/ringbuffer.c \
Index: /trunk/libffado/src/ffado.cpp
===================================================================
--- /trunk/libffado/src/ffado.cpp (revision 864)
+++ /trunk/libffado/src/ffado.cpp (revision 967)
@@ -251,6 +251,9 @@
xruns++;
return ffado_wait_xrun;
+ } else if (result == DeviceManager::eWR_Shutdown) {
+ debugWarning("Streaming system requests shutdown.\n");
+ return ffado_wait_shutdown;
} else {
- debugError("Unhandled XRUN (BUG)\n");
+ debugError("Error condition while waiting (Unhandled XRUN)\n");
xruns++;
return ffado_wait_error;
Index: /trunk/libffado/src/libutil/PosixMutex.h
===================================================================
--- /trunk/libffado/src/libutil/PosixMutex.h (revision 967)
+++ /trunk/libffado/src/libutil/PosixMutex.h (revision 967)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2005-2008 by Pieter Palmers
+ *
+ * This file is part of FFADO
+ * FFADO = Free Firewire (pro-)audio drivers for linux
+ *
+ * FFADO is based upon FreeBoB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifndef __POSIX_MUTEX__
+#define __POSIX_MUTEX__
+
+#include "Mutex.h"
+#include
+
+#include "debugmodule/debugmodule.h"
+
+namespace Util
+{
+
+/**
+ * @brief The POSIX mutex implementation.
+ */
+
+class PosixMutex : public Mutex
+{
+public:
+ PosixMutex();
+ virtual ~PosixMutex();
+
+ virtual void Lock();
+ virtual bool TryLock();
+ virtual void Unlock();
+
+ virtual void show();
+ virtual void setVerboseLevel(int l) {setDebugLevel(l);};
+
+protected:
+ DECLARE_DEBUG_MODULE;
+
+private:
+ pthread_mutex_t m_mutex;
+};
+
+} // end of namespace
+
+#endif
Index: /trunk/libffado/src/libutil/Mutex.h
===================================================================
--- /trunk/libffado/src/libutil/Mutex.h (revision 967)
+++ /trunk/libffado/src/libutil/Mutex.h (revision 967)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005-2008 by Pieter Palmers
+ *
+ * This file is part of FFADO
+ * FFADO = Free Firewire (pro-)audio drivers for linux
+ *
+ * FFADO is based upon FreeBoB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#ifndef __MUTEX__
+#define __MUTEX__
+
+namespace Util
+{
+
+/**
+ * @brief The mutex interface.
+ */
+
+class Mutex
+{
+public:
+ Mutex() {};
+ virtual ~Mutex() {};
+
+ virtual void Lock() = 0;
+ virtual bool TryLock() = 0;
+ virtual void Unlock() = 0;
+
+ virtual void show() = 0;
+};
+
+} // end of namespace
+
+#endif
Index: /trunk/libffado/src/libutil/PosixMutex.cpp
===================================================================
--- /trunk/libffado/src/libutil/PosixMutex.cpp (revision 967)
+++ /trunk/libffado/src/libutil/PosixMutex.cpp (revision 967)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2005-2008 by Pieter Palmers
+ *
+ * This file is part of FFADO
+ * FFADO = Free Firewire (pro-)audio drivers for linux
+ *
+ * FFADO is based upon FreeBoB
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#include "PosixMutex.h"
+
+namespace Util
+{
+
+IMPL_DEBUG_MODULE( PosixMutex, PosixMutex, DEBUG_LEVEL_NORMAL );
+
+PosixMutex::PosixMutex()
+{
+ pthread_mutexattr_t attr;
+ #ifdef DEBUG
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
+ #else
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
+ #endif
+ pthread_mutex_init(&m_mutex, &attr);
+}
+
+PosixMutex::~PosixMutex()
+{
+ pthread_mutex_destroy(&m_mutex);
+}
+
+void
+PosixMutex::Lock()
+{
+ debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) lock\n", this);
+ pthread_mutex_lock(&m_mutex);
+}
+
+bool
+PosixMutex::TryLock()
+{
+ debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) trying to lock\n", this);
+ return pthread_mutex_trylock(&m_mutex) == 0;
+}
+
+void
+PosixMutex::Unlock()
+{
+ debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) unlock\n", this);
+ pthread_mutex_unlock(&m_mutex);
+}
+
+void
+PosixMutex::show()
+{
+ debugOutput(DEBUG_LEVEL_NORMAL, "(%p) mutex\n", this);
+}
+
+
+} // end of namespace
Index: /trunk/libffado/src/genericavc/avc_avdevice.cpp
===================================================================
--- /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 864)
+++ /trunk/libffado/src/genericavc/avc_avdevice.cpp (revision 967)
@@ -98,4 +98,5 @@
AvDevice::discover()
{
+ m_DeviceMutex.Lock();
// check if we already have a valid VendorModel entry
// e.g. because a subclass called this function
@@ -110,4 +111,5 @@
if (!GenericAVC::VendorModel::isValid(m_model)) {
+ m_DeviceMutex.Unlock();
return false;
}
@@ -118,4 +120,5 @@
if ( !Unit::discover() ) {
debugError( "Could not discover unit\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -123,10 +126,13 @@
if((getAudioSubunit( 0 ) == NULL)) {
debugError( "Unit doesn't have an Audio subunit.\n");
+ m_DeviceMutex.Unlock();
return false;
}
if((getMusicSubunit( 0 ) == NULL)) {
debugError( "Unit doesn't have a Music subunit.\n");
- return false;
- }
+ m_DeviceMutex.Unlock();
+ return false;
+ }
+ m_DeviceMutex.Unlock();
return true;
@@ -136,4 +142,5 @@
AvDevice::setVerboseLevel(int l)
{
+ m_DeviceMutex.Lock();
setDebugLevel(l);
m_pPlugManager->setVerboseLevel(l);
@@ -141,4 +148,5 @@
AVC::Unit::setVerboseLevel(l);
debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
+ m_DeviceMutex.Unlock();
}
@@ -168,4 +176,5 @@
AvDevice::setSamplingFrequency( int s )
{
+ m_DeviceMutex.Lock();
bool snoopMode=false;
if(!getOption("snoopMode", snoopMode)) {
@@ -178,6 +187,8 @@
debugError("In snoop mode it is impossible to set the sample rate.\n");
debugError("Please start the client with the correct setting.\n");
- return false;
- }
+ m_DeviceMutex.Unlock();
+ return false;
+ }
+ m_DeviceMutex.Unlock();
return true;
} else {
@@ -185,4 +196,5 @@
if ( !plug ) {
debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -191,4 +203,5 @@
{
debugError( "setSampleRate: Setting sample rate failed\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -197,4 +210,5 @@
if ( !plug ) {
debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -203,4 +217,5 @@
{
debugError( "setSampleRate: Setting sample rate failed\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -209,7 +224,9 @@
"setSampleRate: Set sample rate to %d\n",
s );
+ m_DeviceMutex.Unlock();
return true;
}
// not executable
+ m_DeviceMutex.Unlock();
return false;
@@ -219,4 +236,6 @@
AvDevice::getSupportedClockSources() {
FFADODevice::ClockSourceVector r;
+
+ m_DeviceMutex.Lock();
PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType(
@@ -256,4 +275,5 @@
}
+ m_DeviceMutex.Unlock();
return r;
}
@@ -267,4 +287,5 @@
}
+ m_DeviceMutex.Lock();
for ( SyncInfoVector::const_iterator it
= getSyncInfos().begin();
@@ -275,7 +296,9 @@
if (si.m_source==src) {
+ m_DeviceMutex.Unlock();
return setActiveSync(si);
}
}
+ m_DeviceMutex.Unlock();
return false;
@@ -368,4 +391,5 @@
AvDevice::lock() {
bool snoopMode=false;
+ m_DeviceMutex.Lock();
if(!getOption("snoopMode", snoopMode)) {
debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
@@ -377,4 +401,5 @@
// return Unit::reserve(4);
}
+ m_DeviceMutex.Unlock();
return true;
@@ -384,4 +409,5 @@
AvDevice::unlock() {
bool snoopMode=false;
+ m_DeviceMutex.Lock();
if(!getOption("snoopMode", snoopMode)) {
debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
@@ -393,4 +419,5 @@
// return Unit::reserve(0);
}
+ m_DeviceMutex.Unlock();
return true;
}
@@ -408,4 +435,5 @@
AvDevice::prepare() {
bool snoopMode=false;
+ m_DeviceMutex.Lock();
if(!getOption("snoopMode", snoopMode)) {
debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
@@ -418,4 +446,5 @@
if ( !inputPlug ) {
debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -423,4 +452,5 @@
if ( !outputPlug ) {
debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );
+ m_DeviceMutex.Unlock();
return false;
}
@@ -432,4 +462,5 @@
if ( outputPlug->getNrOfChannels() == 0 ) {
debugError("Receive plug has no channels\n");
+ m_DeviceMutex.Unlock();
return false;
}
@@ -440,4 +471,5 @@
debugFatal("Could not initialize receive processor!\n");
delete p;
+ m_DeviceMutex.Unlock();
return false;
}
@@ -447,4 +479,5 @@
debugFatal("Could not add plug to processor!\n");
delete p;
+ m_DeviceMutex.Unlock();
return false;
}
@@ -468,4 +501,5 @@
(snoopMode?" in snoop mode":""));
delete p;
+ m_DeviceMutex.Unlock();
return false;
}
@@ -475,4 +509,5 @@
Streaming::Port::E_Capture)) {
debugFatal("Could not add plug to processor!\n");
+ m_DeviceMutex.Unlock();
return false;
}
@@ -481,4 +516,5 @@
Streaming::Port::E_Playback)) {
debugFatal("Could not add plug to processor!\n");
+ m_DeviceMutex.Unlock();
return false;
}
@@ -491,4 +527,5 @@
m_transmitProcessors.push_back(p);
+ m_DeviceMutex.Unlock();
return true;
}
@@ -592,5 +629,9 @@
int
AvDevice::getStreamCount() {
- return m_receiveProcessors.size() + m_transmitProcessors.size();
+ int retval;
+ m_DeviceMutex.Lock();
+ retval = m_receiveProcessors.size() + m_transmitProcessors.size();
+ m_DeviceMutex.Unlock();
+ return retval;
//return 1;
}
Index: /trunk/libffado/src/devicemanager.cpp
===================================================================
--- /trunk/libffado/src/devicemanager.cpp (revision 964)
+++ /trunk/libffado/src/devicemanager.cpp (revision 967)
@@ -225,4 +225,11 @@
{
(*it)->handleBusReset();
+ }
+
+ // notify the streamprocessormanager of the busreset
+ if(m_processorManager) {
+ m_processorManager->handleBusReset();
+ } else {
+ debugWarning("No valid SPM\n");
}
@@ -732,11 +739,16 @@
return eWR_OK;
} else {
- debugWarning("XRUN detected\n");
- // do xrun recovery
- if(m_processorManager->handleXrun()) {
- return eWR_Xrun;
+ if(m_processorManager->shutdownNeeded()) {
+ debugWarning("Shutdown requested\n");
+ return eWR_Shutdown;
} else {
- debugError("Could not handle XRUN\n");
- return eWR_Error;
+ debugWarning("XRUN detected\n");
+ // do xrun recovery
+ if(m_processorManager->handleXrun()) {
+ return eWR_Xrun;
+ } else {
+ debugError("Could not handle XRUN\n");
+ return eWR_Error;
+ }
}
}
Index: /trunk/libffado/libffado/ffado.h
===================================================================
--- /trunk/libffado/libffado/ffado.h (revision 864)
+++ /trunk/libffado/libffado/ffado.h (revision 967)
@@ -222,4 +222,5 @@
*/
typedef enum {
+ ffado_wait_shutdown = -3,
ffado_wait_error = -2,
ffado_wait_xrun = -1,
Index: /trunk/libffado/SConstruct
===================================================================
--- /trunk/libffado/SConstruct (revision 948)
+++ /trunk/libffado/SConstruct (revision 967)
@@ -24,6 +24,6 @@
#
-FFADO_API_VERSION="7"
-FFADO_VERSION="1.999.16"
+FFADO_API_VERSION="8"
+FFADO_VERSION="1.999.17"
import os