static void general_load (PluginHandle * plugin) { GList * node = g_list_find_custom (loaded_general_plugins, plugin, (GCompareFunc) general_find_cb); if (node != NULL) return; AUDDBG ("Loading %s.\n", plugin_get_name (plugin)); GeneralPlugin * gp = plugin_get_header (plugin); g_return_if_fail (gp != NULL); LoadedGeneral * general = g_slice_new (LoadedGeneral); general->plugin = plugin; general->gp = gp; general->widget = NULL; if (gp->get_widget != NULL) general->widget = gp->get_widget (); if (general->widget != NULL) { AUDDBG ("Adding %s to interface.\n", plugin_get_name (plugin)); g_signal_connect (general->widget, "destroy", (GCallback) gtk_widget_destroyed, & general->widget); interface_add_plugin_widget (plugin, general->widget); } loaded_general_plugins = g_list_prepend (loaded_general_plugins, general); }
void effect_plugin_stop (PluginHandle * plugin) { if (playback_get_playing ()) { EffectPlugin * ep = plugin_get_header (plugin); g_return_if_fail (ep != NULL); effect_enable (plugin, ep, FALSE); } }
static VFSConstructor * lookup_transport (const char * scheme) { PluginHandle * plugin = transport_plugin_for_scheme (scheme); if (! plugin) return NULL; TransportPlugin * tp = plugin_get_header (plugin); return tp ? tp->vtable : NULL; }
bool_t effect_plugin_start (PluginHandle * plugin) { if (playback_get_playing ()) { EffectPlugin * ep = plugin_get_header (plugin); g_return_val_if_fail (ep != NULL, FALSE); effect_enable (plugin, ep, TRUE); } return TRUE; }
void plugin_do_configure (PluginHandle * plugin) { g_return_if_fail (plugin_get_enabled (plugin)); Plugin * header = plugin_get_header (plugin); g_return_if_fail (header); if (PLUGIN_HAS_FUNC (header, configure)) header->configure (); else if (PLUGIN_HAS_FUNC (header, prefs)) plugin_make_config_window (plugin); }
void plugin_do_about (PluginHandle * plugin) { g_return_if_fail (plugin_get_enabled (plugin)); Plugin * header = plugin_get_header (plugin); g_return_if_fail (header); if (PLUGIN_HAS_FUNC (header, about)) header->about (); else if (PLUGIN_HAS_FUNC (header, about_text)) plugin_make_about_window (plugin); }
int plugin_send_message (PluginHandle * plugin, const char * code, const void * data, int size) { if (! plugin_get_enabled (plugin)) return ENOSYS; Plugin * header = plugin_get_header (plugin); if (! header || ! PLUGIN_HAS_FUNC (header, take_message)) return ENOSYS; return header->take_message (code, data, size); }
void general_plugin_stop (PluginHandle * plugin) { GeneralPlugin * gp = plugin_get_header (plugin); g_return_if_fail (gp != NULL); if (running) general_unload (plugin); if (gp->cleanup != NULL) gp->cleanup (); }
bool_t interface_load (PluginHandle * plugin) { IfacePlugin * i = plugin_get_header (plugin); g_return_val_if_fail (i, FALSE); if (PLUGIN_HAS_FUNC (i, init) && ! i->init ()) return FALSE; current_interface = i; return TRUE; }
bool_t general_plugin_start (PluginHandle * plugin) { GeneralPlugin * gp = plugin_get_header (plugin); g_return_val_if_fail (gp != NULL, FALSE); if (gp->init != NULL && ! gp->init ()) return FALSE; if (running) general_load (plugin); return TRUE; }
bool_t playlist_save (int list, const char * filename) { AUDDBG ("Saving playlist %s.\n", filename); PluginHandle * plugin = get_plugin (filename, TRUE); if (! plugin) return FALSE; PlaylistPlugin * pp = plugin_get_header (plugin); g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE); bool_t fast = get_bool (NULL, "metadata_on_play"); VFSFile * file = vfs_fopen (filename, "w"); if (! file) return FALSE; char * title = playlist_get_title (list); int entries = playlist_entry_count (list); Index * filenames = index_new (); index_allocate (filenames, entries); Index * tuples = index_new (); index_allocate (tuples, entries); for (int i = 0; i < entries; i ++) { index_append (filenames, playlist_entry_get_filename (list, i)); index_append (tuples, playlist_entry_get_tuple (list, i, fast)); } bool_t success = pp->save (filename, file, title, filenames, tuples); vfs_fclose (file); str_unref (title); for (int i = 0; i < entries; i ++) { str_unref (index_get (filenames, i)); Tuple * tuple = index_get (tuples, i); if (tuple) tuple_unref (tuple); } index_free (filenames); index_free (tuples); return success; }
static void * playback_thread (void * unused) { PluginHandle * p = playback_entry_get_decoder (); current_decoder = p ? plugin_get_header (p) : NULL; if (! current_decoder) { char * error = g_strdup_printf (_("No decoder found for %s."), current_filename); interface_show_error (error); g_free (error); playback_error = TRUE; goto DONE; } current_data = NULL; current_bitrate = 0; current_samplerate = 0; current_channels = 0; Tuple * tuple = playback_entry_get_tuple (); read_gain_from_tuple (tuple); if (tuple) tuple_unref (tuple); bool_t seekable = (playback_entry_get_length () > 0); VFSFile * file = vfs_fopen (current_filename, "r"); time_offset = seekable ? playback_entry_get_start_time () : 0; playback_error = ! current_decoder->play (& playback_api, current_filename, file, seekable ? time_offset + initial_seek : 0, seekable ? playback_entry_get_end_time () : -1, paused); output_close_audio (); if (file) vfs_fclose (file); DONE: if (! ready_flag) set_pb_ready (& playback_api); end_source = g_timeout_add (0, end_cb, NULL); return NULL; }
static bool_t effect_start_cb (PluginHandle * plugin, EffectStartState * state) { AUDDBG ("Starting %s at %d channels, %d Hz.\n", plugin_get_name (plugin), * state->channels, * state->rate); EffectPlugin * header = plugin_get_header (plugin); g_return_val_if_fail (header != NULL, TRUE); header->start (state->channels, state->rate); RunningEffect * effect = g_malloc (sizeof (RunningEffect)); effect->plugin = plugin; effect->header = header; effect->channels_returned = * state->channels; effect->rate_returned = * state->rate; effect->remove_flag = FALSE; running_effects = g_list_prepend (running_effects, effect); return TRUE; }
bool_t playlist_load (const char * filename, char * * title, Index * * filenames_p, Index * * tuples_p) { AUDDBG ("Loading playlist %s.\n", filename); PluginHandle * plugin = get_plugin (filename, FALSE); if (! plugin) return FALSE; PlaylistPlugin * pp = plugin_get_header (plugin); g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE); VFSFile * file = vfs_fopen (filename, "r"); if (! file) return FALSE; Index * filenames = index_new (); Index * tuples = index_new (); bool_t success = pp->load (filename, file, title, filenames, tuples); vfs_fclose (file); if (! success) { index_free (filenames); index_free (tuples); return FALSE; } if (index_count (tuples)) g_return_val_if_fail (index_count (tuples) == index_count (filenames), FALSE); else { index_free (tuples); tuples = NULL; } * filenames_p = filenames; * tuples_p = tuples; return TRUE; }