static PluginHandle * get_plugin (const char * filename, bool_t saving) { const char * ext = get_extension (filename); PluginHandle * plugin = ext ? playlist_plugin_for_extension (ext) : NULL; if (! plugin) { char * error = str_printf (_("Cannot %s %s: unsupported file " "extension."), saving ? _("save") : _("load"), filename); interface_show_error (error); str_unref (error); return NULL; } return plugin; }
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; }
Index * import_winamp_eqf (VFSFile * file) { char header[31]; char bands[11]; int i = 0; EqualizerPreset *preset = NULL; char *markup; char preset_name[0xb4]; if (vfs_fread (header, 1, sizeof header, file) != sizeof header || strncmp (header, "Winamp EQ library file v1.1", 27)) goto error; AUDDBG("The EQF header is OK\n"); if (vfs_fseek(file, 0x1f, SEEK_SET) == -1) goto error; Index * list = index_new (); while (vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) { AUDDBG("The preset name is '%s'\n", preset_name); if (vfs_fseek (file, 0x4d, SEEK_CUR)) /* unknown crap --asphyx */ break; if (vfs_fread(bands, 1, 11, file) != 11) break; preset = equalizer_preset_new(preset_name); /*this was divided by 63, but shouldn't it be 64? --majeru*/ preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); for (i = 0; i < 10; i++) preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0); index_append (list, preset); } return list; error: markup = g_strdup_printf (_("Error importing Winamp EQF file '%s'"), vfs_get_filename (file)); interface_show_error(markup); g_free(markup); return NULL; }