Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITADataSources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITADataSources
Commits
7a5b48e0
Commit
7a5b48e0
authored
Jan 24, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intermediate update, trying to fix network error
parent
9099bdd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
48 deletions
+48
-48
src/ITADataSourceUtils.cpp
src/ITADataSourceUtils.cpp
+11
-8
src/ITANetAudioMessage.cpp
src/ITANetAudioMessage.cpp
+30
-34
src/ITANetAudioStream.cpp
src/ITANetAudioStream.cpp
+5
-5
src/ITAStreamPatchBay.cpp
src/ITAStreamPatchBay.cpp
+2
-1
No files found.
src/ITADataSourceUtils.cpp
View file @
7a5b48e0
...
...
@@ -71,15 +71,18 @@ void WriteFromDatasourceToBuffer(ITADatasource* pSource,
unsigned
int
k
=
(
uiNumberOfSamples
-
n
);
if
(
k
>
uiBlocklength
)
k
=
uiBlocklength
;
if
(
!
pfData
)
// Stille einfgen
for
(
unsigned
int
j
=
0
;
j
<
uiBlocklength
;
j
++
)
ppfDest
[
i
][
n
+
j
]
=
0
;
else
{
if
(
dGain
=
1.0
)
memcpy
(
ppfDest
[
i
]
+
n
,
pfData
,
k
*
sizeof
(
float
));
if
(
!
pfData
)
{
// Stille einfgen
for
(
unsigned
int
j
=
0
;
j
<
uiBlocklength
;
j
++
)
ppfDest
[
i
][
n
+
j
]
=
0
;
}
else
{
if
(
dGain
==
1.0
f
)
memcpy
(
ppfDest
[
i
]
+
n
,
pfData
,
k
*
sizeof
(
float
)
);
else
for
(
unsigned
int
j
=
0
;
j
<
k
;
j
++
)
ppfDest
[
i
][
n
+
j
]
=
(
float
)
((
double
)
pfData
[
j
]
*
dGain
);
for
(
unsigned
int
j
=
0
;
j
<
k
;
j
++
)
ppfDest
[
i
][
n
+
j
]
=
(
float
)
(
(
double
)
pfData
[
j
]
*
dGain
);
}
}
...
...
src/ITANetAudioMessage.cpp
View file @
7a5b48e0
...
...
@@ -111,45 +111,35 @@ void CITANetAudioMessage::WriteMessage()
void
CITANetAudioMessage
::
ReadMessage
()
{
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading ] Waiting for incoming data"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading ] Waiting for incoming data"
<<
std
::
endl
;
#endif
long
nIncomingBytes
=
m_pConnection
->
WaitForIncomingData
(
0
);
assert
(
nIncomingBytes
>=
4
);
// we need at least the size of message
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading ] "
<<
nIncomingBytes
<<
" bytes incoming"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading ] "
<<
nIncomingBytes
<<
" bytes incoming"
<<
std
::
endl
;
#endif
VistaType
::
sint32
nMessagePayloadSize
;
int
nBytesRead
=
m_pConnection
->
ReadInt32
(
nMessagePayloadSize
);
assert
(
nBytesRead
==
sizeof
(
VistaType
::
sint32
)
);
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading ] Expecting "
<<
nMessagePayloadSize
<<
" bytes message payload"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading ] Expecting "
<<
nMessagePayloadSize
<<
" bytes message payload"
<<
std
::
endl
;
#endif
// we need at least the two protocol ints
assert
(
nMessagePayloadSize
>=
2
*
sizeof
(
VistaType
::
sint32
)
);
if
(
nMessagePayloadSize
>
(
int
)
m_vecIncomingBuffer
.
size
()
)
m_vecIncomingBuffer
.
resize
(
nMessagePayloadSize
);
/*
int iBytesReceivedTotal = 0;
while( iPayloadDataSize != iBytesReceivedTotal )
{
long nIncomingBytes = pSocket->WaitForIncomingData( 0 );
int iBytesReceived = pSocket->ReceiveRaw( &vdIncomingData[ iBytesReceivedTotal ], nIncomingBytes );
iBytesReceivedTotal += iBytesReceived;
vstr::out() << "[ Server ] " << setw( 3 ) << std::floor( iBytesReceivedTotal / float( iPayloadDataSize ) * 100.0f ) << "% transmitted" << endl;
}
*/
// Receive all incoming data (potentially splitted)
int
iBytesReceivedTotal
=
0
;
while
(
nMessagePayloadSize
!=
iBytesReceivedTotal
)
{
int
iIncommingBytes
=
m_pConnection
->
WaitForIncomingData
(
0
);
int
iBytesReceived
=
m_pConnection
->
Receive
(
&
m_vecIncomingBuffer
[
iBytesReceivedTotal
],
iIncommingBytes
);
iBytesReceivedTotal
+=
iBytesReceived
;
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading ] Further "
<<
std
::
setw
(
3
)
<<
iBytesReceivedTotal
<<
"
transmitted"
<<
std
::
endl
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ CITANetAudioMessage ] "
<<
std
::
setw
(
3
)
<<
std
::
floor
(
iBytesReceivedTotal
/
float
(
nMessagePayloadSize
)
*
100.0
f
)
<<
"%
transmitted"
<<
std
::
endl
;
#endif
}
...
...
@@ -159,7 +149,7 @@ void CITANetAudioMessage::ReadMessage()
m_nMessageId
=
ReadInt
();
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading ] Finished receiving "
<<
m_nMessageType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
")"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading ] Finished receiving "
<<
m_nMessageType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
")"
<<
std
::
endl
;
#endif
}
...
...
@@ -167,7 +157,7 @@ void CITANetAudioMessage::WriteAnswer()
{
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Answering] to "
<<
m_nMessageType
<<
" with "
<<
m_nAnswerType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
")"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Answering] to "
<<
m_nMessageType
<<
" with "
<<
m_nAnswerType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
")"
<<
std
::
endl
;
#endif
assert
(
m_nAnswerType
!=
CITANetAudioProtocol
::
NP_INVALID
);
...
...
@@ -208,40 +198,46 @@ void CITANetAudioMessage::ReadAnswer()
{
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading] yet unkown answer from message "
<<
m_nMessageType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
") OK"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading] yet unkown answer from message "
<<
m_nMessageType
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
") OK"
<<
std
::
endl
;
#endif
VistaType
::
sint32
nMessageSize
;
VistaType
::
sint32
nMessage
Payload
Size
;
int
nReturn
;
nReturn
=
m_pConnection
->
ReadInt32
(
nMessageSize
);
nReturn
=
m_pConnection
->
ReadInt32
(
nMessage
Payload
Size
);
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading] 1. return is "
<<
nReturn
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
") OK"
<<
std
::
endl
;
vstr
::
out
()
<<
"CITANetAudioMessage [ Reading] 1. return is "
<<
nReturn
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
") OK"
<<
std
::
endl
;
#endif
if
(
nReturn
!=
sizeof
(
VistaType
::
sint32
)
)
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
)
);
assert
(
nMessage
Payload
Size
>=
2
*
sizeof
(
VistaType
::
sint32
)
);
if
(
nMessageSize
>
(
int
)
m_vecIncomingBuffer
.
size
()
)
m_vecIncomingBuffer
.
resize
(
nMessageSize
);
if
(
nMessage
Payload
Size
>
(
int
)
m_vecIncomingBuffer
.
size
()
)
m_vecIncomingBuffer
.
resize
(
nMessage
Payload
Size
);
// @todo: read over while( received < total ) loop!!!
// jst: hier nicht while( nReturn < nMessageSize) ReadRawBuffer??
nReturn
=
m_pConnection
->
ReadRawBuffer
(
&
m_vecIncomingBuffer
[
0
],
nMessageSize
);
if
(
nReturn
!=
nMessageSize
)
ITA_EXCEPT1
(
UNKNOWN
,
"Protokoll error, Received less bytes than expected"
);
#if NET_AUDIO_SHOW_TRAFFIC
std
::
cout
<<
"CITANetAudioMessage [ Reading] 2. return is "
<<
nReturn
<<
" (id="
<<
std
::
setw
(
4
)
<<
m_nMessageId
<<
") OK"
<<
std
::
endl
;
int
iBytesReceivedTotal
=
0
;
while
(
nMessagePayloadSize
!=
iBytesReceivedTotal
)
{
int
iIncommingBytes
=
m_pConnection
->
WaitForIncomingData
(
0
);
int
iBytesReceived
=
m_pConnection
->
Receive
(
&
m_vecIncomingBuffer
[
iBytesReceivedTotal
],
iIncommingBytes
);
iBytesReceivedTotal
+=
iBytesReceived
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ CITANetAudioMessage ] "
<<
std
::
setw
(
3
)
<<
std
::
floor
(
iBytesReceivedTotal
/
float
(
nMessagePayloadSize
)
*
100.0
f
)
<<
"% of answer transmitted"
<<
std
::
endl
;
#endif
}
if
(
iBytesReceivedTotal
!=
nMessagePayloadSize
)
ITA_EXCEPT1
(
UNKNOWN
,
"Protokoll error, Received less bytes than expected when trying to receive answer"
);
// Swap data to deserialization buffer
m_oIncoming
.
SetBuffer
(
&
m_vecIncomingBuffer
[
0
],
nReturn
);
m_nAnswerType
=
ReadInt
();
int
nMessageID
=
ReadInt
();
assert
(
nMessageID
==
m_nMessageId
);
m_nMessageId
=
nMessageID
;
}
int
CITANetAudioMessage
::
GetMessageType
()
const
...
...
src/ITANetAudioStream.cpp
View file @
7a5b48e0
...
...
@@ -191,7 +191,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
m_sfOutputStreamBuffer
[
uiChannel
].
Zero
();
m_iStreamingStatus
=
BUFFER_UNDERRUN
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ Stream ] Buffer underrun"
<<
std
::
endl
;
//
vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
}
else
...
...
@@ -202,7 +202,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
m_sfRingBuffer
[
uiChannel
].
Zero
();
m_iStreamingStatus
=
BUFFER_UNDERRUN
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ Stream ] Buffer underrun"
<<
std
::
endl
;
//
vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
}
else
...
...
@@ -234,21 +234,21 @@ void CITANetAudioStream::IncrementBlockPointer()
m_iReadCursor
=
(
m_iReadCursor
+
m_sfOutputStreamBuffer
.
GetLength
()
)
%
m_sfRingBuffer
.
GetLength
();
m_iStreamingStatus
=
STREAMING
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ Stream ] Streaming"
<<
std
::
endl
;
//
vstr::out() << "[ Stream ] Streaming" << std::endl;
#endif
}
else
if
(
GetIsRingBufferEmpty
(
)
)
{
m_iStreamingStatus
=
BUFFER_UNDERRUN
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ Stream ] Buffer underrun"
<<
std
::
endl
;
//
vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
}
else
{
m_iStreamingStatus
=
BUFFER_OVERRUN
;
#if NET_AUDIO_SHOW_TRAFFIC
vstr
::
out
()
<<
"[ Stream ] Buffer overrun"
<<
std
::
endl
;
//
vstr::out() << "[ Stream ] Buffer overrun" << std::endl;
#endif
m_iReadCursor
=
m_iWriteCursor
;
}
...
...
src/ITAStreamPatchBay.cpp
View file @
7a5b48e0
...
...
@@ -150,7 +150,7 @@ void ITAStreamPatchbay::SetInputDatasource( const int iInput, ITADatasource* pds
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Datasource properties do not match the input properties (num channel missmatch"
);
if
(
pdsDatasource
->
GetSampleRate
()
!=
m_dSamplerate
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Datasource properties do not match the input properties (samplerate missmatch"
);
if
(
(
unsigned
int
)
pdsDatasource
->
GetBlocklength
()
!=
m_iBlockLength
)
if
(
(
int
)
pdsDatasource
->
GetBlocklength
()
!=
m_iBlockLength
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Datasource properties do not match the input properties (blocklength missmatch)"
);
}
...
...
@@ -445,6 +445,7 @@ void ITAStreamPatchbay::HandleProcessStream( ITADatasourceRealization* pSender,
{
// Output X wants data
OutputDesc
*
pOutput
=
dynamic_cast
<
OutputDesc
*
>
(
pSender
);
assert
(
pOutput
!=
nullptr
);
// Produce all data?
if
(
m_bProcessData
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment