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 )
vista_use_package( JACK QUIET )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO ${VASIO_FOUND} CACHE BOOL "Build with ASIO support" )
if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
set( ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO ${VASIO_FOUND} CACHE BOOL "Build with ASIO support" )
endif( )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO ${VPORTAUDIO_FOUND} CACHE BOOL "Build with Portaudio support" )
if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
set( ITA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO ${VPORTAUDIO_FOUND} CACHE BOOL "Build with Portaudio support" )
endif( )
if( NOT DEFINED ITA_DATA_SOURCE_WITH_INTEGRATED_JACK )
set( ITA_DATA_SOURCE_WITH_INTEGRATED_JACK ${VJACK_FOUND} CACHE BOOL "Build with JACK2 support" )
if( NOT DEFINED ITA_DATA_SOURCES_WITH_INTEGRATED_JACK )
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( )
......@@ -40,14 +53,6 @@ set( ITADataSourcesHeader
"include/ITADataSourcesDefinitions.h"
"include/ITAFileDataSink.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/ITARMSDetector.h"
"include/ITAStreamAmplifier.h"
......@@ -67,13 +72,6 @@ set( ITADataSourcesSources
"src/ITADataSourceRealization.cpp"
"src/ITAFileDataSink.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/ITARMSDetector.cpp"
"src/ITAStreamAmplifier.cpp"
......@@ -94,27 +92,49 @@ if( WIN32 )
list( APPEND ITADataSourcesSources "src/ITAStreamPump.cpp" "src/ITADataSourceUtils.cpp" )
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 ITADataSourcesSources "src/ITAAsioInterface.cpp" )
add_definitions( -DIEEE754_64FLOAT=1 )
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 ITADataSourcesSources "src/ITAPortaudioInterface.cpp" )
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 ITADataSourcesSources "src/ITAJACKInterface.cpp" )
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
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTATOOLS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
if( BUILD_SHARED_LIBS )
add_definitions( -DITA_DATA_SOURCES_EXPORT )
else( )
......
......@@ -6,13 +6,13 @@ include( VistaCommon )
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" )
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" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
endif( TA_DATA_SOURCES_WITH_INTEGRATED_PORTAUDIO )
add_executable( ita_whad main.cpp )
target_link_libraries( ita_whad ${VISTA_USE_PACKAGE_LIBRARIES} )
......
......@@ -42,6 +42,8 @@ class VistaConnectionIP;
* Messages consist of a message part and an answer part, each read or written
* separately. Messages have a two-int-header (SIZE, MSGTYPE), and
* answers have a two-int header (SIZE; ANSWERTYPE)
*
* @todo move to src folder
*/
class ITA_DATA_SOURCES_API CITANetAudioMessage
{
......
......@@ -5,6 +5,8 @@
#include <VistaBase/VistaExceptionBase.h>
#include <cassert>
#include <iostream>
#include <iomanip>
static int S_nMessageIds = 0;
......@@ -44,6 +46,10 @@ void CITANetAudioMessage::ResetMessage()
m_nAnswerType = CITANetAudioProtocol::NP_INVALID;
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)
......@@ -78,27 +84,33 @@ void CITANetAudioMessage::WriteMessage()
VistaSerializingToolset::Swap4(&iSwapDummy);
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 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();
if (nRet != m_oOutgoing.GetBufferSize())
ITA_EXCEPT1(NETWORK_ERROR, "Could not write the expected number of bytes");
}
catch (VistaExceptionBase& ex)
{
ITA_EXCEPT1(NETWORK_ERROR, ex.GetExceptionText());
}
#ifdef NET_AUDIO_SHOW_TRAFFIC
std::cout << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ") OK" << std::endl;
#endif
}
void CITANetAudioMessage::ReadMessage()
{
try
{
std::cout << "CITANetAudioMessage [ Reading] init" << std::endl;
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
assert(nMessageSize >= 2 * sizeof(VistaType::sint32));
......@@ -107,29 +119,26 @@ void CITANetAudioMessage::ReadMessage()
m_vecIncomingBuffer.resize(nMessageSize);
nReturn = m_pConnection->ReadRawBuffer(&m_vecIncomingBuffer[0], nMessageSize);
if (nReturn != nMessageSize)
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_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()
{
#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::sint32 iSwapDummy;
......@@ -155,38 +164,28 @@ void CITANetAudioMessage::WriteAnswer()
VistaSerializingToolset::Swap4(&iSwapDummy);
memcpy(pBuffer, &iSwapDummy, sizeof(VistaType::sint32));
try
{
int nRet = m_pConnection->WriteRawBuffer(m_oOutgoing.GetBuffer(), m_oOutgoing.GetBufferSize());
m_pConnection->WaitForSendFinish();
if (nRet != m_oOutgoing.GetBufferSize())
ITA_EXCEPT1(UNKNOWN, "Could not write the expected number of bytes");
}
catch (VistaExceptionBase& ex)
{
ITA_EXCEPT1(UNKNOWN, ex.GetExceptionText());
}
}
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;
int nReturn;
try
{
nReturn = m_pConnection->ReadInt32(nMessageSize);
}
catch (...)
{
nReturn = -1; // Network connection error
}
if (nReturn != sizeof(VistaType::sint32))
{
ITA_EXCEPT1(UNKNOWN, "Protokoll error, Received less bytes than expected");
}
ITA_EXCEPT1(UNKNOWN, "Protokoll error, was expecting 4 bytes to read message size, but received " + std::to_string( nReturn ) );
// we need at least the two protocol types
assert(nMessageSize >= 2 * sizeof(VistaType::sint32));
......@@ -201,28 +200,16 @@ void CITANetAudioMessage::ReadAnswer()
m_oIncoming.SetBuffer(&m_vecIncomingBuffer[0], nReturn);
}
catch (VistaExceptionBase& ex)
//catch (VistaExceptionBase& ex)
{
// Probable connection loss
return;
ITA_EXCEPT1(UNKNOWN, ex.GetExceptionText());
}
catch (ITAException& ex)
{
std::string sErrorText = ex.ToString();
//ITA_EXCEPT1( UNKNOWN, ex.GetExceptionText() );
}
try
{
m_nAnswerType = ReadInt(); // TODO: assert weg, daf�r Kontrolle falls Server crasht<
m_nAnswerType = ReadInt();
int nMessageID = ReadInt();
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
# tests
if( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
if( ITA_DATA_SOURCES_WITH_INTEGRATED_ASIO )
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" )
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" )
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( "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