feat(midi): qualify routed startup and refresh workflow screenshots (phase 105)
This commit is contained in:
parent
f37ad8987a
commit
25d4ad5d3b
73 changed files with 208 additions and 37 deletions
|
|
@ -21,7 +21,7 @@ struct xtc_backend {
|
|||
xtc_audio_plan *audio;
|
||||
xtc_midi_plan *midi;
|
||||
xtc_midi_output_plan *midi_out;
|
||||
unsigned int output_seen,output_muted;
|
||||
unsigned int output_seen,output_muted,route_wait;
|
||||
int input_channel,output_channel,midi_thru;
|
||||
unsigned int panic_requested, panic_seen, midi_dropped, peak_left, peak_right;
|
||||
xtc_recorder *recorder; /* Borrowed, installed while callbacks quiescent. */
|
||||
|
|
@ -167,7 +167,7 @@ static int process(jack_nframes_t frames, void *context)
|
|||
__atomic_store_n(&backend->process_result, (unsigned int)XTC_ERR_IO, __ATOMIC_RELAXED);
|
||||
return 0;
|
||||
}
|
||||
if (__atomic_load_n(&backend->stop_done, __ATOMIC_ACQUIRE)) {
|
||||
if (__atomic_load_n(&backend->route_wait,__ATOMIC_ACQUIRE) || __atomic_load_n(&backend->stop_done, __ATOMIC_ACQUIRE)) {
|
||||
memset(output, 0, (size_t)frames * sizeof(*output));
|
||||
if (right) memset(right, 0, (size_t)frames * sizeof(*right));
|
||||
__atomic_store_n(&backend->peak_left, 0U, __ATOMIC_RELAXED);
|
||||
|
|
@ -936,10 +936,28 @@ xtc_result xtc_backend_route_midi(xtc_backend *b,xtc_port_direction d,const char
|
|||
r=xtc_backend_midi_name(b,d,&own);if(r!=XTC_OK)return r;
|
||||
if(!b->running)return XTC_ERR_INVALID_STATE;
|
||||
if(!strcmp(remote,jack_port_name(b->midi_input)) || !strcmp(remote,jack_port_name(b->midi_output)))return XTC_ERR_INVALID_ARGUMENT;
|
||||
code=disconnect ? jack_disconnect(b->client,d==XTC_PORT_OUTPUT ? own : remote,d==XTC_PORT_OUTPUT ? remote : own) :
|
||||
jack_connect(b->client,d==XTC_PORT_OUTPUT ? own : remote,d==XTC_PORT_OUTPUT ? remote : own);
|
||||
if(disconnect)code=jack_disconnect(b->client,d==XTC_PORT_OUTPUT ? own : remote,d==XTC_PORT_OUTPUT ? remote : own);
|
||||
else{unsigned int attempt;
|
||||
/* PipeWire publishes newly activated ports asynchronously. Control only. */
|
||||
for(attempt=0;;++attempt){
|
||||
code=jack_connect(b->client,d==XTC_PORT_OUTPUT ? own : remote,d==XTC_PORT_OUTPUT ? remote : own);
|
||||
if(code==0 || code==EEXIST || attempt==10)break;
|
||||
{struct timespec pause={0,10000000};nanosleep(&pause,NULL);}
|
||||
}
|
||||
}
|
||||
return code==0 || (!disconnect && code==EEXIST) ? XTC_OK : XTC_ERR_IO;
|
||||
}
|
||||
xtc_result xtc_backend_start_routed(xtc_backend *b,const char *input,const char *output)
|
||||
{
|
||||
xtc_result r;if(!b)return XTC_ERR_INVALID_ARGUMENT;
|
||||
if(!b->ready || b->running)return XTC_ERR_INVALID_STATE;
|
||||
__atomic_store_n(&b->route_wait,1U,__ATOMIC_RELEASE);
|
||||
r=xtc_backend_start(b);
|
||||
if(r==XTC_OK && input && *input)r=xtc_backend_route_midi(b,XTC_PORT_INPUT,input,0);
|
||||
if(r==XTC_OK && output && *output)r=xtc_backend_route_midi(b,XTC_PORT_OUTPUT,output,0);
|
||||
if(r!=XTC_OK && b->running){xtc_result stopped=xtc_backend_stop(b);if(stopped!=XTC_OK)r=stopped;}
|
||||
__atomic_store_n(&b->route_wait,0U,__ATOMIC_RELEASE);return r;
|
||||
}
|
||||
xtc_result xtc_backend_read_meters(xtc_backend *backend, xtc_meter_snapshot *out)
|
||||
{
|
||||
size_t i;
|
||||
|
|
@ -1234,4 +1252,5 @@ xtc_result xtc_backend_set_midi_options(xtc_backend *b,int i,int o,int t){(void)
|
|||
xtc_result xtc_backend_midi_name(const xtc_backend *b,xtc_port_direction d,const char **o){(void)b;(void)d;(void)o;return XTC_ERR_UNSUPPORTED;}
|
||||
xtc_result xtc_backend_visit_midi_ports(xtc_backend *b,xtc_port_direction d,xtc_backend_port_visitor v,void *c){(void)b;(void)d;(void)v;(void)c;return XTC_ERR_UNSUPPORTED;}
|
||||
xtc_result xtc_backend_route_midi(xtc_backend *b,xtc_port_direction d,const char *r,int x){(void)b;(void)d;(void)r;(void)x;return XTC_ERR_UNSUPPORTED;}
|
||||
xtc_result xtc_backend_start_routed(xtc_backend *b,const char *i,const char *o){(void)b;(void)i;(void)o;return XTC_ERR_UNSUPPORTED;}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue