示例#1
0
static Tuple *probe_for_tuple(const char *filename, VFSFile *file)
{
	int song = -1;
	unsigned char module[ASAPInfo_MAX_MODULE_LENGTH];
	int module_len;
	ASAPInfo *info = NULL;
	Tuple *tuple = NULL;
	int songs;
	int duration;
	int year;

#if _AUD_PLUGIN_VERSION >= 10
	char *real_filename = filename_split_subtune(filename, &song);
	if (real_filename != NULL)
		filename = real_filename;
#endif
	module_len = load_module(filename, file, module);
	if (module_len > 0) {
		info = ASAPInfo_New();
		if (info != NULL && ASAPInfo_Load(info, filename, module, module_len))
			tuple = tuple_new_from_filename(filename);
	}
#if _AUD_PLUGIN_VERSION >= 10
	g_free(real_filename);
#endif
	if (tuple == NULL) {
		ASAPInfo_Delete(info);
		return NULL;
	}

	tuple_set_nonblank(tuple, FIELD_ARTIST, ASAPInfo_GetAuthor(info));
	tuple_set_nonblank(tuple, FIELD_TITLE, ASAPInfo_GetTitleOrFilename(info));
	tuple_set_nonblank(tuple, FIELD_DATE, ASAPInfo_GetDate(info));
	tuple_set_str(tuple, FIELD_CODEC, NULL, "ASAP");
	songs = ASAPInfo_GetSongs(info);
	if (song > 0) {
		tuple_set_int(tuple, FIELD_SUBSONG_ID, NULL, song);
		tuple_set_int(tuple, FIELD_SUBSONG_NUM, NULL, songs);
		song--;
	}
	else {
		if (songs > 1) {
#if _AUD_PLUGIN_VERSION >= 37
			tuple_set_subtunes(tuple, songs, NULL);
#else
			tuple->nsubtunes = songs;
#endif
		}
		song = ASAPInfo_GetDefaultSong(info);
	}
	duration = ASAPInfo_GetDuration(info, song);
	if (duration > 0)
		tuple_set_int(tuple, FIELD_LENGTH, NULL, duration);
	year = ASAPInfo_GetYear(info);
	if (year > 0)
		tuple_set_int(tuple, FIELD_YEAR, NULL, year);
	ASAPInfo_Delete(info);
	return tuple;
}
示例#2
0
static void setSaved(void)
{
	int i;
	_tcscpy(saved_author, ASAPInfo_GetAuthor(edited_info));
	_tcscpy(saved_title, ASAPInfo_GetTitle(edited_info));
	_tcscpy(saved_date, ASAPInfo_GetDate(edited_info));
	for (i = 0; i < ASAPInfo_GetSongs(edited_info); i++) {
		saved_durations[i] = ASAPInfo_GetDuration(edited_info, i);
		saved_loops[i] = ASAPInfo_GetLoop(edited_info, i);
	}
}
示例#3
0
	void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
	{
		int duration = get_song_duration(p_subsong, false);
		if (duration >= 0)
			p_info.set_length(duration / 1000.0);
		const ASAPInfo *info = ASAP_GetInfo(asap);
		p_info.info_set_int("channels", ASAPInfo_GetChannels(info));
		p_info.info_set_int("subsongs", ASAPInfo_GetSongs(info));
		meta_set(p_info, "composer", ASAPInfo_GetAuthor(info));
		meta_set(p_info, "title", ASAPInfo_GetTitle(info));
		meta_set(p_info, "date", ASAPInfo_GetDate(info));
	}
