2003-07-02 10:21:11 +00:00
|
|
|
/*
|
|
|
|
|
* HDSPConf
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#include "HC_PrefSyncRef.h"
|
|
|
|
|
|
|
|
|
|
void pref_sync_ref_cb(Fl_Widget *w, void *arg)
|
|
|
|
|
{
|
2003-11-24 18:16:26 +00:00
|
|
|
int err;
|
2003-07-02 10:21:11 +00:00
|
|
|
char card_name[6];
|
|
|
|
|
snd_ctl_elem_value_t *ctl;
|
|
|
|
|
snd_ctl_elem_id_t *id;
|
|
|
|
|
snd_ctl_t *handle;
|
2003-11-24 18:16:26 +00:00
|
|
|
int ref = 0;
|
2003-07-02 10:21:11 +00:00
|
|
|
HC_PrefSyncRef *psr = (HC_PrefSyncRef *)arg;
|
|
|
|
|
HC_CardPane *pane = (HC_CardPane *)(psr->parent());
|
|
|
|
|
Fl_Round_Button *source = (Fl_Round_Button *)w;
|
|
|
|
|
if (source == psr->word_clock) {
|
|
|
|
|
ref = 0;
|
|
|
|
|
} else if (source == psr->spdif) {
|
2003-11-03 19:09:32 +00:00
|
|
|
ref = 1;
|
2003-07-02 10:21:11 +00:00
|
|
|
} else if (source == psr->adat1) {
|
2003-11-03 19:09:32 +00:00
|
|
|
ref = 2;
|
|
|
|
|
} else if (source == psr->adat_sync) {
|
2003-07-02 10:21:11 +00:00
|
|
|
ref = 3;
|
|
|
|
|
} else if (source == psr->adat2) {
|
|
|
|
|
ref = 4;
|
|
|
|
|
} else if (source == psr->adat3) {
|
|
|
|
|
ref = 5;
|
|
|
|
|
}
|
|
|
|
|
snprintf(card_name, 6, "hw:%i", pane->alsa_index);
|
|
|
|
|
snd_ctl_elem_value_alloca(&ctl);
|
|
|
|
|
snd_ctl_elem_id_alloca(&id);
|
|
|
|
|
snd_ctl_elem_id_set_name(id, "Preferred Sync Reference");
|
2005-07-29 14:33:00 +00:00
|
|
|
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
|
2003-07-02 10:21:11 +00:00
|
|
|
snd_ctl_elem_id_set_index(id, 0);
|
|
|
|
|
snd_ctl_elem_value_set_id(ctl, id);
|
|
|
|
|
snd_ctl_elem_value_set_enumerated(ctl, 0, ref);
|
|
|
|
|
if ((err = snd_ctl_open(&handle, card_name, SND_CTL_NONBLOCK)) < 0) {
|
|
|
|
|
fprintf(stderr, "Error opening ctl interface on card %s\n", card_name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((err = snd_ctl_elem_write(handle, ctl)) < 0) {
|
2005-07-29 14:33:00 +00:00
|
|
|
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_HWDEP);
|
|
|
|
|
snd_ctl_elem_value_set_id(ctl, id);
|
|
|
|
|
if ((err = snd_ctl_elem_write(handle, ctl)) < 0) {
|
|
|
|
|
fprintf(stderr, "Error accessing ctl interface on card %s\n", card_name);
|
|
|
|
|
snd_ctl_close(handle);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-07-02 10:21:11 +00:00
|
|
|
}
|
|
|
|
|
snd_ctl_close(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HC_PrefSyncRef::HC_PrefSyncRef(int x, int y, int w, int h):Fl_Group(x, y, w, h, "Pref. Sync Ref")
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
2003-11-03 19:09:32 +00:00
|
|
|
if (((HC_CardPane *)parent())->type == Multiface || ((HC_CardPane *)parent())->type == H9632) {
|
|
|
|
|
adat_name = "ADAT In";
|
2003-07-02 10:21:11 +00:00
|
|
|
} else {
|
2003-11-03 19:09:32 +00:00
|
|
|
adat_name = "ADAT1 In";
|
2003-07-02 10:21:11 +00:00
|
|
|
}
|
|
|
|
|
box(FL_ENGRAVED_FRAME);;
|
|
|
|
|
label("Pref. Sync Ref");
|
|
|
|
|
labelsize(10);
|
|
|
|
|
align(FL_ALIGN_TOP|FL_ALIGN_LEFT);
|
2003-11-03 19:09:32 +00:00
|
|
|
word_clock = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, "Word Clock");
|
2003-07-02 10:21:11 +00:00
|
|
|
word_clock->callback(pref_sync_ref_cb, (void *)this);
|
2003-11-03 19:09:32 +00:00
|
|
|
if (((HC_CardPane *)parent())->type != H9632) {
|
|
|
|
|
adat_sync = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, "ADAT Sync");
|
|
|
|
|
adat_sync->callback(pref_sync_ref_cb, (void *)this);
|
|
|
|
|
adat_sync->labelsize(10);
|
|
|
|
|
adat_sync->type(FL_RADIO_BUTTON);
|
|
|
|
|
}
|
|
|
|
|
spdif = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, "SPDIF In");
|
2003-07-02 10:21:11 +00:00
|
|
|
spdif->callback(pref_sync_ref_cb, (void *)this);
|
2003-11-03 19:09:32 +00:00
|
|
|
adat1 = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, adat_name);
|
2003-07-02 10:21:11 +00:00
|
|
|
adat1->callback(pref_sync_ref_cb, (void *)this);
|
2003-11-03 19:09:32 +00:00
|
|
|
if (((HC_CardPane *)parent())->type != Multiface && ((HC_CardPane *)parent())->type != H9632) {
|
|
|
|
|
adat2 = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, "ADAT2 In");
|
2003-07-02 10:21:11 +00:00
|
|
|
adat2->labelsize(10);
|
|
|
|
|
adat2->type(FL_RADIO_BUTTON);
|
|
|
|
|
adat2->callback(pref_sync_ref_cb, (void *)this);
|
2003-11-03 19:09:32 +00:00
|
|
|
adat3 = new Fl_Round_Button(x+10, y+V_STEP*i++, w-20, V_STEP, "ADAT3 In");
|
2003-07-02 10:21:11 +00:00
|
|
|
adat3->labelsize(10);
|
|
|
|
|
adat3->type(FL_RADIO_BUTTON);
|
|
|
|
|
adat3->callback(pref_sync_ref_cb, (void *)this);
|
|
|
|
|
}
|
|
|
|
|
adat1->labelsize(10);
|
|
|
|
|
adat1->type(FL_RADIO_BUTTON);
|
|
|
|
|
spdif->labelsize(10);
|
|
|
|
|
spdif->type(FL_RADIO_BUTTON);
|
|
|
|
|
word_clock->labelsize(10);
|
|
|
|
|
word_clock->type(FL_RADIO_BUTTON);
|
|
|
|
|
end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HC_PrefSyncRef::setRef(int r)
|
|
|
|
|
{
|
2003-11-03 19:09:32 +00:00
|
|
|
switch (r) {
|
|
|
|
|
case 0:
|
|
|
|
|
if (word_clock->value() != 1)
|
|
|
|
|
word_clock->setonly();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (spdif->value() != 1)
|
|
|
|
|
spdif->setonly();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (adat1->value() != 1)
|
|
|
|
|
adat1->setonly();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (((HC_CardPane *)parent())->type != H9632)
|
|
|
|
|
if (adat_sync->value() != 1)
|
|
|
|
|
adat_sync->setonly();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (((HC_CardPane *)parent())->type == H9652 || ((HC_CardPane *)parent())->type == Digiface)
|
|
|
|
|
if (adat2->value() != 1)
|
|
|
|
|
adat2->setonly();
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (((HC_CardPane *)parent())->type == H9652 || ((HC_CardPane *)parent())->type == Digiface)
|
|
|
|
|
if (adat3->value() != 1)
|
|
|
|
|
adat3->setonly();
|
|
|
|
|
break;
|
2003-07-02 10:21:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|