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
a8b5ec4d
Commit
a8b5ec4d
authored
Jan 12, 2017
by
Anne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log für Netzwerk auf dem Client hinzugefügt
parent
caff8f82
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
38 deletions
+57
-38
.gitignore
.gitignore
+1
-0
include/ITANetAudioStream.h
include/ITANetAudioStream.h
+5
-3
src/ITANetAudioStream.cpp
src/ITANetAudioStream.cpp
+48
-26
src/ITANetAudioStreamingServer.cpp
src/ITANetAudioStreamingServer.cpp
+3
-9
No files found.
.gitignore
View file @
a8b5ec4d
...
...
@@ -25,3 +25,4 @@ Thumbs.db
svnaccess
*.lib
*.exp
*.log
include/ITANetAudioStream.h
View file @
a8b5ec4d
...
...
@@ -32,7 +32,8 @@ using namespace std;
class
CITANetAudioStreamingClient
;
class
ITABufferedDataLoggerImpl
;
class
ITABufferedDataLoggerImplStream
;
class
ITABufferedDataLoggerImplNet
;
//! Network audio stream
/**
...
...
@@ -100,8 +101,9 @@ private:
int
m_iStreamingStatus
;
//!< Current streaming status
friend
class
CITANetAudioStreamingClient
;
ofstream
outputFile
;
ITABufferedDataLoggerImpl
*
m_pStreamLogger
;
ITABufferedDataLoggerImplStream
*
m_pStreamLogger
;
ITABufferedDataLoggerImplNet
*
m_pNetLogger
;
int
iID
;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAM
src/ITANetAudioStream.cpp
View file @
a8b5ec4d
...
...
@@ -13,23 +13,44 @@
#include <cmath>
#include <iostream>
struct
ITAStreamLog
:
public
ITALogDataBase
{
virtual
std
::
ostream
&
outputDesc
(
std
::
ostream
&
os
)
const
{
os
<<
"BlockId "
<<
"
\t
TimeStamp"
<<
"
\t
StreamingStatus"
<<
std
::
endl
;
return
os
;
};
virtual
std
::
ostream
&
outputData
(
std
::
ostream
&
os
)
const
{
os
<<
uiBlockId
<<
"
\t
"
<<
std
::
setprecision
(
12
)
<<
dTimecode
<<
"
\t
"
<<
iStreamingStatu
s
<<
std
::
endl
;
os
<<
"StreamLog
\t
"
<<
uiBlockId
<<
"
\t
"
<<
std
::
setprecision
(
12
)
<<
dTimecode
<<
"
\t
"
<<
iStreamingStatus
<<
"
\t
"
<<
iFreeSample
s
<<
std
::
endl
;
return
os
;
};
unsigned
int
uiBlockId
;
int
iStreamingStatus
;
double
dTimecode
;
int
iFreeSamples
;
};
class
ITABufferedDataLoggerImpl
:
public
ITABufferedDataLogger
<
ITAStreamLog
>
{
public
:
struct
ITANetLog
:
public
ITALogDataBase
{
virtual
std
::
ostream
&
outputDesc
(
std
::
ostream
&
os
)
const
{
os
<<
"BlockId "
<<
"
\t
TimeStamp"
<<
"
\t
Bufferstatus"
<<
std
::
endl
;
return
os
;
};
virtual
std
::
ostream
&
outputData
(
std
::
ostream
&
os
)
const
{
os
<<
"NetLog
\t
"
<<
uiBlockId
<<
"
\t
"
<<
std
::
setprecision
(
12
)
<<
dTimecode
<<
"
\t
"
<<
iBufferStatus
<<
"
\t
"
<<
iFreeSamples
<<
std
::
endl
;
return
os
;
};
unsigned
int
uiBlockId
;
int
iBufferStatus
;
double
dTimecode
;
int
iFreeSamples
;
};
class
ITABufferedDataLoggerImplStream
:
public
ITABufferedDataLogger
<
ITAStreamLog
>
{
public:
};
class
ITABufferedDataLoggerImplNet
:
public
ITABufferedDataLogger
<
ITANetLog
>
{
public:
};
CITANetAudioStream
::
CITANetAudioStream
(
int
iChannels
,
double
dSamplingRate
,
int
iBufferSize
,
int
iRingBufferCapacity
)
...
...
@@ -40,7 +61,6 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
,
m_iStreamingStatus
(
INVALID
)
{
m_bRingBufferFull
=
false
;
if
(
iBufferSize
>
iRingBufferCapacity
)
ITA_EXCEPT1
(
INVALID_PARAMETER
,
"Ring buffer capacity can not be smaller than buffer size."
);
...
...
@@ -50,16 +70,19 @@ CITANetAudioStream::CITANetAudioStream( int iChannels, double dSamplingRate, int
m_iWriteCursor
=
0
;
// always ahead, i.e. iWriteCursor >= iReadCursor if unwrapped
m_iStreamingStatus
=
STOPPED
;
outputFile
.
open
(
"program3data.txt"
);
m_pStreamLogger
=
new
ITABufferedDataLoggerImpl
(
);
// Logging
m_pStreamLogger
=
new
ITABufferedDataLoggerImpl
Stream
(
);
m_pStreamLogger
->
setOutputFile
(
"NetAudioStream.log"
);
m_pNetLogger
=
new
ITABufferedDataLoggerImplNet
(
);
m_pNetLogger
->
setOutputFile
(
"NetAudioNet.log"
);
iID
=
0
;
}
CITANetAudioStream
::~
CITANetAudioStream
()
{
delete
m_pNetAudioStreamingClient
;
outputFile
.
close
(
);
delete
m_pStreamLogger
;
delete
m_pNetLogger
;
}
bool
CITANetAudioStream
::
Connect
(
const
std
::
string
&
sAddress
,
int
iPort
)
...
...
@@ -77,7 +100,6 @@ bool CITANetAudioStream::GetIsConnected() const
const
float
*
CITANetAudioStream
::
GetBlockPointer
(
unsigned
int
uiChannel
,
const
ITAStreamInfo
*
pInfo
)
{
outputFile
<<
"GBP "
;
if
(
!
GetIsConnected
(
)
)
{
m_sfOutputStreamBuffer
[
uiChannel
].
Zero
(
);
...
...
@@ -86,13 +108,11 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if
(
GetIsRingBufferEmpty
(
)
)
{
outputFile
<<
"ZERO "
;
m_sfOutputStreamBuffer
[
uiChannel
].
Zero
(
);
}
// Es ist mindestens ein Block da
else
{
outputFile
<<
"Norm "
;
// Es ist mindestens ein Block da
m_sfRingBuffer
[
uiChannel
].
cyclic_read
(
m_sfOutputStreamBuffer
[
uiChannel
].
GetData
(
),
m_sfOutputStreamBuffer
.
GetLength
(
),
m_iReadCursor
);
// weniger als ein Block
...
...
@@ -104,7 +124,9 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
ITAStreamLog
oLog
;
oLog
.
iStreamingStatus
=
m_iStreamingStatus
;
oLog
.
dTimecode
=
ITAClock
::
getDefaultClock
(
)
->
getTime
(
);
oLog
.
uiBlockId
=
pInfo
->
nSamples
/
GetBlocklength
();
iID
++
;
oLog
.
uiBlockId
=
iID
;
oLog
.
iFreeSamples
=
GetRingBufferFreeSamples
(
);
m_pStreamLogger
->
log
(
oLog
);
}
return
m_sfOutputStreamBuffer
[
uiChannel
].
GetData
();
...
...
@@ -113,8 +135,6 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
void
CITANetAudioStream
::
IncrementBlockPointer
()
{
// Increment read cursor by one audio block and wrap around if exceeding ring buffer
// TODo hier logitem
ITAStreamLog
oLog
;
int
iSavedSample
=
GetRingBufferSize
(
)
-
GetRingBufferFreeSamples
(
);
if
(
iSavedSample
>=
int
(
GetBlocklength
(
)
)
)
...
...
@@ -122,23 +142,17 @@ void CITANetAudioStream::IncrementBlockPointer()
//es wurden Samples abgespielt
m_iReadCursor
=
(
m_iReadCursor
+
m_sfOutputStreamBuffer
.
GetLength
()
)
%
m_sfRingBuffer
.
GetLength
();
m_iStreamingStatus
=
STREAMING
;
outputFile
<<
"incRead "
;
}
else
if
(
GetIsRingBufferEmpty
(
)
)
{
m_iStreamingStatus
=
STOPPED
;
outputFile
<<
"buffer empty "
;
}
else
{
m_iStreamingStatus
=
BUFFER_UNDERRUN
;
m_iReadCursor
=
m_iWriteCursor
;
outputFile
<<
"BufferOverrun "
;
}
m_bRingBufferFull
=
false
;
outputFile
<<
"
\t
Read: "
<<
m_iReadCursor
;
outputFile
<<
"
\t
Write : "
<<
m_iWriteCursor
;
outputFile
<<
"
\t
FreeSamples: "
<<
GetRingBufferFreeSamples
()
<<
endl
;
m_pNetAudioStreamingClient
->
TriggerBlockIncrement
();
}
...
...
@@ -149,12 +163,14 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
int
iCurrentReadCursor
=
m_iReadCursor
;
int
iCurrentWriteCursor
=
m_iWriteCursor
;
ITANetLog
oLog
;
if
(
iCurrentWriteCursor
<
iCurrentReadCursor
)
iCurrentWriteCursor
+=
GetRingBufferSize
();
// Unwrap, because write cursor always ahead
if
(
(
m_iWriteCursor
==
m_iReadCursor
)
&&
m_bRingBufferFull
)
{
outputFile
<<
" BuffFull: "
;
// BufferFull
oLog
.
iBufferStatus
=
1
;
}
else
if
(
GetRingBufferFreeSamples
()
<
iNumSamples
)
{
...
...
@@ -162,23 +178,29 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
//std::cerr << "BUFFER_OVERRUN! Would partly write samples because ring buffer will be full then." << std::endl;
m_iWriteCursor
=
m_iReadCursor
;
o
utputFile
<<
" incSomeWrite: "
;
o
Log
.
iBufferStatus
=
2
;
}
else
{
// write samples into ring buffer
m_sfRingBuffer
.
cyclic_write
(
sfNewSamples
,
iNumSamples
,
0
,
iCurrentWriteCursor
);
m_bRingBufferFull
=
false
;
oLog
.
iBufferStatus
=
1
;
// set write curser
m_iWriteCursor
=
(
m_iWriteCursor
+
iNumSamples
)
%
GetRingBufferSize
(
);
if
(
m_iWriteCursor
==
m_iReadCursor
)
{
m_bRingBufferFull
=
true
;
outputFile
<<
" IncWrite: "
;
oLog
.
iBufferStatus
=
1
;
}
}
outputFile
<<
"
\t
Read: "
<<
m_iReadCursor
;
outputFile
<<
"
\t
Write : "
<<
m_iWriteCursor
;
outputFile
<<
"
\t
FreeSamples: "
<<
GetRingBufferFreeSamples
(
)
<<
endl
;
oLog
.
dTimecode
=
ITAClock
::
getDefaultClock
(
)
->
getTime
(
);
iID
++
;
oLog
.
uiBlockId
=
iID
;
oLog
.
iFreeSamples
=
GetRingBufferFreeSamples
(
);
m_pNetLogger
->
log
(
oLog
);
return
GetRingBufferFreeSamples
();
}
...
...
src/ITANetAudioStreamingServer.cpp
View file @
a8b5ec4d
...
...
@@ -25,7 +25,6 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
,
m_pConnection
(
NULL
)
{
m_pNetAudioServer
=
new
CITANetAudioServer
(
);
outputFile
.
open
(
"ServerLog.txt"
);
}
bool
CITANetAudioStreamingServer
::
Start
(
const
std
::
string
&
sAddress
,
int
iPort
)
...
...
@@ -90,8 +89,6 @@ int CITANetAudioStreamingServer::GetNetworkPort() const
void
CITANetAudioStreamingServer
::
Stop
()
{
m_pNetAudioServer
->
Stop
();
outputFile
.
close
(
);
}
void
CITANetAudioStreamingServer
::
SetInputStream
(
ITADatasource
*
pInStream
)
...
...
@@ -131,12 +128,10 @@ bool CITANetAudioStreamingServer::LoopBody()
case
CITANetAudioProtocol
::
NP_CLIENT_WAITING_FOR_SAMPLES
:
{
int
iFreeSamples
=
m_pMessage
->
ReadInt
();
outputFile
<<
"freeSamples "
<<
iFreeSamples
;
if
(
iFreeSamples
>=
m_pInputStream
->
GetBlocklength
()
)
{
// Send Samples
outputFile
<<
"SendSamples"
<<
endl
;
// Send Samples
for
(
int
i
=
0
;
i
<
m_pInputStream
->
GetNumberOfChannels
();
i
++
)
{
ITAStreamInfo
oStreamInfo
;
...
...
@@ -152,8 +147,7 @@ bool CITANetAudioStreamingServer::LoopBody()
//std::cout << "Transmitted " << m_pInputStream->GetBlocklength() << " samples, because there where " << iFreeSamples << " free samples on client side" << std::endl;
}
else
{
outputFile
<<
"Waiting"
<<
endl
;
{
//std::cout << "Could not transmitt, because there where only " << iFreeSamples << " free samples on client side" << std::endl;
// Waiting for Trigger
...
...
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