void JACK_set_name(SoundPlugin *plugin, int portnum, const char *new_name){ Data *data = plugin->data; if(plugin->type->num_inputs>0) jack_port_set_name(data->output_ports[portnum], new_name); else jack_port_set_name(data->input_ports[portnum], new_name); }
/** * Give the @a n 'th port the name of @a instr . * If the n'th port doesn't exist, new ports up to n are created. */ void JackOutput::setTrackOutput( int n, Instrument * instr, InstrumentComponent * compo, Song * song ) { QString chName; if ( track_port_count <= n ) { // need to create more ports for ( int m = track_port_count; m <= n; m++ ) { chName = QString( "Track_%1_" ).arg( m + 1 ); track_output_ports_L[m] = jack_port_register ( client, ( chName + "L" ).toLocal8Bit(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); track_output_ports_R[m] = jack_port_register ( client, ( chName + "R" ).toLocal8Bit(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); if ( ! track_output_ports_R[m] || ! track_output_ports_L[m] ) { Hydrogen::get_instance()->raiseError( Hydrogen::JACK_ERROR_IN_PORT_REGISTER ); } } track_port_count = n + 1; } // Now we're sure there is an n'th port, rename it. //DrumkitComponent* p_dmCompo = Hydrogen::get_instance()->getSong()->get_component( compo->get_drumkit_componentID() ); DrumkitComponent* p_dmCompo = song->get_component( compo->get_drumkit_componentID() ); chName = QString( "Track_%1_%2_%3_" ).arg( n + 1 ).arg( instr->get_name() ).arg( p_dmCompo->get_name() ); #ifdef HAVE_JACK_PORT_RENAME jack_port_rename( client, track_output_ports_L[n], ( chName + "L" ).toLocal8Bit() ); jack_port_rename( client, track_output_ports_R[n], ( chName + "R" ).toLocal8Bit() ); #else jack_port_set_name( track_output_ports_L[n], ( chName + "L" ).toLocal8Bit() ); jack_port_set_name( track_output_ports_R[n], ( chName + "R" ).toLocal8Bit() ); #endif }
bool Port::rename ( void ) { char jackname[max_name()]; snprintf( jackname, sizeof(jackname), "%s%s%s", _trackname ? _trackname : "", _trackname ? "/" : "", _name ); if ( _port ) return 0 == jack_port_set_name( _port, jackname ); else return false; }
/** * Give the @a n 'th port the name of @a instr . * If the n'th port doesn't exist, new ports up to n are created. */ void JackAudioDriver::setTrackOutput( int n, Instrument * instr, InstrumentComponent * pCompo, Song * pSong ) { QString chName; // The function considers `track_port_count' as the number of // ports already present. If its smaller than `n', new ports // have to be created. if ( track_port_count <= n ) { for ( int m = track_port_count; m <= n; m++ ) { chName = QString( "Track_%1_" ).arg( m + 1 ); track_output_ports_L[m] = jack_port_register( m_pClient, ( chName + "L" ).toLocal8Bit(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); track_output_ports_R[m] = jack_port_register( m_pClient, ( chName + "R" ).toLocal8Bit(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 ); if ( ! track_output_ports_R[m] || ! track_output_ports_L[m] ) { Hydrogen::get_instance()->raiseError( Hydrogen::JACK_ERROR_IN_PORT_REGISTER ); } } track_port_count = n + 1; } // Now we're sure there is an n'th port, rename it. DrumkitComponent* pDrumkitComponent = pSong->get_component( pCompo->get_drumkit_componentID() ); chName = QString( "Track_%1_%2_%3_" ).arg( n + 1 ).arg( instr->get_name() ).arg( pDrumkitComponent->get_name() ); #ifdef HAVE_JACK_PORT_RENAME // This differs from jack_port_set_name() by triggering // PortRename notifications to clients that have registered a // port rename handler. jack_port_rename( m_pClient, track_output_ports_L[n], ( chName + "L" ).toLocal8Bit() ); jack_port_rename( m_pClient, track_output_ports_R[n], ( chName + "R" ).toLocal8Bit() ); #else jack_port_set_name( track_output_ports_L[n], ( chName + "L" ).toLocal8Bit() ); jack_port_set_name( track_output_ports_R[n], ( chName + "R" ).toLocal8Bit() ); #endif }
void AudioJack::renamePort( AudioPort * _port ) { #ifdef AUDIO_PORT_SUPPORT if( m_portMap.contains( _port ) ) { const QString name[2] = { _port->name() + " L", _port->name() + " R" }; for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) { jack_port_set_name( m_portMap[_port].ports[ch], name[ch].toAscii().constData() ); } } #endif }
int jack_port_rename (jack_client_t* client, jack_port_t *port, const char *new_name) { int ret; char* old_name = strdup (port->shared->name); if ((ret = jack_port_set_name (port, new_name)) == 0) { /* tell server about name change */ jack_request_t req; req.type = PortNameChanged; /* re-purpose an appropriate part of the request union to convey the names */ snprintf ((char*)req.x.connect.source_port, JACK_PORT_NAME_SIZE - 1, "%s", old_name); snprintf ((char*)req.x.connect.destination_port, JACK_PORT_NAME_SIZE - 1, "%s", new_name); (void)jack_client_deliver_request (client, &req); } free (old_name); return ret; }
void Mixer_Strip::change_parameters() { qDebug() << "DEBUG: in change_parameters"; if ((paramDialog) && (paramDialog->get_value_changed())) { qDebug() << "DEBUG: in change_parameters - value changed"; this->set_coarse_min(paramDialog->get_coarse_min_value()); this->set_coarse_max(paramDialog->get_coarse_max_value()); this->set_coarse_current(paramDialog->get_coarse_current_value()); this->set_fine_min(paramDialog->get_fine_min_value()); this->set_fine_max(paramDialog->get_fine_max_value()); this->set_fine_current(paramDialog->get_fine_current_value()); this->set_att_rms_level(paramDialog->get_att_rms_value()); this->set_att_max_level(paramDialog->get_att_max_value()); if (this->get_mixer_type()==Mixer_Strip::mono) { jack_port_set_name(input_port[0], qPrintable(paramDialog->get_mono_in_name())); jack_port_set_name(output_port[0], qPrintable(paramDialog->get_mono_out_name())); } else { jack_port_set_name(input_port[0], qPrintable(paramDialog->get_stereo_in_left_name())); jack_port_set_name(input_port[1], qPrintable(paramDialog->get_stereo_in_right_name())); jack_port_set_name(output_port[0], qPrintable(paramDialog->get_stereo_in_left_name())); jack_port_set_name(output_port[1], qPrintable(paramDialog->get_stereo_in_right_name())); } delete paramDialog; paramDialog = NULL; } }
static gboolean cbox_jack_io_process_cmd(struct cbox_command_target *ct, struct cbox_command_target *fb, struct cbox_osc_command *cmd, GError **error) { struct cbox_jack_io_impl *jii = (struct cbox_jack_io_impl *)ct->user_data; struct cbox_io *io = jii->ioi.pio; gboolean handled = FALSE; if (!strcmp(cmd->command, "/status") && !strcmp(cmd->arg_types, "")) { if (!cbox_check_fb_channel(fb, cmd->command, error)) return FALSE; return cbox_execute_on(fb, NULL, "/client_type", "s", error, "JACK") && cbox_execute_on(fb, NULL, "/client_name", "s", error, jii->client_name) && cbox_io_process_cmd(io, fb, cmd, error, &handled); } else if (!strcmp(cmd->command, "/rename_midi_port") && !strcmp(cmd->arg_types, "ss")) { const char *uuidstr = CBOX_ARG_S(cmd, 0); const char *new_name = CBOX_ARG_S(cmd, 1); struct cbox_uuid uuid; if (!cbox_uuid_fromstring(&uuid, uuidstr, error)) return FALSE; struct cbox_midi_input *midiin = cbox_io_get_midi_input(io, NULL, &uuid); struct cbox_midi_output *midiout = cbox_io_get_midi_output(io, NULL, &uuid); if (!midiout && !midiin) { g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Port '%s' not found", uuidstr); return FALSE; } jack_port_t *port = midiout ? ((struct cbox_jack_midi_output *)midiout)->port : ((struct cbox_jack_midi_input *)midiin)->port; char **pname = midiout ? &midiout->name : &midiin->name; if (0 != jack_port_set_name(port, new_name)) { g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Cannot set port name to '%s'", new_name); return FALSE; } g_free(*pname); *pname = g_strdup(new_name); return TRUE; } else if (!strcmp(cmd->command, "/autoconnect") && !strcmp(cmd->arg_types, "ss")) { const char *uuidstr = CBOX_ARG_S(cmd, 0); const char *spec = CBOX_ARG_S(cmd, 1); struct cbox_uuid uuid; if (!cbox_uuid_fromstring(&uuid, uuidstr, error)) return FALSE; struct cbox_midi_output *midiout = cbox_io_get_midi_output(io, NULL, &uuid); if (midiout) { cbox_jack_midi_output_set_autoconnect((struct cbox_jack_midi_output *)midiout, spec); return TRUE; } struct cbox_midi_input *midiin = cbox_io_get_midi_input(io, NULL, &uuid); if (midiin) { cbox_jack_midi_input_set_autoconnect((struct cbox_jack_midi_input *)midiin, spec); return TRUE; } g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Port '%s' not found", uuidstr); return FALSE; } else if (!strcmp(cmd->command, "/disconnect_midi_port") && !strcmp(cmd->arg_types, "s")) { const char *uuidstr = CBOX_ARG_S(cmd, 0); struct cbox_uuid uuid; if (!cbox_uuid_fromstring(&uuid, uuidstr, error)) return FALSE; struct cbox_midi_input *midiin = cbox_io_get_midi_input(io, NULL, &uuid); struct cbox_midi_output *midiout = cbox_io_get_midi_output(io, NULL, &uuid); if (!midiout && !midiin) { g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Port '%s' not found", uuidstr); return FALSE; } jack_port_t *port = midiout ? ((struct cbox_jack_midi_output *)midiout)->port : ((struct cbox_jack_midi_input *)midiin)->port; jack_port_disconnect(jii->client, port); return TRUE; } else if (!strcmp(cmd->command, "/port_connect") && !strcmp(cmd->arg_types, "ss")) { const char *port_from = CBOX_ARG_S(cmd, 0); const char *port_to = CBOX_ARG_S(cmd, 1); int res = jack_connect(jii->client, port_from, port_to); if (res == EEXIST) res = 0; if (res) g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Cannot connect port '%s' to '%s'", port_from, port_to); return res == 0; } else if (!strcmp(cmd->command, "/port_disconnect") && !strcmp(cmd->arg_types, "ss")) { const char *port_from = CBOX_ARG_S(cmd, 0); const char *port_to = CBOX_ARG_S(cmd, 1); int res = jack_disconnect(jii->client, port_from, port_to); if (res) g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Cannot disconnect port '%s' from '%s'", port_from, port_to); return res == 0; } else if (!strcmp(cmd->command, "/get_connected_ports") && !strcmp(cmd->arg_types, "s")) { if (!cbox_check_fb_channel(fb, cmd->command, error)) return FALSE; const char *name = CBOX_ARG_S(cmd, 0); jack_port_t *port = jack_port_by_name(jii->client, name); if (!port) { g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Port '%s' not found", name); return FALSE; } const char** ports = jack_port_get_all_connections(jii->client, port); for (int i = 0; ports && ports[i]; i++) { if (!cbox_execute_on(fb, NULL, "/port", "s", error, ports[i])) return FALSE; } jack_free(ports); return TRUE; } else if (!strcmp(cmd->command, "/get_ports") && !strcmp(cmd->arg_types, "ssi")) { if (!cbox_check_fb_channel(fb, cmd->command, error)) return FALSE; const char *mask = CBOX_ARG_S(cmd, 0); const char *type = CBOX_ARG_S(cmd, 1); uint32_t flags = CBOX_ARG_I(cmd, 2); const char** ports = jack_get_ports(jii->client, mask, type, flags); for (int i = 0; ports && ports[i]; i++) { if (!cbox_execute_on(fb, NULL, "/port", "s", error, ports[i])) return FALSE; } jack_free(ports); return TRUE; } else { gboolean result = cbox_io_process_cmd(io, fb, cmd, error, &handled); if (!handled) g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "Unknown combination of target path and argument: '%s', '%s'", cmd->command, cmd->arg_types); return result; } }
void AudioOutputDeviceJack::AudioChannelJack::ParameterName::OnSetValue(String s) { if (jack_port_set_name(pChannel->hJackPort, s.c_str())) throw AudioOutputException("Failed to rename JACK port"); }