Commit 808c512c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Improving CMake configuration, fixing some naming inconsistencies

parent 3bbfc4dc
...@@ -14,16 +14,29 @@ vista_use_package( Portaudio QUIET ) ...@@ -14,16 +14,29 @@ vista_use_package( Portaudio QUIET )
vista_use_package( JACK QUIET ) vista_use_package( JACK QUIET )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ${VASIO_FOUND} CACHE BOOL "Build with ASIO support" ) set( ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO ${VASIO_FOUND} CACHE BOOL "Build with ASIO support" )
endif( ) endif( )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ${VPORTAUDIO_FOUND} CACHE BOOL "Build with Portaudio support" ) set( ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO ${VPORTAUDIO_FOUND} CACHE BOOL "Build with Portaudio support" )
endif( ) endif( )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ) if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_JACK )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ${VJACK_FOUND} CACHE BOOL "Build with JACK2 support" ) set( ITA_DATA_SOURCES_WITH_INTEGRATED_JACK ${VJACK_FOUND} CACHE BOOL "Build with JACK2 support" )
endif( )
if( NOT DEFINED ITA_DATA_SOURCES_WITH_NET_AUDIO )
set( ITA_DATA_SOURCES_WITH_NET_AUDIO ON CACHE BOOL "Build with NetAudio support" )
endif( )
if( NOT DEFINED ITA_DATA_SOURCES_NET_AUDIO_SHOW_TRAFFIC )
set( ITA_DATA_SOURCES_NET_AUDIO_SHOW_TRAFFIC OFF CACHE BOOL "Show a lot of traffic information with NetAudio (debugging only)" )
mark_as_advanced( ITA_DATA_SOURCES_NET_AUDIO_SHOW_TRAFFIC )
endif( )
if( ITA_DATA_SOURCES_NET_AUDIO_SHOW_TRAFFIC )
add_definitions( -DNET_AUDIO_SHOW_TRAFFIC )
endif( ) endif( )
...@@ -40,14 +53,6 @@ set( ITADataSourcesHeader ...@@ -40,14 +53,6 @@ set( ITADataSourcesHeader
"include/ITADataSourcesDefinitions.h" "include/ITADataSourcesDefinitions.h"
"include/ITAFileDataSink.h" "include/ITAFileDataSink.h"
"include/ITAFileDataSource.h" "include/ITAFileDataSource.h"
"include/ITANetAudioClient.h"
"include/ITANetAudioMessage.h"
"include/ITANetAudioProtocol.h"
"include/ITANetAudioServer.h"
"include/ITANetAudioStream.h"
"include/ITANetAudioStreamingClient.h"
"include/ITANetAudioStreamingServer.h"
"include/ITANetAudioStreamingClient.h"
"include/ITAPeakDetector.h" "include/ITAPeakDetector.h"
"include/ITARMSDetector.h" "include/ITARMSDetector.h"
"include/ITAStreamAmplifier.h" "include/ITAStreamAmplifier.h"
...@@ -67,13 +72,6 @@ set( ITADataSourcesSources ...@@ -67,13 +72,6 @@ set( ITADataSourcesSources
"src/ITADataSourceRealization.cpp" "src/ITADataSourceRealization.cpp"
"src/ITAFileDataSink.cpp" "src/ITAFileDataSink.cpp"
"src/ITAFileDataSource.cpp" "src/ITAFileDataSource.cpp"
"src/ITANetAudioClient.cpp"
"src/ITANetAudioMessage.cpp"
"src/ITANetAudioProtocol.cpp"
"src/ITANetAudioStream.cpp"
"src/ITANetAudioStreamingClient.cpp"
"src/ITANetAudioStreamingServer.cpp"
"src/ITANetAudioServer.cpp"
"src/ITAPeakDetector.cpp" "src/ITAPeakDetector.cpp"
"src/ITARMSDetector.cpp" "src/ITARMSDetector.cpp"
"src/ITAStreamAmplifier.cpp" "src/ITAStreamAmplifier.cpp"
...@@ -94,27 +92,49 @@ if( WIN32 ) ...@@ -94,27 +92,49 @@ if( WIN32 )
list( APPEND ITADataSourcesSources "src/ITAStreamPump.cpp" "src/ITADataSourceUtils.cpp" ) list( APPEND ITADataSourcesSources "src/ITAStreamPump.cpp" "src/ITADataSourceUtils.cpp" )
endif( ) endif( )
if( VASIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) if( VASIO_FOUND AND ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
list( APPEND ITADataSourcesHeader "include/ITAAsioInterface.h" ) list( APPEND ITADataSourcesHeader "include/ITAAsioInterface.h" )
list( APPEND ITADataSourcesSources "src/ITAAsioInterface.cpp" ) list( APPEND ITADataSourcesSources "src/ITAAsioInterface.cpp" )
add_definitions( -DIEEE754_64FLOAT=1 ) add_definitions( -DIEEE754_64FLOAT=1 )
endif( ) endif( )
if( VPORTAUDIO_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) if( VPORTAUDIO_FOUND AND ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
list( APPEND ITADataSourcesHeader "include/ITAPortaudioInterface.h" ) list( APPEND ITADataSourcesHeader "include/ITAPortaudioInterface.h" )
list( APPEND ITADataSourcesSources "src/ITAPortaudioInterface.cpp" ) list( APPEND ITADataSourcesSources "src/ITAPortaudioInterface.cpp" )
endif( ) endif( )
if( VJACK_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ) if( VJACK_FOUND AND ITA_DATA_SOURCES_WITH_INTEGRATED_JACK )
list( APPEND ITADataSourcesHeader "include/ITAJACKInterface.h" ) list( APPEND ITADataSourcesHeader "include/ITAJACKInterface.h" )
list( APPEND ITADataSourcesSources "src/ITAJACKInterface.cpp" ) list( APPEND ITADataSourcesSources "src/ITAJACKInterface.cpp" )
endif( ) endif( )
if( ITA_DATA_SOURCES_WITH_NET_AUDIO )
list( APPEND ITADataSourcesHeader
"include/ITANetAudioClient.h"
"include/ITANetAudioMessage.h"
"include/ITANetAudioProtocol.h"
"include/ITANetAudioServer.h"
"include/ITANetAudioStream.h"
"include/ITANetAudioStreamingClient.h"
"include/ITANetAudioStreamingServer.h"
"include/ITANetAudioStreamingClient.h"
)
list( APPEND ITADataSourcesSources
"src/ITANetAudioClient.cpp"
"src/ITANetAudioMessage.cpp"
"src/ITANetAudioProtocol.cpp"
"src/ITANetAudioStream.cpp"
"src/ITANetAudioStreamingClient.cpp"
"src/ITANetAudioStreamingServer.cpp"
"src/ITANetAudioServer.cpp"
)
endif( )
# compiler settings # compiler settings
if( ITA_VISTA_BUILD_STATIC ) if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC ) add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( ) endif( )
if( BUILD_SHARED_LIBS ) if( BUILD_SHARED_LIBS )
add_definitions( -DITA_DATA_SOURCES_EXPORT ) add_definitions( -DITA_DATA_SOURCES_EXPORT )
else( ) else( )
......
...@@ -6,13 +6,13 @@ include( VistaCommon ) ...@@ -6,13 +6,13 @@ include( VistaCommon )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES ) vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) if( TA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
add_definitions( "-DITA_WHAD_WITH_ASIO" ) add_definitions( "-DITA_WHAD_WITH_ASIO" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) endif( TA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) if( TA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
add_definitions( "-DITA_WHAD_WITH_PORTAUDIO" ) add_definitions( "-DITA_WHAD_WITH_PORTAUDIO" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) endif( TA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
add_executable( ita_whad main.cpp ) add_executable( ita_whad main.cpp )
target_link_libraries( ita_whad ${VISTA_USE_PACKAGE_LIBRARIES} ) target_link_libraries( ita_whad ${VISTA_USE_PACKAGE_LIBRARIES} )
......
...@@ -42,6 +42,8 @@ class VistaConnectionIP; ...@@ -42,6 +42,8 @@ class VistaConnectionIP;
* Messages consist of a message part and an answer part, each read or written * Messages consist of a message part and an answer part, each read or written
* separately. Messages have a two-int-header (SIZE, MSGTYPE), and * separately. Messages have a two-int-header (SIZE, MSGTYPE), and
* answers have a two-int header (SIZE; ANSWERTYPE) * answers have a two-int header (SIZE; ANSWERTYPE)
*
* @todo move to src folder
*/ */
class ITA_DATA_SOURCES_API CITANetAudioMessage class ITA_DATA_SOURCES_API CITANetAudioMessage
{ {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <VistaBase/VistaExceptionBase.h> #include <VistaBase/VistaExceptionBase.h>
#include <cassert> #include <cassert>
#include <iostream>
#include <iomanip>
static int S_nMessageIds = 0; static int S_nMessageIds = 0;
...@@ -44,6 +46,10 @@ void CITANetAudioMessage::ResetMessage() ...@@ -44,6 +46,10 @@ void CITANetAudioMessage::ResetMessage()
m_nAnswerType = CITANetAudioProtocol::NP_INVALID; m_nAnswerType = CITANetAudioProtocol::NP_INVALID;
m_pConnection = NULL; m_pConnection = NULL;
#ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [Preparing] (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
} }
void CITANetAudioMessage::SetConnection(VistaConnectionIP* pConn) void CITANetAudioMessage::SetConnection(VistaConnectionIP* pConn)
...@@ -78,58 +84,61 @@ void CITANetAudioMessage::WriteMessage() ...@@ -78,58 +84,61 @@ void CITANetAudioMessage::WriteMessage()
VistaSerializingToolset::Swap4(&iSwapDummy); VistaSerializingToolset::Swap4(&iSwapDummy);
memcpy(pBuffer, &iSwapDummy, sizeof(VistaType::sint32)); memcpy(pBuffer, &iSwapDummy, sizeof(VistaType::sint32));
try #ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
//try
{ {
int iRawBufferSize = m_oOutgoing.GetBufferSize(); int iRawBufferSize = m_oOutgoing.GetBufferSize();
int nRet = m_pConnection->WriteRawBuffer(m_oOutgoing.GetBuffer(), iRawBufferSize); int nRet = m_pConnection->WriteRawBuffer( m_oOutgoing.GetBuffer(), iRawBufferSize );
std::cout << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ") RAW BUFFER DONE" << std::endl;
m_pConnection->WaitForSendFinish(); m_pConnection->WaitForSendFinish();
if (nRet != m_oOutgoing.GetBufferSize()) if (nRet != m_oOutgoing.GetBufferSize())
ITA_EXCEPT1(NETWORK_ERROR, "Could not write the expected number of bytes"); ITA_EXCEPT1(NETWORK_ERROR, "Could not write the expected number of bytes");
} }
catch (VistaExceptionBase& ex)
{ #ifdef NET_AUDIO_SHOW_TRAFFIC
ITA_EXCEPT1(NETWORK_ERROR, ex.GetExceptionText()); std::cout << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ") OK" << std::endl;
} #endif
} }
void CITANetAudioMessage::ReadMessage() void CITANetAudioMessage::ReadMessage()
{ {
try std::cout << "CITANetAudioMessage [ Reading] init" << std::endl;
{
VistaType::sint32 nMessageSize; VistaType::sint32 nMessageSize;
int nReturn = m_pConnection->ReadInt32(nMessageSize); int nReturn = m_pConnection->ReadInt32( nMessageSize );
std::cout << "CITANetAudioMessage [ Reading] size " << nMessageSize << std::endl;
// we need at least the two protocol ints // we need at least the two protocol ints
assert(nMessageSize >= 2 * sizeof(VistaType::sint32)); assert(nMessageSize >= 2 * sizeof(VistaType::sint32));
if (nMessageSize > (int)m_vecIncomingBuffer.size()) if (nMessageSize > (int)m_vecIncomingBuffer.size())
m_vecIncomingBuffer.resize(nMessageSize); m_vecIncomingBuffer.resize(nMessageSize);
nReturn = m_pConnection->ReadRawBuffer(&m_vecIncomingBuffer[0], nMessageSize); nReturn = m_pConnection->ReadRawBuffer(&m_vecIncomingBuffer[0], nMessageSize);
if (nReturn != nMessageSize) m_oIncoming.SetBuffer(&m_vecIncomingBuffer[0], nReturn);
ITA_EXCEPT1(NETWORK_ERROR, "Protokoll error, Received less bytes than expected");
m_oIncoming.SetBuffer(&m_vecIncomingBuffer[0], nReturn);
// DEBUG: std::cout << "Remainign Size after Mesage Read: " << m_pConnection->PendingDataSize() << std::endl;
}
catch (VistaExceptionBase& ex)
{
ITA_EXCEPT1(UNKNOWN, ex.GetExceptionText());
}
catch (ITAException& ex)
{
ex;
}
m_nMessageType = ReadInt(); m_nMessageType = ReadInt();
m_nMessageId = ReadInt(); m_nMessageId = ReadInt();
}
#ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [ Reading] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
}
void CITANetAudioMessage::WriteAnswer() void CITANetAudioMessage::WriteAnswer()
{ {
#ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [ Answering] to " << m_nMessageType << " with " << m_nAnswerType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
#endif
assert( m_nAnswerType != CITANetAudioProtocol::NP_INVALID );
VistaType::byte* pBuffer = (VistaType::byte*)m_oOutgoing.GetBuffer(); VistaType::byte* pBuffer = (VistaType::byte*)m_oOutgoing.GetBuffer();
VistaType::sint32 iSwapDummy; VistaType::sint32 iSwapDummy;
...@@ -155,38 +164,28 @@ void CITANetAudioMessage::WriteAnswer() ...@@ -155,38 +164,28 @@ void CITANetAudioMessage::WriteAnswer()
VistaSerializingToolset::Swap4(&iSwapDummy); VistaSerializingToolset::Swap4(&iSwapDummy);
memcpy(pBuffer, &iSwapDummy, sizeof(VistaType::sint32)); memcpy(pBuffer, &iSwapDummy, sizeof(VistaType::sint32));
try
{ {
int nRet = m_pConnection->WriteRawBuffer(m_oOutgoing.GetBuffer(), m_oOutgoing.GetBufferSize()); int nRet = m_pConnection->WriteRawBuffer(m_oOutgoing.GetBuffer(), m_oOutgoing.GetBufferSize());
m_pConnection->WaitForSendFinish(); m_pConnection->WaitForSendFinish();
if (nRet != m_oOutgoing.GetBufferSize()) if (nRet != m_oOutgoing.GetBufferSize())
ITA_EXCEPT1(UNKNOWN, "Could not write the expected number of bytes"); ITA_EXCEPT1(UNKNOWN, "Could not write the expected number of bytes");
} }
catch (VistaExceptionBase& ex)
{
ITA_EXCEPT1(UNKNOWN, ex.GetExceptionText());
}
} }
void CITANetAudioMessage::ReadAnswer() void CITANetAudioMessage::ReadAnswer()
{ {
try #ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [ Reading] yet unkown answer from message " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ") OK" << std::endl;
#endif
//try
{ {
VistaType::sint32 nMessageSize; VistaType::sint32 nMessageSize;
int nReturn; int nReturn;
try nReturn = m_pConnection->ReadInt32(nMessageSize);
{
nReturn = m_pConnection->ReadInt32(nMessageSize);
}
catch (...)
{
nReturn = -1; // Network connection error
}
if (nReturn != sizeof(VistaType::sint32)) if (nReturn != sizeof(VistaType::sint32))
{ ITA_EXCEPT1(UNKNOWN, "Protokoll error, was expecting 4 bytes to read message size, but received " + std::to_string( nReturn ) );
ITA_EXCEPT1(UNKNOWN, "Protokoll error, Received less bytes than expected");
}
// we need at least the two protocol types // we need at least the two protocol types
assert(nMessageSize >= 2 * sizeof(VistaType::sint32)); assert(nMessageSize >= 2 * sizeof(VistaType::sint32));
...@@ -201,28 +200,16 @@ void CITANetAudioMessage::ReadAnswer() ...@@ -201,28 +200,16 @@ void CITANetAudioMessage::ReadAnswer()
m_oIncoming.SetBuffer(&m_vecIncomingBuffer[0], nReturn); m_oIncoming.SetBuffer(&m_vecIncomingBuffer[0], nReturn);
} }
catch (VistaExceptionBase& ex) //catch (VistaExceptionBase& ex)
{ {
// Probable connection loss // Probable connection loss
return; //ITA_EXCEPT1( UNKNOWN, ex.GetExceptionText() );
ITA_EXCEPT1(UNKNOWN, ex.GetExceptionText());
}
catch (ITAException& ex)
{
std::string sErrorText = ex.ToString();
} }
try m_nAnswerType = ReadInt();
{ int nMessageID = ReadInt();
m_nAnswerType = ReadInt(); // TODO: assert weg, daf�r Kontrolle falls Server crasht< assert(nMessageID == m_nMessageId);
int nMessageID = ReadInt(); m_nMessageId = nMessageID;
assert(nMessageID == m_nMessageId);
m_nMessageId = nMessageID;
}
catch (ITAException& ex)
{
std::cerr << "ITANetAudioMessage: Protocol error: " << ex << std::endl;
}
} }
......
...@@ -115,17 +115,17 @@ set_property( TARGET StreamProbeTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataS ...@@ -115,17 +115,17 @@ set_property( TARGET StreamProbeTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADataS
# tests # tests
if( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) if( ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
add_subdirectory( ITAAsioTests ) add_subdirectory( ITAAsioTests )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ) endif( ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) if( ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
add_subdirectory( "ITAPortaudioTests" ) add_subdirectory( "ITAPortaudioTests" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ) endif( ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
if( VJACK_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ) if( VJACK_FOUND AND ITA_DATA_SOURCES_WITH_INTEGRATED_JACK )
add_subdirectory( "ITAJACKTests" ) add_subdirectory( "ITAJACKTests" )
endif( VJACK_FOUND AND ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ) endif( VJACK_FOUND AND ITA_DATA_SOURCES_WITH_INTEGRATED_JACK )
add_subdirectory( "NetAudio" ) add_subdirectory( "NetAudio" )
add_subdirectory( "VistaNetTest" ) add_subdirectory( "VistaNetTest" )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment