예제 #1
0
static
#if _AUD_PLUGIN_VERSION >= 18
	gboolean
#else
	void
#endif
	plugin_init(void)
{
	asap = ASAP_New();
#if _AUD_PLUGIN_VERSION >= 18
	return asap != NULL;
#endif
}
예제 #2
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;
}
예제 #3
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();
}
예제 #4
0
static cibool asap_load(ASAP_Decoder *d, const char *filename)
{
	struct io_stream *s;
	ssize_t module_len;
	unsigned char *module;
	cibool ok;
	const ASAPInfo *info;
	int song;
	int duration;

	d->asap = NULL;
	decoder_error_init(&d->error);
	s = io_open(filename, 0);
	if (s == NULL) {
		decoder_error(&d->error, ERROR_FATAL, 0, "Can't open %s", filename);
		return FALSE;
	}
	module_len = io_file_size(s);
	module = (unsigned char *) xmalloc(module_len);
	module_len = io_read(s, module, module_len);
	io_close(s);

	d->asap = ASAP_New();
	if (d->asap == NULL) {
		decoder_error(&d->error, ERROR_FATAL, 0, "Out of memory");
		return FALSE;
	}

	ok = ASAP_Load(d->asap, filename, module, module_len);
	free(module);
	if (!ok) {
		decoder_error(&d->error, ERROR_FATAL, 0, "Unsupported file format");
		return FALSE;
	}
	info = ASAP_GetInfo(d->asap);
	song = ASAPInfo_GetDefaultSong(info);
	duration = ASAPInfo_GetDuration(info, song);
	if (duration < 0)
		duration = DEFAULT_SONG_LENGTH * 1000;
	d->duration = duration;
	return TRUE;
}
예제 #5
0
파일: libasap-xmms.c 프로젝트: epi/asap
static void asap_init(void)
{
	asap = ASAP_New();
}
예제 #6
0
파일: ASAP_Apollo.cpp 프로젝트: epi/asap
	CASAPPlugin(HINSTANCE hInst) : hInstance(hInst)
	{
		if (asap == NULL)
			asap = ASAP_New();
	}
예제 #7
0
ASAP* getAsap() {
	if (asap == 0)
		asap= ASAP_New();
	return asap;
}