示例#4
0
static char *tagFunc(char *tag, void *p)
{
	if (stricmp(tag, "artist") == 0) {
		const char *author = ASAPInfo_GetAuthor(title_info);
		return author[0] != '\0' ? strdup(author) : NULL;
	}
	if (stricmp(tag, "title") == 0) {
		char *title = malloc(strlen(ASAPInfo_GetTitleOrFilename(title_info)) + 11);
		if (title != NULL)
			getTitle(title);
		return title;
	}
	return NULL;
}
示例#5
0
文件: libasap-xmms.c 项目: epi/asap
static void asap_file_info_box(char *filename)
{
	ASAPInfo *info = asap_get_info(filename);
	char s[3 * ASAPInfo_MAX_TEXT_LENGTH + 100];
	char *p;
	if (info == NULL)
		return;
	p = asap_stpcpy(s, "Author: ");
	p = asap_stpcpy(p, ASAPInfo_GetAuthor(info));
	p = asap_stpcpy(p, "\nName: ");
	p = asap_stpcpy(p, ASAPInfo_GetTitle(info));
	p = asap_stpcpy(p, "\nDate: ");
	p = asap_stpcpy(p, ASAPInfo_GetDate(info));
	*p = '\0';
	ASAPInfo_Delete(info);
	asap_show_message("File information", s);
}
示例#6
0
static BOOL infoChanged(void)
{
	int i;
	if (_tcscmp(ASAPInfo_GetAuthor(edited_info), saved_author) != 0)
		return TRUE;
	if (_tcscmp(ASAPInfo_GetTitle(edited_info), saved_title) != 0)
		return TRUE;
	if (_tcscmp(ASAPInfo_GetDate(edited_info), saved_date) != 0)
		return TRUE;
	for (i = 0; i < ASAPInfo_GetSongs(edited_info); i++) {
		if (ASAPInfo_GetDuration(edited_info, i) != saved_durations[i])
			return TRUE;
		if (saved_durations[i] >= 0 && ASAPInfo_GetLoop(edited_info, i) != saved_loops[i])
			return TRUE;
	}
	return FALSE;
}
static void asap_info(const char *file, struct file_tags *tags, const int tags_sel)
{
	ASAP_Decoder d;
	if (asap_load(&d, file)) {
		if ((tags_sel & TAGS_COMMENTS) != 0) {
			const ASAPInfo *info = ASAP_GetInfo(d.asap);
			tags->title = xstrdup(ASAPInfo_GetTitleOrFilename(info));
			tags->artist = xstrdup(ASAPInfo_GetAuthor(info));
			tags->filled |= TAGS_COMMENTS;
		}
		if ((tags_sel & TAGS_TIME) != 0) {
			tags->time = d.duration / 1000;
			tags->filled |= TAGS_TIME;
		}
	}
	ASAP_Delete(d.asap);
}
示例#8
0
bool ReadTag(const char* strFile, char* title, char* artist,
             int* length)
{
  int track=1;
  std::string toLoad(strFile);
  if (toLoad.find(".asapstream") != std::string::npos)
  {
    size_t iStart=toLoad.rfind('-') + 1;
    track = atoi(toLoad.substr(iStart, toLoad.size()-iStart-11).c_str());
    //  The directory we are in, is the file
    //  that contains the bitstream to play,
    //  so extract it
    size_t slash = toLoad.rfind('\\');
    if (slash == std::string::npos)
      slash = toLoad.rfind('/');
    toLoad = toLoad.substr(0, slash);
  }
  void* file = XBMC->OpenFile(toLoad.c_str(), 0);
  if (!file)
    return false;

  int len = XBMC->GetFileLength(file);
  uint8_t* data = new uint8_t[len];
  XBMC->ReadFile(file, data, len);
  XBMC->CloseFile(file);

  ASAP* asap = ASAP_New();

  // Now load the module
  if (!ASAP_Load(asap, strFile, data, len))
  {
    delete[] data;
    return false;
  }

  delete[] data;

  const ASAPInfo* info = ASAP_GetInfo(asap);
  strcpy(artist, ASAPInfo_GetAuthor(info));
  strcpy(title, ASAPInfo_GetTitleOrFilename(info));
  *length = ASAPInfo_GetDuration(info, track);

  return true;
}
示例#9
0
文件: libasap-xmms.c 项目: epi/asap
static char *asap_get_title(const char *filename, const ASAPInfo *info)
{
	char *path;
	char *filepart;
	char *ext;
	TitleInput *title_input;
	const char *p;
	int year;
	char *title;

	path = g_strdup(filename);
	filepart = strrchr(path, '/');
	if (filepart != NULL) {
		filepart[1] = '\0';
		filepart += 2;
	}
	else
		filepart = path;
	ext = strrchr(filepart, '.');
	if (ext != NULL)
		ext++;

	XMMS_NEW_TITLEINPUT(title_input);
	p = ASAPInfo_GetAuthor(info);
	if (p[0] != '\0')
		title_input->performer = (gchar *) p;
	title_input->track_name = (gchar *) ASAPInfo_GetTitleOrFilename(info);
	year = ASAPInfo_GetYear(info);
	if (year > 0)
		title_input->year = year;
	p = ASAPInfo_GetDate(info);
	if (p[0] != '\0')
		title_input->date = (gchar *) p;
	title_input->file_name = g_basename(filename);
	title_input->file_ext = ext;
	title_input->file_path = path;
	title = xmms_get_titlestring(xmms_get_gentitle_format(), title_input);
	if (title == NULL)
		title = g_strdup(ASAPInfo_GetTitleOrFilename(info));

	g_free(path);
	return title;
}
示例#10
0
文件: asap-sdl.c 项目: epi/asap
static void process_file(const char *input_file)
{
	FILE *fp;
	static unsigned char module[ASAPInfo_MAX_MODULE_LENGTH];
	int module_len;
	ASAP *asap;
	const ASAPInfo *info;
	SDL_AudioSpec desired;

	fp = fopen(input_file, "rb");
	if (fp == NULL)
		fatal_error("cannot open %s", input_file);
	module_len = fread(module, 1, sizeof(module), fp);
	fclose(fp);

	asap = ASAP_New();
	if (!ASAP_Load(asap, input_file, module, module_len))
		fatal_error("%s: unsupported file", input_file);
	info = ASAP_GetInfo(asap);
	if (song < 0)
		song = ASAPInfo_GetDefaultSong(info);
	if (!ASAP_PlaySong(asap, song, -1))
		fatal_error("%s: PlaySong failed", input_file);
	print_header("Name", ASAPInfo_GetTitle(info));
	print_header("Author", ASAPInfo_GetAuthor(info));
	print_header("Date", ASAPInfo_GetDate(info));

	if (SDL_Init(SDL_INIT_AUDIO) != 0)
		sdl_error("SDL_Init");
	desired.freq = ASAP_SAMPLE_RATE;
	desired.format = AUDIO_S16LSB;
	desired.channels = ASAPInfo_GetChannels(info);
	desired.samples = 4096;
	desired.callback = audio_callback;
	desired.userdata = asap;
	if (SDL_OpenAudio(&desired, NULL) != 0)
		sdl_error("SDL_OpenAudio");
	SDL_PauseAudio(0);
	printf(" playing - press Enter to quit\n");
	getchar();
	SDL_Quit();
}
示例#11
0
 HRESULT GetAuthors(PROPVARIANT *pvarData, BOOL vista)
 {
     const char *author = ASAPInfo_GetAuthor(m_pinfo);
     if (!vista)
         return GetString(pvarData, author);
     if (author[0] == '\0') {
         pvarData->vt = VT_EMPTY;
         return S_OK;
     }
     // split on " & "
     int i;
     const char *s = author;
     for (i = 1; ; i++) {
         s = strstr(s, " & ");
         if (s == NULL)
             break;
         s += 3;
     }
     pvarData->vt = VT_VECTOR | VT_LPSTR;
     pvarData->calpstr.cElems = i;
     LPSTR *pElems = (LPSTR *) CoTaskMemAlloc(i * sizeof(LPSTR));
     pvarData->calpstr.pElems = pElems;
     if (pElems == NULL)
         return E_OUTOFMEMORY;
     s = author;
     for (i = 0; ; i++) {
         const char *e = strstr(s, " & ");
         size_t len = e != NULL ? e - s : strlen(s);
         pElems[i] = (LPSTR) CoTaskMemAlloc(len + 1);
         if (pElems[i] == NULL)
             return E_OUTOFMEMORY;
         memcpy(pElems[i], s, len);
         pElems[i][len] = '\0';
         if (e == NULL)
             break;
         s = e + 3;
     }
     return S_OK;
 }
示例#12
0
const char *EMSCRIPTEN_KEEPALIVE asapinfo_GetAuthor() {
	return ASAPInfo_GetAuthor(info);
}