📄 configure.c
字号:
/* * Copyright (C) 2001 CubeSoft Communications, Inc. * <http://www.csoft.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include <errno.h>#include "sun.h"#include "libxmms/util.h"#include "xmms/i18n.h"#include "mixer.h"struct sun_statsframe stats_frame;static GtkWidget *configure_win;static GtkWidget *buffer_size_spin, *buffer_pre_spin;static GtkWidget *adevice_entry, *actldevice_entry, *mdevice_entry;static GtkWidget *keepopen_cbutton;static char devaudio[64], devaudioctl[64], devmixer[64], mixer_toggle[64];static void configure_win_destroy();static void configure_win_ok_cb(GtkWidget *w, gpointer data){ ConfigFile *cfgfile; strcpy(audio.devaudio, gtk_entry_get_text(GTK_ENTRY(adevice_entry))); strcpy(audio.devmixer, gtk_entry_get_text(GTK_ENTRY(mdevice_entry))); audio.req_buffer_size = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(buffer_size_spin)); audio.req_prebuffer_size = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(buffer_pre_spin)); if (sun_mixer_open() == 0) { audio.mixer_keepopen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(keepopen_cbutton)); sun_mixer_close(); } cfgfile = xmms_cfg_open_default_file(); xmms_cfg_write_string(cfgfile, "sun", "audio_devaudio", audio.devaudio); xmms_cfg_write_string(cfgfile, "sun", "audio_devaudioctl", audio.devaudioctl); xmms_cfg_write_string(cfgfile, "sun", "audio_devmixer", audio.devmixer); xmms_cfg_write_string(cfgfile, "sun", "mixer_voldev", audio.mixer_voldev); xmms_cfg_write_boolean(cfgfile, "sun", "mixer_keepopen", audio.mixer_keepopen); xmms_cfg_write_int(cfgfile, "sun", "buffer_size", audio.req_buffer_size); xmms_cfg_write_int(cfgfile, "sun", "prebuffer_size", audio.req_prebuffer_size); xmms_cfg_write_default_file(cfgfile); xmms_cfg_free(cfgfile); configure_win_destroy();}static void configure_win_cancel_cb(GtkWidget *w, gpointer data){ configure_win_destroy();}static void mixer_cbutton_toggled_cb(GtkWidget *w, int id){ mixer_ctrl_t mixer; if (sun_mixer_open() == 0) { mixer.type = AUDIO_MIXER_ENUM; mixer.dev = id; mixer_toggle[id] = !mixer_toggle[id]; mixer.un.ord = mixer_toggle[id]; if (ioctl(audio.mixerfd, AUDIO_MIXER_WRITE, &mixer) != 0) g_warning("Could not toggle mixer setting %i", id); sun_mixer_close(); }}static void configure_win_mixer_volume_dev_cb(GtkWidget *w, gint voldev_index){ mixer_devinfo_t info; if (sun_mixer_open() == 0) { info.index = voldev_index; if (!ioctl(audio.mixerfd, AUDIO_MIXER_DEVINFO, &info)) strcpy(audio.mixer_voldev, info.label.name); sun_mixer_close(); }}static void configure_win_destroy(void){ stats_frame.active = 0; if (!pthread_mutex_lock(&stats_frame.active_mutex)) { if (!pthread_mutex_lock(&stats_frame.audioctl_mutex)) { if (stats_frame.fd) { close(stats_frame.fd); stats_frame.fd = 0; } pthread_mutex_unlock(&stats_frame.audioctl_mutex); pthread_mutex_destroy(&stats_frame.audioctl_mutex); } pthread_mutex_unlock(&stats_frame.active_mutex); pthread_mutex_destroy(&stats_frame.active_mutex); } gtk_widget_destroy(configure_win); configure_win = NULL;}static void configure_mixer_volumedev_scan(gchar *type, GtkWidget *option_menu){ mixer_devinfo_t info; GtkWidget *menu; if (sun_mixer_open() < 0) return; menu = gtk_menu_new(); /* FIXME: info is used while undefined here */ for (info.index = 0; ioctl(audio.mixerfd, AUDIO_MIXER_DEVINFO, &info) == 0; info.index++) { GtkWidget *item; if (info.type == AUDIO_MIXER_VALUE) { item = gtk_menu_item_new_with_label(info.label.name); gtk_signal_connect(GTK_OBJECT(item), "activate", configure_win_mixer_volume_dev_cb, (gpointer) info.index); gtk_widget_show(item); gtk_menu_append(GTK_MENU(menu), item); if (!strcmp(info.label.name, audio.mixer_voldev)) gtk_menu_reorder_child(GTK_MENU(menu), item, 0); } } gtk_option_menu_set_menu(GTK_OPTION_MENU(option_menu), menu); sun_mixer_close();}static void configure_adevice_box(GtkWidget *dev_vbox){ GtkWidget *adevice_frame, *adevice_vbox; adevice_frame = gtk_frame_new(_("Audio device:")); gtk_box_pack_start(GTK_BOX(dev_vbox), adevice_frame, FALSE, FALSE, 0); adevice_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(adevice_vbox), 5); gtk_container_add(GTK_CONTAINER(adevice_frame), adevice_vbox); strcpy(devaudio, audio.devaudio); adevice_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(adevice_entry), devaudio); gtk_box_pack_start_defaults(GTK_BOX(adevice_vbox), adevice_entry);}static void configure_actldevice_box(GtkWidget *dev_vbox){ GtkWidget *actldevice_frame, *actldevice_vbox; actldevice_frame = gtk_frame_new(_("Audio control device:")); gtk_box_pack_start(GTK_BOX(dev_vbox), actldevice_frame, FALSE, FALSE, 0); actldevice_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(actldevice_vbox), 5); gtk_container_add(GTK_CONTAINER(actldevice_frame), actldevice_vbox); strcpy(devaudioctl, audio.devaudioctl); actldevice_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(actldevice_entry), devaudioctl); gtk_box_pack_start_defaults(GTK_BOX(actldevice_vbox), actldevice_entry);}static void configure_mdevice_box(GtkWidget *dev_vbox){ GtkWidget *mdevice_frame, *mdevice_vbox; mdevice_frame = gtk_frame_new(_("Mixer device:")); gtk_box_pack_start(GTK_BOX(dev_vbox), mdevice_frame, FALSE, FALSE, 0); mdevice_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(mdevice_vbox), 5); gtk_container_add(GTK_CONTAINER(mdevice_frame), mdevice_vbox); strcpy(devmixer, audio.devmixer); mdevice_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(mdevice_entry), devmixer); gtk_box_pack_start_defaults(GTK_BOX(mdevice_vbox), mdevice_entry);}static void configure_devices_frame(GtkWidget *vbox, GtkWidget * notebook){ GtkWidget *dev_vbox; dev_vbox = gtk_vbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(dev_vbox), 5); configure_adevice_box(dev_vbox); configure_actldevice_box(dev_vbox); configure_mdevice_box(dev_vbox); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dev_vbox, gtk_label_new(_("Devices")));}static void configure_buffering_frame(GtkWidget *vbox, GtkWidget * notebook){ GtkWidget *buffer_frame, *buffer_vbox, *buffer_table; GtkWidget *buffer_size_box, *buffer_size_label; GtkObject *buffer_size_adj, *buffer_pre_adj; GtkWidget *buffer_pre_box, *buffer_pre_label; buffer_frame = gtk_frame_new(_("Buffering:")); gtk_container_set_border_width(GTK_CONTAINER(buffer_frame), 5); buffer_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(buffer_frame), buffer_vbox); buffer_table = gtk_table_new(2, 1, TRUE); gtk_container_set_border_width(GTK_CONTAINER(buffer_table), 5); gtk_box_pack_start(GTK_BOX(buffer_vbox), buffer_table, FALSE, FALSE, 0); buffer_size_box = gtk_hbox_new(FALSE, 5); gtk_table_attach_defaults( GTK_TABLE(buffer_table), buffer_size_box, 0, 1, 0, 1); buffer_size_label = gtk_label_new(_("Buffer size (ms):")); gtk_box_pack_start(GTK_BOX(buffer_size_box), buffer_size_label, FALSE, FALSE, 0); buffer_size_adj = gtk_adjustment_new(audio.req_buffer_size, 200, 131072, 100, 100, 100); buffer_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(buffer_size_adj), 8, 0); gtk_widget_set_usize(buffer_size_spin, 60, -1); gtk_box_pack_start(GTK_BOX(buffer_size_box), buffer_size_spin, FALSE, FALSE, 0); buffer_pre_box = gtk_hbox_new(FALSE, 5); gtk_table_attach_defaults(GTK_TABLE(buffer_table), buffer_pre_box, 1, 2, 0, 1); buffer_pre_label = gtk_label_new(_("Pre-buffer (percent):")); gtk_box_pack_start(GTK_BOX(buffer_pre_box), buffer_pre_label, FALSE, FALSE, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -