Open a modplug file. Definition at line 87 of file audio_format_modplug.c. 00088 { 00089 struct modplug_drv_data *data; 00090 const char *title; 00091 00092 /* libmodplug doesn't have good magic. Match by extension */ 00093 if (ext == NULL) 00094 return (-1); 00095 if (g_ascii_strcasecmp(ext, "mod") != 0 && 00096 g_ascii_strcasecmp(ext, "s3m") != 0 && 00097 g_ascii_strcasecmp(ext, "it") != 0 && 00098 g_ascii_strcasecmp(ext, "xm") != 0) 00099 return (-1); 00100 00101 /* If only we could memory map the internet... */ 00102 if (fd->stream) 00103 return (-1); 00104 00105 data = g_slice_new(struct modplug_drv_data); 00106 00107 /* Calculate file length */ 00108 fseek(fd->fp, 0, SEEK_END); 00109 data->map_len = ftello(fd->fp); 00110 00111 /* Memory map the entire file */ 00112 data->map_base = mmap(NULL, data->map_len, PROT_READ, 00113 MAP_PRIVATE, fileno(fd->fp), 0); 00114 if (data->map_base == MAP_FAILED) 00115 goto free; 00116 00117 /* Now feed it to modplug */ 00118 modplug_init(); 00119 data->modplug = ModPlug_Load(data->map_base, data->map_len); 00120 if (data->modplug != NULL) { 00121 data->sample = 0; 00122 fd->drv_data = data; 00123 fd->srate = SAMPLERATE; 00124 fd->channels = 2; 00125 00126 fd->time_len = ModPlug_GetLength(data->modplug) / 1000; 00127 title = ModPlug_GetName(data->modplug); 00128 if (title != NULL && title[0] != '\0') 00129 fd->title = g_strdup(title); 00130 return (0); 00131 } 00132 00133 munmap(data->map_base, data->map_len); 00134 free: g_slice_free(struct modplug_drv_data, data); 00135 return (1); 00136 }
Here is the call graph for this function:
![]() |
1.6.3