void si_cfg_load (void) { aud_config_set_defaults ("statusicon", si_defaults); si_cfg.rclick_menu = aud_get_int ("statusicon", "rclick_menu"); si_cfg.scroll_action = aud_get_int ("statusicon", "scroll_action"); si_cfg.volume_delta = aud_get_int ("statusicon", "volume_delta"); si_cfg.disable_popup = aud_get_bool ("statusicon", "disable_popup"); si_cfg.close_to_tray = aud_get_bool ("statusicon", "close_to_tray"); }
static void *create_config_widget (void) { int feed_level = aud_get_int ("bs2b", "feed"); int fcut_level = aud_get_int ("bs2b", "fcut"); { GtkWidget *vbox, *hbox, *button; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Feed level:")), TRUE, FALSE, 0); feed_slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, BS2B_MINFEED, BS2B_MAXFEED, 1.0); gtk_range_set_value (GTK_RANGE(feed_slider), feed_level); gtk_widget_set_size_request (feed_slider, 200, -1); gtk_box_pack_start ((GtkBox *) hbox, feed_slider, FALSE, FALSE, 0); g_signal_connect (feed_slider, "value-changed", (GCallback) feed_value_changed, NULL); g_signal_connect (feed_slider, "format-value", (GCallback) feed_format_value, NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new(_("Cut frequency:")), TRUE, FALSE, 0); fcut_slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, BS2B_MINFCUT, BS2B_MAXFCUT, 1.0); gtk_range_set_value (GTK_RANGE(fcut_slider), fcut_level); gtk_widget_set_size_request (fcut_slider, 200, -1); gtk_box_pack_start ((GtkBox *) hbox, fcut_slider, FALSE, FALSE, 0); g_signal_connect (fcut_slider, "value-changed", (GCallback) fcut_value_changed, NULL); g_signal_connect (fcut_slider, "format-value", (GCallback) fcut_format_value, NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) vbox, hbox, FALSE, FALSE, 0); gtk_box_pack_start ((GtkBox *) hbox, gtk_label_new(_("Presets:")), TRUE, FALSE, 0); button = preset_button(_("Default"), BS2B_DEFAULT_CLEVEL); gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0); button = preset_button("C. Moy", BS2B_CMOY_CLEVEL); gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0); button = preset_button("J. Meier", BS2B_JMEIER_CLEVEL); gtk_box_pack_start ((GtkBox *) hbox, button, TRUE, FALSE, 0); return vbox; } }
static void restore_window_size (void) { gint x = aud_get_int ("gtkui", "player_x"); gint y = aud_get_int ("gtkui", "player_y"); gint w = aud_get_int ("gtkui", "player_width"); gint h = aud_get_int ("gtkui", "player_height"); gtk_window_set_default_size ((GtkWindow *) window, w, h); if (x > -1000 && y > -1000) gtk_window_move ((GtkWindow *) window, x, y); }
gboolean init() { aud_config_set_defaults("bs2b", bs2b_defaults); bs2b = bs2b_open(); if (bs2b == NULL) return FALSE; bs2b_set_level_feed (bs2b, aud_get_int ("bs2b", "feed")); bs2b_set_level_fcut (bs2b, aud_get_int ("bs2b", "fcut")); return TRUE; }
/* load plugin configuration */ void load_config (void) { HotkeyConfiguration *hotkey; int i,max; /* default volume level */ plugin_cfg.vol_increment = 4; plugin_cfg.vol_decrement = 4; hotkey = &(plugin_cfg.first); hotkey->next = NULL; hotkey->key = 0; hotkey->mask = 0; hotkey->event = 0; hotkey->type = TYPE_KEY; max = aud_get_int ("globalHotkey", "NumHotkeys"); if (max == 0) load_defaults(); else for (i=0; i<max; i++) { gchar *text = NULL; if (hotkey->key) { hotkey->next = (HotkeyConfiguration*) malloc(sizeof (HotkeyConfiguration)); hotkey = hotkey->next; hotkey->next = NULL; hotkey->key = 0; hotkey->mask = 0; hotkey->event = 0; hotkey->type = TYPE_KEY; } text = g_strdup_printf("Hotkey_%d_key", i); hotkey->key = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_mask", i); hotkey->mask = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_type", i); hotkey->type = aud_get_int ("globalHotkey", text); g_free(text); text = g_strdup_printf("Hotkey_%d_event", i); hotkey->event = aud_get_int ("globalHotkey", text); g_free(text); } }
void resample_config_load (void) { aud_config_set_defaults ("resample", resample_defaults); for (int count = 0; count < n_common_rates; count ++) { char scratch[16]; snprintf (scratch, sizeof scratch, "%d", common_rates[count]); converted_rates[count] = aud_get_int ("resample", scratch); } fallback_rate = aud_get_int ("resample", "fallback_rate"); method = aud_get_int ("resample", "method"); }
int sdlout_init (void) { aud_config_set_defaults ("sdlout", sdl_defaults); vol_left = aud_get_int ("sdlout", "vol_left"); vol_right = aud_get_int ("sdlout", "vol_right"); if (SDL_Init (SDL_INIT_AUDIO) < 0) { fprintf (stderr, "Failed to init SDL: %s.\n", SDL_GetError ()); return 0; } return 1; }
static gboolean bscope_init (void) { aud_config_set_defaults ("BlurScope", bscope_defaults); color = aud_get_int ("BlurScope", "color"); return TRUE; }
static void load_enabled_from_config (void) { int count = aud_get_int ("ladspa", "plugin_count"); for (int i = 0; i < count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); char * path = aud_get_string ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_string ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); int ccount = index_count (loaded->plugin->controls); for (int ci = 0; ci < ccount; ci ++) { snprintf (key, sizeof key, "plugin%d_control%d", i, ci); loaded->values[ci] = aud_get_double ("ladspa", key); } } g_free (path); g_free (label); } }
static void popup_trigger (PlaylistWidgetData * data, gint pos) { popup_hide (data); data->popup_pos = pos; data->popup_source = g_timeout_add (aud_get_int (NULL, "filepopup_delay") * 100, (GSourceFunc) popup_show, data); }
static gboolean si_cb_btscroll(GtkStatusIcon * icon, GdkEventScroll * event, gpointer user_data) { switch (event->direction) { case GDK_SCROLL_UP: { switch (aud_get_int ("statusicon", "scroll_action")) { case SI_CFG_SCROLL_ACTION_VOLUME: si_volume_change (aud_get_int ("statusicon", "volume_delta")); break; case SI_CFG_SCROLL_ACTION_SKIP: if (aud_get_bool ("statusicon", "reverse_scroll")) aud_drct_pl_next (); else aud_drct_pl_prev (); break; } break; } case GDK_SCROLL_DOWN: { switch (aud_get_int ("statusicon", "scroll_action")) { case SI_CFG_SCROLL_ACTION_VOLUME: si_volume_change (-aud_get_int ("statusicon", "volume_delta")); break; case SI_CFG_SCROLL_ACTION_SKIP: if (aud_get_bool ("statusicon", "reverse_scroll")) aud_drct_pl_prev (); else aud_drct_pl_next (); break; } break; } default:; } return FALSE; }
bool play(const char *filename, VFSFile &file) { force_apply = true; try { MPTWrap mpt(file); open_audio(FMT_FLOAT, 44100, 2); while(!check_stop()) { unsigned char buffer[65536]; std::int64_t n; int seek_value = check_seek(); if(seek_value >= 0) mpt.seek(seek_value); if(force_apply) { mpt.set_interpolator(aud_get_int(PACKAGE, SETTING_INTERPOLATOR)); mpt.set_stereo_separation(aud_get_int(PACKAGE, SETTING_STEREO_SEPARATION)); force_apply = false; } n = mpt.read(buffer, sizeof buffer); if(n == 0) break; write_audio(buffer, n); } return true; } catch(MPTWrap::InvalidFile) { return false; } }
void resample_start (int * channels, int * rate) { if (state) { src_delete (state); state = NULL; } int new_rate = 0; if (aud_get_bool ("resample", "use-mappings")) { char rate_s[16]; str_itoa (* rate, rate_s, sizeof rate_s); new_rate = aud_get_int ("resample", rate_s); } if (! new_rate) new_rate = aud_get_int ("resample", "default-rate"); new_rate = CLAMP (new_rate, MIN_RATE, MAX_RATE); if (new_rate == * rate) return; int method = aud_get_int ("resample", "method"); int error; if ((state = src_new (method, * channels, & error)) == NULL) { RESAMPLE_ERROR (error); return; } stored_channels = * channels; ratio = (double) new_rate / * rate; * rate = new_rate; }
/* Initialize necessary things */ static bool_t jack_init (void) { aud_config_set_defaults ("jack", jack_defaults); jack_cfg.isTraceEnabled = aud_get_bool ("jack", "isTraceEnabled"); jack_cfg.volume_left = aud_get_int ("jack", "volume_left"); jack_cfg.volume_right = aud_get_int ("jack", "volume_right"); TRACE("initializing\n"); JACK_Init(); /* initialize the driver */ /* set the bio2jack name so users will see xmms-jack in their */ /* jack client list */ JACK_SetClientName("audacious-jack"); /* set the port connection mode */ jack_set_port_connection_mode(); output_opened = FALSE; /* Always return OK, as we don't know about physical devices here */ return TRUE; }
/* * read the current configuration from the file */ static void alarm_read_config(void) { int daynum = 0; // used for day number aud_config_set_defaults ("alarm", alarm_defaults); alarm_h = aud_get_int ("alarm", "alarm_h"); alarm_m = aud_get_int ("alarm", "alarm_m"); /* save them here too */ alarm_conf.default_hour = alarm_h; alarm_conf.default_min = alarm_m; stop_h = aud_get_int ("alarm", "stop_h"); stop_m = aud_get_int ("alarm", "stop_m"); stop_on = aud_get_bool ("alarm", "stop_on"); volume = aud_get_int ("alarm", "volume"); quietvol = aud_get_int ("alarm", "quietvol"); fading = aud_get_int ("alarm", "fading"); cmd_on = aud_get_bool ("alarm", "cmd_on"); alarm_conf.reminder_on = aud_get_bool ("alarm", "reminder_on"); /* day flags and times */ for(; daynum < 7; daynum++) { /* read the flags */ alarm_conf.day[daynum].flags = aud_get_int ("alarm", day_flags[daynum]); /* read the times */ alarm_conf.day[daynum].hour = aud_get_int ("alarm", day_h[daynum]); alarm_conf.day[daynum].min = aud_get_int ("alarm", day_m[daynum]); } }
static void load_enabled_from_config (void) { int count = aud_get_int ("ladspa", "plugin_count"); for (int i = 0; i < count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); char * path = aud_get_str ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_str ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; char * controls = aud_get_str ("ladspa", key); if (str_to_double_array (controls, temp, ccount)) { for (int ci = 0; ci < ccount; ci ++) loaded->values[ci] = temp[ci]; } else { /* migrate from old config format */ for (int ci = 0; ci < ccount; ci ++) { snprintf (key, sizeof key, "plugin%d_control%d", i, ci); loaded->values[ci] = aud_get_double ("ladspa", key); aud_set_str ("ladspa", key, ""); } } str_unref (controls); } str_unref (path); str_unref (label); } }
int oss_open_audio(int aud_format, int rate, int channels) { AUDDBG("Opening audio.\n"); int format; int vol_left, vol_right; audio_buf_info buf_info; CHECK_NOISY(oss_data->fd = open_device); format = oss_convert_aud_format(aud_format); if (!set_format(format, rate, channels)) goto FAILED; CHECK_NOISY(ioctl, oss_data->fd, SNDCTL_DSP_GETOSPACE, &buf_info); AUDDBG("Buffer information, fragstotal: %d, fragsize: %d, bytes: %d.\n", buf_info.fragstotal, buf_info.fragsize, buf_info.bytes); oss_time = 0; oss_paused = FALSE; oss_paused_time = 0; oss_delay = oss_bytes_to_frames(buf_info.fragstotal * buf_info.fragsize) * 1000 / oss_data->rate; oss_ioctl_vol = TRUE; AUDDBG("Internal OSS buffer size: %dms.\n", oss_delay); if (aud_get_bool("oss4", "save_volume")) { vol_right = (aud_get_int("oss4", "volume") & 0xFF00) >> 8; vol_left = (aud_get_int("oss4", "volume") & 0x00FF); oss_set_volume(vol_left, vol_right); }
int sdlout_open_audio (int format, int rate, int chan) { if (format != FMT_S16_NE) { sdlout_error ("Only signed 16-bit, native endian audio is supported.\n"); return 0; } AUDDBG ("Opening audio for %d channels, %d Hz.\n", chan, rate); sdlout_chan = chan; sdlout_rate = rate; buffer_size = 2 * chan * (aud_get_int (NULL, "output_buffer_size") * rate / 1000); buffer = g_malloc (buffer_size); buffer_data_start = 0; buffer_data_len = 0; frames_written = 0; prebuffer_flag = 1; paused_flag = 0; SDL_AudioSpec spec = { .freq = rate, .format = AUDIO_S16, .channels = chan, .samples = 4096, .callback = callback, .userdata = NULL}; if (SDL_OpenAudio (& spec, NULL) < 0) { sdlout_error ("Failed to open audio stream: %s.\n", SDL_GetError ()); g_free (buffer); buffer = NULL; return 0; } return 1; } void sdlout_close_audio (void) { AUDDBG ("Closing audio.\n"); SDL_CloseAudio (); g_free (buffer); buffer = NULL; }
static void save_enabled_to_config (void) { int count = index_count (loadeds); int old_count = aud_get_int ("ladspa", "plugin_count"); aud_set_int ("ladspa", "plugin_count", count); for (int i = 0; i < count; i ++) { LoadedPlugin * loaded = index_get (loadeds, 0); char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); aud_set_str ("ladspa", key, loaded->plugin->path); snprintf (key, sizeof key, "plugin%d_label", i); aud_set_str ("ladspa", key, loaded->plugin->desc->Label); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; for (int ci = 0; ci < ccount; ci ++) temp[ci] = loaded->values[ci]; char * controls = double_array_to_str (temp, ccount); aud_set_str ("ladspa", key, controls); str_unref (controls); disable_plugin_locked (0); } for (int i = count; i < old_count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); aud_set_str ("ladspa", key, ""); snprintf (key, sizeof key, "plugin%d_label", i); aud_set_str ("ladspa", key, ""); snprintf (key, sizeof key, "plugin%d_controls", i); aud_set_str ("ladspa", key, ""); } }
static gboolean file_init (void) { aud_config_set_defaults ("filewriter", filewriter_defaults); fileext = aud_get_int ("filewriter", "fileext"); filenamefromtags = aud_get_bool ("filewriter", "filenamefromtags"); file_path = aud_get_string ("filewriter", "file_path"); prependnumber = aud_get_bool ("filewriter", "prependnumber"); save_original = aud_get_bool ("filewriter", "save_original"); use_suffix = aud_get_bool ("filewriter", "use_suffix"); if (! file_path[0]) { g_return_val_if_fail (getenv ("HOME") != NULL, FALSE); file_path = g_filename_to_uri (getenv ("HOME"), NULL, NULL); g_return_val_if_fail (file_path != NULL, FALSE); } set_plugin(); if (plugin->init) plugin->init(&file_write_output); return TRUE; }
static int open_handle (struct neon_handle * handle, uint64_t startbyte) { int ret; char * proxy_host = NULL; int proxy_port = 0; bool_t use_proxy = aud_get_bool (NULL, "use_proxy"); bool_t use_proxy_auth = aud_get_bool (NULL, "use_proxy_auth"); if (use_proxy) { proxy_host = aud_get_str (NULL, "proxy_host"); proxy_port = aud_get_int (NULL, "proxy_port"); } handle->redircount = 0; _DEBUG ("<%p> Parsing URL", handle); if (ne_uri_parse (handle->url, handle->purl) != 0) { _ERROR ("<%p> Could not parse URL '%s'", (void *) handle, handle->url); return -1; } while (handle->redircount < 10) { if (! handle->purl->port) handle->purl->port = ne_uri_defaultport (handle->purl->scheme); _DEBUG ("<%p> Creating session to %s://%s:%d", handle, handle->purl->scheme, handle->purl->host, handle->purl->port); handle->session = ne_session_create (handle->purl->scheme, handle->purl->host, handle->purl->port); ne_redirect_register (handle->session); ne_add_server_auth (handle->session, NE_AUTH_BASIC, server_auth_callback, (void *) handle); ne_set_session_flag (handle->session, NE_SESSFLAG_ICYPROTO, 1); ne_set_session_flag (handle->session, NE_SESSFLAG_PERSIST, 0); #ifdef HAVE_NE_SET_CONNECT_TIMEOUT ne_set_connect_timeout (handle->session, 10); #endif ne_set_read_timeout (handle->session, 10); ne_set_useragent (handle->session, "Audacious/" PACKAGE_VERSION); if (use_proxy) { _DEBUG ("<%p> Using proxy: %s:%d", handle, proxy_host, proxy_port); ne_session_proxy (handle->session, proxy_host, proxy_port); if (use_proxy_auth) { _DEBUG ("<%p> Using proxy authentication", handle); ne_add_proxy_auth (handle->session, NE_AUTH_BASIC, neon_proxy_auth_cb, (void *) handle); } } if (! strcmp ("https", handle->purl->scheme)) { ne_ssl_trust_default_ca (handle->session); ne_ssl_set_verify (handle->session, neon_vfs_verify_environment_ssl_certs, handle->session); } _DEBUG ("<%p> Creating request", handle); ret = open_request (handle, startbyte); if (! ret) { str_unref (proxy_host); return 0; } if (ret == -1) { ne_session_destroy (handle->session); handle->session = NULL; str_unref (proxy_host); return -1; } _DEBUG ("<%p> Following redirect...", handle); ne_session_destroy (handle->session); handle->session = NULL; } /* If we get here, our redirect count exceeded */ _ERROR ("<%p> Redirect count exceeded for URL %s", (void *) handle, handle->url); str_unref (proxy_host); return 1; }
static void modplug_settings_load () { aud_config_set_defaults (MODPLUG_CFGID, modplug_defaults); modplug_settings.mBits = aud_get_int (MODPLUG_CFGID, "Bits"); modplug_settings.mChannels = aud_get_int (MODPLUG_CFGID, "Channels"); modplug_settings.mResamplingMode = aud_get_int (MODPLUG_CFGID, "ResamplingMode"); modplug_settings.mFrequency = aud_get_int (MODPLUG_CFGID, "Frequency"); modplug_settings.mReverb = aud_get_bool (MODPLUG_CFGID, "Reverb"); modplug_settings.mReverbDepth = aud_get_int (MODPLUG_CFGID, "ReverbDepth"); modplug_settings.mReverbDelay = aud_get_int (MODPLUG_CFGID, "ReverbDelay"); modplug_settings.mMegabass = aud_get_bool (MODPLUG_CFGID, "Megabass"); modplug_settings.mBassAmount = aud_get_int (MODPLUG_CFGID, "BassAmount"); modplug_settings.mBassRange = aud_get_int (MODPLUG_CFGID, "BassRange"); modplug_settings.mSurround = aud_get_bool (MODPLUG_CFGID, "Surround"); modplug_settings.mSurroundDepth = aud_get_int (MODPLUG_CFGID, "SurroundDepth"); modplug_settings.mSurroundDelay = aud_get_int (MODPLUG_CFGID, "SurroundDelay"); modplug_settings.mPreamp = aud_get_bool (MODPLUG_CFGID, "PreAmp"); modplug_settings.mPreampLevel = aud_get_double (MODPLUG_CFGID, "PreAmpLevel"); modplug_settings.mOversamp = aud_get_bool (MODPLUG_CFGID, "Oversampling"); modplug_settings.mNoiseReduction = aud_get_bool (MODPLUG_CFGID, "NoiseReduction"); modplug_settings.mGrabAmigaMOD = aud_get_bool (MODPLUG_CFGID, "GrabAmigaMOD"); modplug_settings.mLoopCount = aud_get_int (MODPLUG_CFGID, "LoopCount"); }
void crossfade_config_load (void) { aud_config_set_defaults ("crossfade", crossfade_defaults); crossfade_length = aud_get_int ("crossfade", "length"); }
static int mixer_init (void) { aud_config_set_defaults ("mixer", mixer_defaults); mixer_channels = aud_get_int ("mixer", "channels"); return 1; }
EXPORT void audgui_playlist_manager (void) { GtkWidget * playman_vbox; GtkWidget * playman_pl_lv, * playman_pl_lv_sw; GtkWidget * playman_button_hbox; GtkWidget * new_button, * delete_button, * rename_button, * play_button; GtkWidget * hbox, * check_button; GdkGeometry playman_win_hints; if (playman_win) { gtk_window_present ((GtkWindow *) playman_win); return; } playman_win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_type_hint ((GtkWindow *) playman_win, GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_title ((GtkWindow *) playman_win, _("Playlist Manager")); gtk_container_set_border_width ((GtkContainer *) playman_win, 6); playman_win_hints.min_width = 400; playman_win_hints.min_height = 250; gtk_window_set_geometry_hints ((GtkWindow *) playman_win, playman_win, &playman_win_hints , GDK_HINT_MIN_SIZE); int x = aud_get_int ("audgui", "playlist_manager_x"); int y = aud_get_int ("audgui", "playlist_manager_y"); int w = aud_get_int ("audgui", "playlist_manager_w"); int h = aud_get_int ("audgui", "playlist_manager_h"); if (w && h) { gtk_window_move ((GtkWindow *) playman_win, x, y); gtk_window_set_default_size ((GtkWindow *) playman_win, w, h); } g_signal_connect (playman_win, "delete-event", (GCallback) hide_cb, NULL); audgui_hide_on_escape (playman_win); playman_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_container_add ((GtkContainer *) playman_win, playman_vbox); /* ListView */ playman_pl_lv = audgui_list_new (& callbacks, NULL, aud_playlist_count ()); audgui_list_add_column (playman_pl_lv, _("Title"), 0, G_TYPE_STRING, -1); audgui_list_add_column (playman_pl_lv, _("Entries"), 1, G_TYPE_INT, 7); audgui_list_set_highlight (playman_pl_lv, aud_playlist_get_playing ()); gtk_tree_view_set_search_equal_func ((GtkTreeView *) playman_pl_lv, search_cb, NULL, NULL); hook_associate ("playlist update", update_hook, playman_pl_lv); hook_associate ("playlist activate", activate_hook, playman_pl_lv); hook_associate ("playlist set playing", position_hook, playman_pl_lv); playman_pl_lv_sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_SHADOW_IN); gtk_scrolled_window_set_policy ((GtkScrolledWindow *) playman_pl_lv_sw, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add ((GtkContainer *) playman_pl_lv_sw, playman_pl_lv); gtk_box_pack_start ((GtkBox *) playman_vbox, playman_pl_lv_sw, TRUE, TRUE, 0); /* ButtonBox */ playman_button_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); new_button = gtk_button_new_from_stock (GTK_STOCK_NEW); delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE); rename_button = gtk_button_new_with_mnemonic (_("_Rename")); gtk_button_set_image ((GtkButton *) rename_button, gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON)); play_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); gtk_container_add ((GtkContainer *) playman_button_hbox, new_button); gtk_container_add ((GtkContainer *) playman_button_hbox, delete_button); gtk_box_pack_end ((GtkBox *) playman_button_hbox, play_button, FALSE, FALSE, 0); gtk_box_pack_end ((GtkBox *) playman_button_hbox, rename_button, FALSE, FALSE, 0); gtk_container_add ((GtkContainer *) playman_vbox, playman_button_hbox); g_signal_connect (new_button, "clicked", (GCallback) new_cb, NULL); g_signal_connect (delete_button, "clicked", (GCallback) delete_cb, NULL); g_signal_connect (rename_button, "clicked", (GCallback) rename_cb, NULL); g_signal_connect (play_button, "clicked", (GCallback) play_cb, NULL); /* CheckButton */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start ((GtkBox *) playman_vbox, hbox, FALSE, FALSE, 0); check_button = gtk_check_button_new_with_mnemonic (_("_Close dialog on activating playlist")); gtk_box_pack_start ((GtkBox *) hbox, check_button, FALSE, FALSE, 0); gtk_toggle_button_set_active ((GtkToggleButton *) check_button, aud_get_bool ("audgui", "playlist_manager_close_on_activate")); g_signal_connect (check_button, "toggled", (GCallback) close_on_activate_cb, NULL); gtk_widget_show_all (playman_win); hook_associate ("config save", save_config_cb, playman_win); }
static gboolean lirc_input_callback (GIOChannel * source, GIOCondition condition, void * data) { char *code; char *c; gint playlist_time, playlist_pos, output_time, v; int ret; char *ptr; gint balance; #if 0 gboolean show_pl; #endif int n; gchar *utf8_title_markup; while ((ret = lirc_nextcode (&code)) == 0 && code != NULL) { while ((ret = lirc_code2char (config, code, &c)) == 0 && c != NULL) { if (strcasecmp ("PLAY", c) == 0) aud_drct_play (); else if (strcasecmp ("STOP", c) == 0) aud_drct_stop (); else if (strcasecmp ("PAUSE", c) == 0) aud_drct_pause (); else if (strcasecmp ("PLAYPAUSE", c) == 0) aud_drct_play_pause (); else if (strncasecmp ("NEXT", c, 4) == 0) { ptr = c + 4; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 1; for (; n > 0; n--) { aud_drct_pl_next (); } } else if (strncasecmp ("PREV", c, 4) == 0) { ptr = c + 4; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 1; for (; n > 0; n--) { aud_drct_pl_prev (); } } else if (strcasecmp ("SHUFFLE", c) == 0) aud_set_bool (NULL, "shuffle", ! aud_get_bool (NULL, "shuffle")); else if (strcasecmp ("REPEAT", c) == 0) aud_set_bool (NULL, "repeat", ! aud_get_bool (NULL, "repeat")); else if (strncasecmp ("FWD", c, 3) == 0) { ptr = c + 3; while (isspace (*ptr)) ptr++; n = atoi (ptr) * 1000; if (n <= 0) n = 5000; output_time = aud_drct_get_time (); int playlist = aud_playlist_get_active (); playlist_pos = aud_playlist_get_position (playlist); playlist_time = aud_playlist_entry_get_length (playlist, playlist_pos, FALSE); if (playlist_time - output_time < n) output_time = playlist_time - n; aud_drct_seek (output_time + n); } else if (strncasecmp ("BWD", c, 3) == 0) { ptr = c + 3; while (isspace (*ptr)) ptr++; n = atoi (ptr) * 1000; if (n <= 0) n = 5000; output_time = aud_drct_get_time (); if (output_time < n) output_time = n; aud_drct_seek (output_time - n); } else if (strncasecmp ("VOL_UP", c, 6) == 0) { ptr = c + 6; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 5; aud_drct_get_volume_main (&v); if (v > (100 - n)) v = 100 - n; aud_drct_set_volume_main (v + n); } else if (strncasecmp ("VOL_DOWN", c, 8) == 0) { ptr = c + 8; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 5; aud_drct_get_volume_main (&v); if (v < n) v = n; aud_drct_set_volume_main (v - n); } else if (strcasecmp ("QUIT", c) == 0) { aud_drct_quit (); } else if (strcasecmp ("MUTE", c) == 0) { if (mute == 0) { mute = 1; /* store the master volume so we can restore it on unmute. */ aud_drct_get_volume_main (&mute_vol); aud_drct_set_volume_main (0); } else { mute = 0; aud_drct_set_volume_main (mute_vol); } } else if (strncasecmp ("BAL_LEFT", c, 8) == 0) { ptr = c + 8; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 5; aud_drct_get_volume_balance (&balance); balance -= n; if (balance < -100) balance = -100; aud_drct_set_volume_balance (balance); } else if (strncasecmp ("BAL_RIGHT", c, 9) == 0) { ptr = c + 9; while (isspace (*ptr)) ptr++; n = atoi (ptr); if (n <= 0) n = 5; aud_drct_get_volume_balance (&balance); balance += n; if (balance > 100) balance = 100; aud_drct_set_volume_balance (balance); } else if (strcasecmp ("BAL_CENTER", c) == 0) { balance = 0; aud_drct_set_volume_balance (balance); } else if (strcasecmp ("LIST", c) == 0) { #if 0 show_pl = aud_drct_pl_win_is_visible (); show_pl = (show_pl) ? 0 : 1; aud_drct_pl_win_toggle (show_pl); #endif } else if (strcasecmp ("PLAYLIST_CLEAR", c) == 0) { aud_drct_stop (); int playlist = aud_playlist_get_active (); aud_playlist_entry_delete (playlist, 0, aud_playlist_entry_count (playlist)); } else if (strncasecmp ("PLAYLIST_ADD ", c, 13) == 0) { aud_drct_pl_add (c + 13, -1); } else if ((strlen (c) == 1) && ((*c >= '0') || (*c <= '9'))) { if (track_no_pos < 63) { if (tid) g_source_remove (tid); track_no[track_no_pos++] = *c; track_no[track_no_pos] = 0; tid = g_timeout_add (1500, jump_to, NULL); utf8_title_markup = g_markup_printf_escaped ("%s", track_no); hook_call ("aosd toggle", utf8_title_markup); } } else { fprintf (stderr, _("%s: unknown command \"%s\"\n"), plugin_name, c); } } free (code); if (ret == -1) break; } if (ret == -1) { /* something went badly wrong */ fprintf (stderr, _("%s: disconnected from LIRC\n"), plugin_name); cleanup (); if (aud_get_bool ("lirc", "enable_reconnect")) { int reconnect_timeout = aud_get_int ("lirc", "reconnect_timeout"); fprintf (stderr, _("%s: will try reconnect every %d seconds...\n"), plugin_name, reconnect_timeout); g_timeout_add (1000 * reconnect_timeout, reconnect_lirc, NULL); } } return TRUE; }
static void mp3_init(write_output_callback write_output_func) { aud_config_set_defaults ("filewriter_mp3", mp3_defaults); vbr_on = aud_get_int ("filewriter_mp3", "vbr_on"); vbr_type = aud_get_int ("filewriter_mp3", "vbr_type"); vbr_min_val = aud_get_int ("filewriter_mp3", "vbr_min_val"); vbr_max_val = aud_get_int ("filewriter_mp3", "vbr_max_val"); enforce_min_val = aud_get_int ("filewriter_mp3", "enforce_min_val"); vbr_quality_val = aud_get_int ("filewriter_mp3", "vbr_quality_val"); abr_val = aud_get_int ("filewriter_mp3", "abr_val"); toggle_xing_val = aud_get_int ("filewriter_mp3", "toggle_xing_val"); mark_original_val = aud_get_int ("filewriter_mp3", "mark_original_val"); mark_copyright_val = aud_get_int ("filewriter_mp3", "mark_copyright_val"); force_v2_val = aud_get_int ("filewriter_mp3", "force_v2_val"); only_v1_val = aud_get_int ("filewriter_mp3", "only_v1_val"); only_v2_val = aud_get_int ("filewriter_mp3", "only_v2_val"); algo_quality_val = aud_get_int ("filewriter_mp3", "algo_quality_val"); out_samplerate_val = aud_get_int ("filewriter_mp3", "out_samplerate_val"); bitrate_val = aud_get_int ("filewriter_mp3", "bitrate_val"); compression_val = aud_get_double ("filewriter_mp3", "compression_val"); enc_toggle_val = aud_get_int ("filewriter_mp3", "enc_toggle_val"); audio_mode_val = aud_get_int ("filewriter_mp3", "audio_mode_val"); enforce_iso_val = aud_get_int ("filewriter_mp3", "enforce_iso_val"); error_protect_val = aud_get_int ("filewriter_mp3", "error_protect_val"); if (write_output_func) write_output=write_output_func; }
gint aosd_cfg_load ( aosd_cfg_t * cfg ) { aud_config_set_defaults ("aosd", aosd_defaults); gint i = 0; gint max_numcol; gchar *trig_active_str; /* position */ cfg->osd->position.placement = aud_get_int ("aosd", "position_placement"); cfg->osd->position.offset_x = aud_get_int ("aosd", "position_offset_x"); cfg->osd->position.offset_y = aud_get_int ("aosd", "position_offset_y"); cfg->osd->position.maxsize_width = aud_get_int ("aosd", "position_maxsize_width"); cfg->osd->position.multimon_id = aud_get_int ("aosd", "position_multimon_id"); /* animation */ cfg->osd->animation.timing_display = aud_get_int ("aosd", "animation_timing_display"); cfg->osd->animation.timing_fadein = aud_get_int ("aosd", "animation_timing_fadein"); cfg->osd->animation.timing_fadeout = aud_get_int ("aosd", "animation_timing_fadeout"); /* text */ for ( i = 0 ; i < AOSD_TEXT_FONTS_NUM ; i++ ) { gchar *color_str = NULL; gchar *key_str = NULL; key_str = g_strdup_printf( "text_fonts_name_%i" , i ); cfg->osd->text.fonts_name[i] = aud_get_string ("aosd", key_str); g_free( key_str ); key_str = g_strdup_printf( "text_fonts_color_%i" , i ); color_str = aud_get_string ("aosd", key_str); aosd_cfg_util_str_to_color( color_str , &(cfg->osd->text.fonts_color[i]) ); g_free( key_str ); g_free( color_str ); key_str = g_strdup_printf( "text_fonts_draw_shadow_%i" , i ); cfg->osd->text.fonts_draw_shadow[i] = aud_get_bool ("aosd", key_str); g_free( key_str ); key_str = g_strdup_printf( "text_fonts_shadow_color_%i" , i ); color_str = aud_get_string ("aosd", key_str); aosd_cfg_util_str_to_color( color_str , &(cfg->osd->text.fonts_shadow_color[i]) ); g_free( key_str ); g_free( color_str ); } cfg->osd->text.utf8conv_disable = aud_get_bool ("aosd", "text_utf8conv_disable"); /* decoration */ cfg->osd->decoration.code = aud_get_int ("aosd", "decoration_code"); /* TODO not implemented yet if ( !aud_cfg_db_get_string( cfgfile , "aosd" , "decoration_skin_file" , &(cfg->osd->decoration.skin_file) ) ) cfg->osd->decoration.skin_file = g_strdup( "" ); */ /* decoration - colors */ max_numcol = aosd_deco_style_get_max_numcol(); for ( i = 0 ; i < max_numcol ; i++ ) { gchar *key_str = NULL; gchar *color_str = NULL; aosd_color_t color; key_str = g_strdup_printf( "decoration_color_%i" , i ); color_str = aud_get_string ("aosd", key_str); aosd_cfg_util_str_to_color( color_str , &color ); g_array_insert_val( cfg->osd->decoration.colors , i , color ); } /* trigger */ trig_active_str = aud_get_string ("aosd", "trigger_active"); if (strcmp (trig_active_str, "x")) { gchar **trig_active_strv = g_strsplit( trig_active_str , "," , 0 ); gint j = 0; while ( trig_active_strv[j] != NULL ) { gint trig_active_val = strtol( trig_active_strv[j] , NULL , 10 ); g_array_append_val( cfg->osd->trigger.active , trig_active_val ); j++; } g_strfreev( trig_active_strv ); } g_free (trig_active_str); /* miscellanous */ cfg->osd->misc.transparency_mode = aud_get_int ("aosd", "transparency_mode"); /* the config object has been filled with information */ cfg->set = TRUE; return 0; }
static int pulse_open(int fmt, int rate, int nch) { pa_sample_spec ss; pa_operation *o = NULL; int success; assert(!mainloop); assert(!context); assert(!stream); assert(!connected); switch(fmt) { case FMT_U8: ss.format = PA_SAMPLE_U8; break; case FMT_S16_LE: ss.format = PA_SAMPLE_S16LE; break; case FMT_S16_BE: ss.format = PA_SAMPLE_S16BE; break; #ifdef PA_SAMPLE_S24_32LE case FMT_S24_LE: ss.format = PA_SAMPLE_S24_32LE; break; case FMT_S24_BE: ss.format = PA_SAMPLE_S24_32BE; break; #endif #ifdef PA_SAMPLE_S32LE case FMT_S32_LE: ss.format = PA_SAMPLE_S32LE; break; case FMT_S32_BE: ss.format = PA_SAMPLE_S32BE; break; #endif case FMT_FLOAT: ss.format = PA_SAMPLE_FLOAT32NE; break; default: return FALSE; } ss.rate = rate; ss.channels = nch; if (!pa_sample_spec_valid(&ss)) return FALSE; if (!(mainloop = pa_threaded_mainloop_new())) { ERROR ("Failed to allocate main loop"); goto fail; } pa_threaded_mainloop_lock(mainloop); if (!(context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), "Audacious"))) { ERROR ("Failed to allocate context"); goto unlock_and_fail; } pa_context_set_state_callback(context, context_state_cb, NULL); pa_context_set_subscribe_callback(context, subscribe_cb, NULL); if (pa_context_connect(context, NULL, 0, NULL) < 0) { ERROR ("Failed to connect to server: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } if (pa_threaded_mainloop_start(mainloop) < 0) { ERROR ("Failed to start main loop"); goto unlock_and_fail; } /* Wait until the context is ready */ pa_threaded_mainloop_wait(mainloop); if (pa_context_get_state(context) != PA_CONTEXT_READY) { ERROR ("Failed to connect to server: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } if (!(stream = pa_stream_new(context, "Audacious", &ss, NULL))) { ERROR ("Failed to create stream: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } pa_stream_set_state_callback(stream, stream_state_cb, NULL); pa_stream_set_write_callback(stream, stream_request_cb, NULL); pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL); /* Connect stream with sink and default volume */ /* Buffer struct */ int aud_buffer = aud_get_int(NULL, "output_buffer_size"); size_t buffer_size = pa_usec_to_bytes(aud_buffer, &ss) * 1000; pa_buffer_attr buffer = {(uint32_t) -1, buffer_size, (uint32_t) -1, (uint32_t) -1, buffer_size}; if (pa_stream_connect_playback(stream, NULL, &buffer, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0) { ERROR ("Failed to connect stream: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } /* Wait until the stream is ready */ pa_threaded_mainloop_wait(mainloop); if (pa_stream_get_state(stream) != PA_STREAM_READY) { ERROR ("Failed to connect stream: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } /* Now subscribe to events */ if (!(o = pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK_INPUT, context_success_cb, &success))) { ERROR ("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } success = 0; while (pa_operation_get_state(o) != PA_OPERATION_DONE) { CHECK_DEAD_GOTO(fail, 1); pa_threaded_mainloop_wait(mainloop); } if (!success) { ERROR ("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } pa_operation_unref(o); /* Now request the initial stream info */ if (!(o = pa_context_get_sink_input_info(context, pa_stream_get_index(stream), info_cb, NULL))) { ERROR ("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } while (pa_operation_get_state(o) != PA_OPERATION_DONE) { CHECK_DEAD_GOTO(fail, 1); pa_threaded_mainloop_wait(mainloop); } if (!volume_valid) { ERROR ("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context))); goto unlock_and_fail; } pa_operation_unref(o); do_trigger = 0; written = 0; flush_time = 0; bytes_per_second = FMT_SIZEOF (fmt) * nch * rate; connected = 1; volume_time_event = NULL; pa_threaded_mainloop_unlock(mainloop); return TRUE; unlock_and_fail: if (o) pa_operation_unref(o); pa_threaded_mainloop_unlock(mainloop); fail: pulse_close(); return FALSE; }