Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TPF
jack2
Commits
f4a158af
Commit
f4a158af
authored
Oct 09, 2013
by
Stephane Letz
Browse files
Add time-out in libjacknet netmaster side.
parent
1fe47bd9
Changes
4
Hide whitespace changes
Inline
Side-by-side
common/JackNetAPI.cpp
View file @
f4a158af
...
...
@@ -63,6 +63,7 @@ extern "C"
jack_nframes_t
buffer_size
;
jack_nframes_t
sample_rate
;
char
master_name
[
MASTER_NAME_SIZE
];
int
time_out
;
}
jack_master_t
;
...
...
@@ -161,6 +162,7 @@ struct JackNetExtMaster : public JackNetMasterInterface {
fRequest
.
sample_rate
=
request
->
sample_rate
;
fRequest
.
audio_input
=
request
->
audio_input
;
fRequest
.
audio_output
=
request
->
audio_output
;
fRequest
.
time_out
=
request
->
time_out
;
fAudioCaptureBuffer
=
NULL
;
fAudioPlaybackBuffer
=
NULL
;
fMidiCaptureBuffer
=
NULL
;
...
...
@@ -209,7 +211,8 @@ struct JackNetExtMaster : public JackNetMasterInterface {
// Main loop, wait for data, deal with it and wait again
int
attempt
=
0
;
int
rx_bytes
=
0
;
int
try_count
=
(
fRequest
.
time_out
>
0
)
?
int
((
1000000.
f
*
float
(
fRequest
.
time_out
))
/
float
(
MANAGER_INIT_TIMEOUT
))
:
INT_MAX
;
do
{
session_params_t
net_params
;
...
...
@@ -246,7 +249,12 @@ struct JackNetExtMaster : public JackNetMasterInterface {
}
}
}
while
(
fRunning
);
while
(
fRunning
&&
(
--
try_count
>
0
));
if
(
try_count
==
0
)
{
jack_error
(
"Time out error in connect"
);
return
-
1
;
}
// Set result parameters
result
->
audio_input
=
fParams
.
fSendAudioChannels
;
...
...
common/JackNetInterface.cpp
View file @
f4a158af
...
...
@@ -643,7 +643,7 @@ namespace Jack
bool
JackNetSlaveInterface
::
InitConnection
(
int
time_out_sec
)
{
jack_log
(
"JackNetSlaveInterface::InitConnection time_out_sec = %d"
,
time_out_sec
);
int
try_count
=
(
time_out_sec
>
0
)
?
((
1000000
*
time_out_sec
)
/
SLAVE_INIT_TIMEOUT
)
:
INT_MAX
;
int
try_count
=
(
time_out_sec
>
0
)
?
int
((
1000000
.
f
*
float
(
time_out_sec
)
)
/
float
(
SLAVE_INIT_TIMEOUT
)
)
:
INT_MAX
;
// set the parameters to send
strcpy
(
fParams
.
fPacketType
,
"params"
);
...
...
common/jack/net.h
View file @
f4a158af
...
...
@@ -53,7 +53,7 @@ typedef struct {
int
midi_input
;
// from master or to slave (-1 to take master MIDI physical inputs)
int
midi_output
;
// to master or from slave (-1 to take master MIDI physical outputs)
int
mtu
;
// network Maximum Transmission Unit
int
time_out
;
// in second, -1 means
in
infinite
int
time_out
;
// in second, -1 means infinite
int
encoder
;
// encoder type (one of JackNetEncoder)
int
kbps
;
// KB per second for CELT encoder
int
latency
;
// network latency
...
...
@@ -66,9 +66,10 @@ typedef struct {
int
audio_output
;
// master audio physical inputs (-1 to take slave wanted audio outputs)
int
midi_input
;
// master MIDI physical outputs (-1 to take slave wanted MIDI inputs)
int
midi_output
;
// master MIDI physical inputs (-1 to take slave wanted MIDI outputs)
jack_nframes_t
buffer_size
;
// mater buffer size
jack_nframes_t
sample_rate
;
// mater sample rate
jack_nframes_t
buffer_size
;
// ma
s
ter buffer size
jack_nframes_t
sample_rate
;
// ma
s
ter sample rate
char
master_name
[
MASTER_NAME_SIZE
];
// master machine name
int
time_out
;
// in second, -1 means infinite
}
jack_master_t
;
...
...
example-clients/netmaster.c
View file @
f4a158af
...
...
@@ -100,8 +100,8 @@ main (int argc, char *argv[])
}
int
i
;
jack_master_t
request
=
{
4
,
4
,
-
1
,
-
1
,
buffer_size
,
sample_rate
,
"master"
};
//
jack_master_t request = { -1, -1, -1, -1, buffer_size, sample_rate, "master" };
//
jack_master_t request = { 4, 4, -1, -1, buffer_size, sample_rate, "master"
, -1
};
jack_master_t
request
=
{
-
1
,
-
1
,
-
1
,
-
1
,
buffer_size
,
sample_rate
,
"master"
,
6
};
jack_slave_t
result
;
float
**
audio_input_buffer
;
float
**
audio_output_buffer
;
...
...
@@ -146,7 +146,9 @@ main (int argc, char *argv[])
WARNING !! : this code is given for demonstration purpose. For proper timing bevahiour
it has to be called in a real-time context (which is *not* the case here...)
*/
//usleep(5*1000000);
while
(
1
)
{
// Copy input to output
...
...
@@ -154,17 +156,17 @@ main (int argc, char *argv[])
for
(
i
=
0
;
i
<
result
.
audio_input
;
i
++
)
{
memcpy
(
audio_output_buffer
[
i
],
audio_input_buffer
[
i
],
buffer_size
*
sizeof
(
float
));
}
if
(
jack_net_master_send
(
net
,
result
.
audio_output
,
audio_output_buffer
,
0
,
NULL
)
<
0
)
{
printf
(
"jack_net_master_send failure, exiting
\n
"
);
break
;
}
if
(
jack_net_master_recv
(
net
,
result
.
audio_input
,
audio_input_buffer
,
0
,
NULL
)
<
0
)
{
printf
(
"jack_net_master_recv failure, exiting
\n
"
);
break
;
}
usleep
(
wait_usec
);
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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