コード例 #1
0
ファイル: in_asap.c プロジェクト: vitamin-caig/zxtune
static void getTitle(char *title)
{
	if (ASAPInfo_GetSongs(title_info) > 1)
		sprintf(title, "%s (song %d)", ASAPInfo_GetTitleOrFilename(title_info), title_song + 1);
	else
		strcpy(title, ASAPInfo_GetTitleOrFilename(title_info));
}
コード例 #2
0
ファイル: asapplug.c プロジェクト: hudokkow/audiodecoder.asap
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;
}
コード例 #3
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;
}
コード例 #4
0
ファイル: in_asap.c プロジェクト: vitamin-caig/zxtune
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
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);
}
コード例 #6
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;
}
コード例 #7
0
ファイル: interface.c プロジェクト: wothke/asap-3.2.0
const char *EMSCRIPTEN_KEEPALIVE asapinfo_GetTitleOrFilename() {
	return ASAPInfo_GetTitleOrFilename(info);
}