static bool modplug_scan_stream(struct input_stream *is, const struct tag_handler *handler, void *handler_ctx) { ModPlugFile *f; GByteArray *bdatas; bdatas = mod_loadfile(NULL, is); if (!bdatas) return false; f = ModPlug_Load(bdatas->data, bdatas->len); g_byte_array_free(bdatas, TRUE); if (f == NULL) return false; tag_handler_invoke_duration(handler, handler_ctx, ModPlug_GetLength(f) / 1000); const char *title = ModPlug_GetName(f); if (title != NULL) tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title); ModPlug_Unload(f); return true; }
static bool mad_decoder_scan_stream(struct input_stream *is, const struct tag_handler *handler, void *handler_ctx) { int total_time; total_time = mad_decoder_total_file_time(is); if (total_time < 0) return false; tag_handler_invoke_duration(handler, handler_ctx, total_time); return true; }
static bool vorbis_scan_stream(struct input_stream *is, const struct tag_handler *handler, void *handler_ctx) { struct vorbis_input_stream vis; OggVorbis_File vf; if (!vorbis_is_open(&vis, &vf, NULL, is)) return false; tag_handler_invoke_duration(handler, handler_ctx, (int)(ov_time_total(&vf, -1) + 0.5)); vorbis_comments_scan(ov_comment(&vf, -1)->user_comments, handler, handler_ctx); ov_clear(&vf); return true; }
static bool sndfile_scan_file(const char *path_fs, const struct tag_handler *handler, void *handler_ctx) { SNDFILE *sf; SF_INFO info; const char *p; info.format = 0; sf = sf_open(path_fs, SFM_READ, &info); if (sf == NULL) return false; if (!audio_valid_sample_rate(info.samplerate)) { sf_close(sf); g_warning("Invalid sample rate in %s\n", path_fs); return false; } tag_handler_invoke_duration(handler, handler_ctx, info.frames / info.samplerate); p = sf_get_string(sf, SF_STR_TITLE); if (p != NULL) tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, p); p = sf_get_string(sf, SF_STR_ARTIST); if (p != NULL) tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST, p); p = sf_get_string(sf, SF_STR_DATE); if (p != NULL) tag_handler_invoke_tag(handler, handler_ctx, TAG_DATE, p); sf_close(sf); return true; }