/* * Class: org_tritonus_lowlevel_alsa_AlsaMixerElement * Method: getChannelName * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_tritonus_lowlevel_alsa_AlsaMixerElement_getChannelName (JNIEnv* env, jclass cls UNUSED, jint nChannelType) { const char* channelName; jstring channelNameObj; if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaMixerElement_getChannelName(): begin\n"); } channelName = snd_mixer_selem_channel_name((snd_mixer_selem_channel_id_t) nChannelType); channelNameObj = (*env)->NewStringUTF(env, channelName); if (debug_flag) { (void) fprintf(debug_file, "Java_org_tritonus_lowlevel_alsa_AlsaMixerElement_getChannelName(): end\n"); } return channelNameObj; }
void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator) { PortMixer* portMixer; snd_mixer_elem_t* elem; void* control; PortControl* portControl; void* controls[10]; int numControls; char* portName; int isPlayback = 0; int isMono; int isStereo; char* type; snd_mixer_selem_channel_id_t channel; TRACE0("> PORT_GetControls\n"); if (id == NULL) { ERROR0("Invalid handle!"); // $$mp: an error code should be returned. return; } portMixer = (PortMixer*) id; if (portIndex < 0 || portIndex >= portMixer->numElems) { ERROR0("Port index out of range!"); // $$mp: an error code should be returned. return; } numControls = 0; elem = portMixer->elems[portIndex]; if (snd_mixer_selem_has_playback_volume(elem) || snd_mixer_selem_has_capture_volume(elem)) { /* Since we've split/duplicated elements with both playback and capture on the recovery of elements, we now can assume that we handle only to deal with either playback or capture. */ isPlayback = isPlaybackFunction(portMixer->types[portIndex]); isMono = (isPlayback && snd_mixer_selem_is_playback_mono(elem)) || (!isPlayback && snd_mixer_selem_is_capture_mono(elem)); isStereo = (isPlayback && snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_FRONT_LEFT) && snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_FRONT_RIGHT)) || (!isPlayback && snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_FRONT_LEFT) && snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_FRONT_RIGHT)); // single volume control if (isMono || isStereo) { if (getControlSlot(portMixer, &portControl)) { portControl->elem = elem; portControl->portType = portMixer->types[portIndex]; portControl->controlType = CONTROL_TYPE_VOLUME; if (isMono) { portControl->channel = CHANNELS_MONO; } else { portControl->channel = CHANNELS_STEREO; } control = createVolumeControl(creator, portControl, elem, isPlayback); if (control != NULL) { controls[numControls++] = control; } } } else { // more than two channels, each channels has its own control. for (channel = SND_MIXER_SCHN_FRONT_LEFT; channel <= SND_MIXER_SCHN_LAST; channel++) { if ((isPlayback && snd_mixer_selem_has_playback_channel(elem, channel)) || (!isPlayback && snd_mixer_selem_has_capture_channel(elem, channel))) { if (getControlSlot(portMixer, &portControl)) { portControl->elem = elem; portControl->portType = portMixer->types[portIndex]; portControl->controlType = CONTROL_TYPE_VOLUME; portControl->channel = channel; control = createVolumeControl(creator, portControl, elem, isPlayback); // We wrap in a compound control to provide the channel name. if (control != NULL) { /* $$mp 2003-09-14: The following cast shouln't be necessary. Instead, the declaration of PORT_NewCompoundControlPtr in Ports.h should be changed to take a const char* parameter. */ control = (creator->newCompoundControl)(creator, (char*) snd_mixer_selem_channel_name(channel), &control, 1); } if (control != NULL) { controls[numControls++] = control; } } } } } // BALANCE control if (isStereo) { if (getControlSlot(portMixer, &portControl)) { portControl->elem = elem; portControl->portType = portMixer->types[portIndex]; portControl->controlType = CONTROL_TYPE_BALANCE; portControl->channel = CHANNELS_STEREO; /* $$mp: The value for precision is chosen more or less arbitrarily. */ control = (creator->newFloatControl)(creator, portControl, CONTROL_TYPE_BALANCE, -1.0F, 1.0F, 0.01F, ""); if (control != NULL) { controls[numControls++] = control; } } } } if (snd_mixer_selem_has_playback_switch(elem) || snd_mixer_selem_has_capture_switch(elem)) { if (getControlSlot(portMixer, &portControl)) { type = isPlayback ? CONTROL_TYPE_MUTE : CONTROL_TYPE_SELECT; portControl->elem = elem; portControl->portType = portMixer->types[portIndex]; portControl->controlType = type; control = (creator->newBooleanControl)(creator, portControl, type); if (control != NULL) { controls[numControls++] = control; } } } /* $$mp 2003-09-14: The following cast shouln't be necessary. Instead, the declaration of PORT_NewCompoundControlPtr in Ports.h should be changed to take a const char* parameter. */ portName = (char*) snd_mixer_selem_get_name(elem); control = (creator->newCompoundControl)(creator, portName, controls, numControls); if (control != NULL) { (creator->addControl)(creator, control); } TRACE0("< PORT_GetControls\n"); }