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
856ce0b9
Commit
856ce0b9
authored
Dec 21, 2016
by
Anne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge fixed bodyloop
parent
5c42938a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
487 additions
and
418 deletions
+487
-418
include/ITANetAudioMessage.h
include/ITANetAudioMessage.h
+8
-2
include/ITANetAudioStreamingServer.h
include/ITANetAudioStreamingServer.h
+0
-2
src/ITANetAudioMessage.cpp
src/ITANetAudioMessage.cpp
+449
-399
src/ITANetAudioServer.cpp
src/ITANetAudioServer.cpp
+0
-1
src/ITANetAudioStreamingClient.cpp
src/ITANetAudioStreamingClient.cpp
+16
-6
src/ITANetAudioStreamingServer.cpp
src/ITANetAudioStreamingServer.cpp
+12
-6
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
+2
-2
No files found.
include/ITANetAudioMessage.h
View file @
856ce0b9
...
...
@@ -78,7 +78,10 @@ public:
void
WriteString
(
const
std
::
string
&
);
void
WriteIntVector
(
const
std
::
vector
<
int
>
);
void
WriteFloatVector
(
const
std
::
vector
<
float
>
);
void
WriteStreamingParameters
(
const
CITANetAudioProtocol
::
StreamingParameters
&
);
void
WriteStreamingParameters
(
const
CITANetAudioProtocol
::
StreamingParameters
&
);
void
WriteRingBufferSize
(
const
int
);
void
WriteRingBufferFree
(
const
int
);
void
WriteSampleFrame
(
ITASampleFrame
*
);
std
::
string
ReadString
();
int
ReadInt
();
...
...
@@ -89,6 +92,9 @@ public:
std
::
vector
<
int
>
ReadIntVector
();
std
::
vector
<
float
>
ReadFloatVector
();
CITANetAudioProtocol
::
StreamingParameters
ReadStreamingParameters
();
int
ReadRingBufferSize
();
int
ReadRingBufferFree
();
void
ReadSampleFrame
(
ITASampleFrame
*
pSampleFrame
);
private:
...
...
include/ITANetAudioStreamingServer.h
View file @
856ce0b9
...
...
@@ -74,8 +74,6 @@ public:
void
SetAutomaticUpdateRate
();
bool
LoopBody
();
protected:
int
Transmit
(
const
ITASampleFrame
&
sfNewSamples
,
int
iNumSamples
);
ITADatasource
*
GetInputStream
()
const
;
...
...
src/ITANetAudioMessage.cpp
View file @
856ce0b9
...
...
@@ -102,7 +102,7 @@ void CITANetAudioMessage::ReadMessage()
int
nReturn
=
m_pConnection
->
ReadInt32
(
nMessageSize
);
// we need at least the two protocol ints
assert
(
nMessageSize
>=
3
*
sizeof
(
VistaType
::
sint32
)
);
assert
(
nMessageSize
>=
2
*
sizeof
(
VistaType
::
sint32
)
);
if
(
nMessageSize
>
(
int
)
m_vecIncomingBuffer
.
size
()
)
m_vecIncomingBuffer
.
resize
(
nMessageSize
);
...
...
@@ -397,3 +397,53 @@ void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol::
WriteDouble
(
oParams
.
dSampleRate
);
WriteInt
(
oParams
.
iBlockSize
);
}
int
CITANetAudioMessage
::
ReadRingBufferSize
()
{
return
ReadInt
();
}
void
CITANetAudioMessage
::
WriteRingBufferSize
(
const
int
iBufferSize
)
{
WriteInt
(
iBufferSize
);
}
int
CITANetAudioMessage
::
ReadRingBufferFree
()
{
return
ReadInt
();
}
void
CITANetAudioMessage
::
WriteRingBufferFree
(
const
int
iBufferFree
)
{
WriteInt
(
iBufferFree
);
}
void
CITANetAudioMessage
::
ReadSampleFrame
(
ITASampleFrame
*
pSampleFrame
)
{
int
iChannels
=
ReadInt
();
int
iSamples
=
ReadInt
();
if
(
pSampleFrame
->
channels
()
!=
iChannels
||
pSampleFrame
->
GetLength
()
!=
iSamples
)
pSampleFrame
->
init
(
iChannels
,
iSamples
,
false
);
for
(
int
i
=
0
;
i
<
iChannels
;
i
++
)
{
for
(
int
j
=
0
;
j
<
iSamples
;
j
++
)
{
(
*
pSampleFrame
)[
i
][
j
]
=
ReadFloat
();
}
}
}
void
CITANetAudioMessage
::
WriteSampleFrame
(
ITASampleFrame
*
pSamples
)
{
WriteInt
(
pSamples
->
channels
());
WriteInt
(
pSamples
->
GetLength
());
for
(
int
i
=
0
;
i
<
pSamples
->
channels
();
i
++
)
{
for
(
int
j
=
0
;
j
<
pSamples
->
GetLength
();
j
++
)
{
WriteFloat
((
*
pSamples
)[
i
][
j
]);
}
}
}
src/ITANetAudioServer.cpp
View file @
856ce0b9
...
...
@@ -24,7 +24,6 @@ CITANetAudioServer::CITANetAudioServer()
,
m_pSocket
(
NULL
)
,
m_pConnection
(
NULL
)
,
m_iServerPort
(
-
1
)
,
m_pConnection
(
NULL
)
{
};
...
...
src/ITANetAudioStreamingClient.cpp
View file @
856ce0b9
...
...
@@ -13,9 +13,9 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
{
m_pClient
=
new
CITANetAudioClient
();
m_o
Client
Params
.
iChannels
=
pParent
->
GetNumberOfChannels
();
m_o
Client
Params
.
dSampleRate
=
pParent
->
GetSampleRate
();
m_o
Client
Params
.
iBlockSize
=
pParent
->
GetBlocklength
();
m_oParams
.
iChannels
=
pParent
->
GetNumberOfChannels
();
m_oParams
.
dSampleRate
=
pParent
->
GetSampleRate
();
m_oParams
.
iBlockSize
=
pParent
->
GetBlocklength
();
m_pMessage
=
new
CITANetAudioMessage
(
VistaSerializingToolset
::
SWAPS_MULTIBYTE_VALUES
);
}
...
...
@@ -24,6 +24,8 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
{
if
(
m_pConnection
)
{
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_CLOSE
);
m_pMessage
->
WriteAnswer
();
}
...
...
@@ -79,9 +81,17 @@ bool CITANetAudioStreamingClient::LoopBody()
if
(
m_bStopIndicated
)
return
true
;
// Receive message
m_pMessage
->
ReadMessage
();
switch
(
m_pMessage
->
GetMessageType
()
)
// send freesamples
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_WAITING_FOR_SAMPLES
);
m_pMessage
->
WriteInt
(
m_pStream
->
GetRingbufferFreeSamples
()
);
m_pMessage
->
WriteMessage
();
m_pMessage
->
ReadAnswer
();
switch
(
m_pMessage
->
GetAnswerType
()
)
{
case
CITANetAudioProtocol
::
NP_INVALID
:
break
;
...
...
src/ITANetAudioStreamingServer.cpp
View file @
856ce0b9
...
...
@@ -70,10 +70,6 @@ int CITANetAudioStreamingServer::GetNetworkPort() const
{
return
m_pNetAudioServer
->
GetNetworkPort
();
}
bool
CITANetAudioStreamingServer
::
LoopBody
()
{
return
true
;
}
void
CITANetAudioStreamingServer
::
Stop
()
{
...
...
@@ -118,16 +114,26 @@ bool CITANetAudioStreamingServer::LoopBody()
case
CITANetAudioProtocol
::
NP_CLIENT_WAITING_FOR_SAMPLES
:
if
(
m_pInputStream
)
{
int
iFreeSamples
=
m_pMessage
->
ReadInt
();
if
(
iFreeSamples
<
m_pInputStream
->
GetBlocklength
())
{
// zurückmelden und warten auf exeption
break
;
}
for
(
int
i
=
0
;
i
<
m_pInputStream
->
GetNumberOfChannels
();
i
++
)
{
ITAStreamInfo
oStreamInfo
;
const
float
*
pfData
=
m_pInputStream
->
GetBlockPointer
(
i
,
&
oStreamInfo
);
m_sfTempTransmitBuffer
[
i
].
write
(
pfData
,
m_pInputStream
->
GetBlocklength
()
);
}
m_pMessage
->
WriteSampleFrame
(
&
m_sfTempTransmitBuffer
);
}
//m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
m_pMessage
->
WriteAnswer
();
m_pInputStream
->
IncrementBlockPointer
();
float
fTimeOut
=
m_pInputStream
->
GetBlocklength
()
/
m_pInputStream
->
GetSampleRate
();
//VistaTimeUtils::Sleep( (int) ( fTimeOut * 1000 ) );
break
;
}
...
...
tests/NetAudio/ITANetAudioStreamingServerTest.cpp
View file @
856ce0b9
...
...
@@ -16,8 +16,8 @@ int main( int , char** )
{
ITAStreamFunctionGenerator
oGenerator
(
1
,
g_dSampleRate
,
g_iBlockLength
,
ITAStreamFunctionGenerator
::
SINE
,
456.78
f
,
0.81
f
,
true
);
//CITANetAudioStream
oStreamingServer;
//
oStreamingServer.SetInputStream( &oGenerator );
CITANetAudioStreamingServer
oStreamingServer
;
oStreamingServer
.
SetInputStream
(
&
oGenerator
);
cout
<<
"Starting server and waiting for connections on '"
<<
g_sServerName
<<
"' on port "
<<
g_iServerPort
<<
endl
;
oStreamingServer
.
Start
(
g_sServerName
,
g_iServerPort
);
...
...
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