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
0d9073a6
Commit
0d9073a6
authored
Feb 22, 2017
by
Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing disconnect problems with client
parent
d4d3a8b2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
27 deletions
+54
-27
include/ITANetAudioStream.h
include/ITANetAudioStream.h
+2
-0
include/ITANetAudioStreamingClient.h
include/ITANetAudioStreamingClient.h
+4
-1
src/ITANetAudioClient.cpp
src/ITANetAudioClient.cpp
+1
-1
src/ITANetAudioStream.cpp
src/ITANetAudioStream.cpp
+5
-0
src/ITANetAudioStreamingClient.cpp
src/ITANetAudioStreamingClient.cpp
+39
-24
tests/NetAudio/ITANetAudioTest.cpp
tests/NetAudio/ITANetAudioTest.cpp
+3
-1
No files found.
include/ITANetAudioStream.h
View file @
0d9073a6
...
...
@@ -78,6 +78,8 @@ public:
*/
bool
Connect
(
const
std
::
string
&
sAddress
,
int
iPort
=
12480
);
void
Disconnect
();
//! Returns the connection status
/**
* @return True, if connected
...
...
include/ITANetAudioStreamingClient.h
View file @
0d9073a6
...
...
@@ -69,13 +69,16 @@ private:
CITANetAudioMessage
*
m_pMessage
;
VistaConnectionIP
*
m_pConnection
;
VistaThreadEvent
m_oBlockIncrementEvent
;
//
VistaThreadEvent m_oBlockIncrementEvent;
ITASampleFrame
m_sfReceivingBuffer
;
//!< Buffer incoming data
CITANetAudioProtocol
::
StreamingParameters
m_oParams
;
bool
m_bStopIndicated
;
bool
m_bStopped
;
int
iStreamingBlockId
;
ITABufferedDataLoggerImplClient
*
m_pClientLogger
;
friend
class
CITANetAudioStream
;
};
...
...
src/ITANetAudioClient.cpp
View file @
0d9073a6
...
...
@@ -46,5 +46,5 @@ void CITANetAudioClient::Disconnect()
bool
CITANetAudioClient
::
GetIsConnected
()
const
{
return
m_pConnection
?
true
:
false
;
return
(
m_pConnection
!=
NULL
)
?
true
:
false
;
}
src/ITANetAudioStream.cpp
View file @
0d9073a6
...
...
@@ -126,6 +126,11 @@ bool CITANetAudioStream::Connect( const std::string& sAddress, int iPort )
return
m_pNetAudioStreamingClient
->
Connect
(
sAddress
,
iPort
);
}
void
CITANetAudioStream
::
Disconnect
()
{
m_pNetAudioStreamingClient
->
Disconnect
();
}
bool
CITANetAudioStream
::
GetIsConnected
()
const
{
return
m_pNetAudioStreamingClient
->
GetIsConnected
();
...
...
src/ITANetAudioStreamingClient.cpp
View file @
0d9073a6
...
...
@@ -6,12 +6,13 @@
#include <VistaInterProcComm/Connections/VistaConnectionIP.h>
#include <VistaBase/VistaStreamUtils.h>
#include <VistaBase/VistaTimeUtils.h>
CITANetAudioStreamingClient
::
CITANetAudioStreamingClient
(
CITANetAudioStream
*
pParent
)
:
m_oBlockIncrementEvent
(
VistaThreadEvent
::
WAITABLE_EVENT
)
,
m_pStream
(
pParent
)
:
m_pStream
(
pParent
)
,
m_pConnection
(
NULL
)
,
m_bStopIndicated
(
false
)
,
m_bStopped
(
false
)
{
m_pClient
=
new
CITANetAudioClient
();
...
...
@@ -24,14 +25,14 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
CITANetAudioStreamingClient
::~
CITANetAudioStreamingClient
()
{
if
(
m_pConnection
)
{
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_CLOSE
);
m_pMessage
->
WriteMessage
()
;
m_pClient
->
Disconnect
()
;
}
if
(
GetIsConnected
()
)
Disconnect
();
StopGently
(
true
);
delete
m_pClientLogger
;
delete
m_pClient
;
delete
m_pMessage
;
}
bool
CITANetAudioStreamingClient
::
Connect
(
const
std
::
string
&
sAddress
,
int
iPort
)
...
...
@@ -66,10 +67,27 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
bool
CITANetAudioStreamingClient
::
LoopBody
()
{
if
(
m_bStopIndicated
)
if
(
!
GetIsConnected
()
)
return
true
;
// Send message to server that samples can be received
ITAClientLog
oLog
;
oLog
.
uiBlockId
=
++
iStreamingBlockId
;
if
(
m_bStopIndicated
&&
!
m_bStopped
)
{
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_CLOSE
);
m_pMessage
->
WriteMessage
();
m_bStopped
=
true
;
m_pMessage
->
SetConnection
(
NULL
);
while
(
GetIsConnected
()
)
VistaTimeUtils
::
Sleep
(
100
);
return
true
;
}
m_pMessage
->
ResetMessage
();
m_pMessage
->
SetConnection
(
m_pConnection
);
m_pMessage
->
SetMessageType
(
CITANetAudioProtocol
::
NP_CLIENT_WAITING_FOR_SAMPLES
);
...
...
@@ -79,11 +97,11 @@ bool CITANetAudioStreamingClient::LoopBody()
m_pMessage
->
WriteInt
(
iFreeSamplesUntilAllowedReached
);
m_pMessage
->
WriteMessage
();
// Wait for answer of server
m_pMessage
->
ReadAnswer
();
int
iAnswerType
=
m_pMessage
->
GetAnswerType
();
switch
(
iAnswerType
)
// Read answer (blocking)
m_pMessage
->
ResetMessage
(
);
if
(
m_pMessage
->
ReadMessage
(
0
)
)
{
int
iMsgType
=
m_pMessage
->
GetMessageType
(
);
case
CITANetAudioProtocol
::
NP_INVALID
:
// Something went wrong
...
...
@@ -112,11 +130,6 @@ bool CITANetAudioStreamingClient::LoopBody()
return
true
;
}
void
CITANetAudioStreamingClient
::
TriggerBlockIncrement
()
{
m_oBlockIncrementEvent
.
SignalEvent
();
}
bool
CITANetAudioStreamingClient
::
GetIsConnected
()
const
{
return
m_pClient
->
GetIsConnected
();
...
...
@@ -125,10 +138,12 @@ bool CITANetAudioStreamingClient::GetIsConnected() const
void
CITANetAudioStreamingClient
::
Disconnect
()
{
m_bStopIndicated
=
true
;
StopGently
(
true
);
delete
m_pConnection
;
while
(
!
m_bStopped
)
VistaTimeUtils
::
Sleep
(
100
);
m_pConnection
=
NULL
;
m_pClient
->
Disconnect
();
m_bStopIndicated
=
false
;
m_bStopped
=
false
;
}
tests/NetAudio/ITANetAudioTest.cpp
View file @
0d9073a6
...
...
@@ -61,7 +61,7 @@ private:
int
main
(
int
,
char
**
)
{
// Sample server (forked away into a thread)
CServer
o
Server
(
g_sInputFilePath
);
CServer
*
pServer
=
new
C
Server
(
g_sInputFilePath
);
// Client dumping received stream and mixing down to two channels
CITANetAudioStream
oNetAudioStream
(
g_iChannels
,
g_dSampleRate
,
g_iBlockLength
,
100
*
g_iBlockLength
);
...
...
@@ -105,6 +105,8 @@ int main( int, char** )
ITAPA
.
Sleep
(
fSeconds
);
// blocking
vstr
::
out
()
<<
"[ NetAudioTestClient ] Done."
<<
endl
;
oNetAudioStream
.
Disconnect
();
vstr
::
out
()
<<
"[ NetAudioTestClient ] Will now disconnect from net audio server '"
<<
g_sServerName
<<
"' and port "
<<
g_iServerPort
<<
endl
;
vstr
::
out
()
<<
"[ NetAudioTestClient ] Closing in 1 second (net audio stream not connected and playing back zeros)"
<<
endl
;
ITAPA
.
Sleep
(
1.0
f
);
...
...
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