Example #1
0
int
FMGUI_GetCWD(char *buf, size_t len)
{
#ifdef _WIN32
	DWORD rv;

	if ((rv = GetCurrentDirectory(len, buf)) == 0) {
		ReportError1("Failed to get current directory (%d)",
		    (int)GetLastError());
		return (-1);
	} else if (rv > len) {
		FReportError1("Failed to get current directory (%s)",
		    "Path name is too long");
		return (-1);
	}
	return (0);
#else
	if (getcwd(buf, len) == NULL) {
		ReportError1("Failed to get current directory (%s)",
		    strerror(errno));
		return (-1);
	}
	return (0);
#endif
}
Example #2
0
PDL_bool CheckPathForImg(PDL_JSParameters *parms)
{
	PDL_Err err;

	char retVal[512];

	const char *strVal = PDL_GetJSParamString(parms, 0);

	if (g_Indexer.CheckForImg(strVal, retVal))
	{
		err = PDL_JSReply(parms, retVal);

		if (err != PDL_NOERROR)
		{
			ReportError1("PDL_Init failed, err = %s", PDL_GetError());
			return PDL_FALSE;
		}
	}
	else
	{
		err = PDL_JSReply(parms, "-1");

		if (err != PDL_NOERROR)
		{
			ReportError1("PDL_Init failed, err = %s", PDL_GetError());
			return PDL_FALSE;
		}
	}


	return PDL_TRUE;
}
Example #3
0
FMGUI_Dir *
FMGUI_OpenDir(const char *path)
{
	FMGUI_Dir *dir;

	dir = (FMGUI_Dir *) Malloc(sizeof(FMGUI_Dir));
	dir->ents = NULL;
	dir->nents = 0;

#ifdef _WIN32
	{
		char dpath[FMGUI_PATHNAME_MAX];
		HANDLE h;
		WIN32_FIND_DATA fdata;
		DWORD rv;

		Strlcpy(dpath, path, sizeof(dpath));
		Strlcat(dpath, "\\*", sizeof(dpath));
		if ((h = FindFirstFile(dpath, &fdata))==INVALID_HANDLE_VALUE) {
			ReportError1("Invalid file handle (%d)",
			    (int)GetLastError());
			goto fail;
		}
		while (FindNextFile(h, &fdata) != 0) {
			dir->ents = Realloc(dir->ents,
			    (dir->nents+1)*sizeof(char *));
			dir->ents[dir->nents++] = Strdup(fdata.cFileName);
		}
		rv = GetLastError();
		FindClose(h);
		if (rv != ERROR_NO_MORE_FILES) {
			ReportError1("FindNextFileError (%lu)", rv);
			goto fail;
		}
	}
#else /* !_WIN32 */
	{
		DIR *dp;
		struct dirent *dent;
		
		if ((dp = opendir(path)) == NULL) {
			ReportError2("%s: Failed to open directory (%s)",
			    path, strerror(errno));
			goto fail;
		}
		while ((dent = readdir(dp)) != NULL) {
			dir->ents = (char **) Realloc(dir->ents,
			    (dir->nents+1)*sizeof(char *));
			dir->ents[dir->nents++] = strdup(dent->d_name);
		}
		closedir(dp);
	}
#endif /* _WIN32 */

	return (dir);
fail:
	Free(dir);
	return (NULL);
}
Example #4
0
PDL_bool GetAvgMagString(PDL_JSParameters *parms)
{
	//ReportError("Entering Get Cur");

	PDL_Err err;

	int32_t iTrack = PDL_GetJSParamInt(parms, 0);

	//ReportError1("GetAvg - iTrack:%i", iTrack);

	const char *cstrRet;
	cstrRet = g_MusController.PassMessage(MUS_MESSAGE_GET_MAG_STR, iTrack);

	//ReportError1("GetAvg:%s", cstrRet);

	err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	//ReportError("Exiting Get Cur");

	return PDL_TRUE;
}
Example #5
0
uint32_t SoundPipe::Seek(double dTime)
{
	if ((m_msgPipeInStatus == MUS_STATUS_WAITING_FOR_SONG) ||
		(m_msgPipeOutStatus == MUS_STATUS_WAITING_FOR_SONG))
	{
		return -1;
	}

	SDL_LockAudio();
	m_msgPipeInStatus 		= MUS_STATUS_WAITING_FOR_SONG;
	m_msgPipeOutStatus 		= MUS_STATUS_WAITING_FOR_SONG;
	SDL_UnlockAudio();

	m_cbBuf.Flush();
	m_cbBuf.SetBuffClock(dTime);

	ResetFilters();

	ReportError1("About to call FFmpeg seek with %f", dTime);

	uint32_t retVal = m_FFmpegDecoder.Seek(dTime);

	m_msgPipeInStatus 	= MUS_STATUS_INITIAL_BUFFERING;
	m_msgPipeOutStatus 	= MUS_STATUS_PLAYING;
	
	return retVal;
}
Example #6
0
int Init()
{

	// init SDL. This function is all it takes to init both
	// the audio and video.
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO ))
	{
		ReportError1("SDL_Init failed, err = %s", SDL_GetError());
		return 1;
	}

	// Should not need this to be called, but not sure, so leaving it commented
	//	until we can be sure it is not needed.

	Uint32 videoFlags = SDL_SWSURFACE;

	// Note that these were originally the full screen.  Don't think that is
	// needed but just in case it is being marked here.
	g_screen = SDL_SetVideoMode(100, 100, 0, videoFlags);
	if ( g_screen == NULL )
	{
		// couldn't make that screen
		return 1;
	}


	// return 0 for success
	return 0;
}
Example #7
0
MUS_MESSAGE SoundPipe::Open(const char *cstrFileName)
{
	SDL_LockAudio();
	m_msgPipeInStatus 		= MUS_STATUS_WAITING_FOR_SONG;
	m_msgPipeOutStatus 		= MUS_STATUS_WAITING_FOR_SONG;	
	SDL_UnlockAudio();
	
	MusMessage err = m_FFmpegDecoder.Open(cstrFileName);
	ReportError1("Opening %s", cstrFileName);

	if (err == MUS_MOD_Error)
	{
		m_msgPipeInStatus 	= MUS_STATUS_ERROR;
		m_msgPipeOutStatus	= MUS_STATUS_ERROR;
		m_cstrCurSongPath[0] = 0;
		return MUS_STATUS_ERROR;
	}

	strcpy(m_cstrCurSongPath, cstrFileName);

	m_fSampleRate = m_FFmpegDecoder.GetSampleRate();

	if (m_fSampleRate == 0) m_fSampleRate = 44100;

	m_cbBuf.Start(m_fSampleRate);

	m_dResampConvFactor = DEST_FREQ/m_fSampleRate;

	float fCurSpeed = m_rfResample.GetSpeed();
	
	ReportError2("fCurSpeed=%f, resampconv=%f", fCurSpeed, m_dResampConvFactor);

	fCurSpeed *= m_dResampConvFactor;

	m_rfResample.SetFilterRate(fCurSpeed);

	if (fCurSpeed == 1.0)
		m_bUseResampFilt = 0;
	else
		m_bUseResampFilt = 1;

	m_lSongEndInSec = m_FFmpegDecoder.GetDuration();

	if (m_lSongEndInSec == 0)
		m_lSongEndInSec = UINT_MAX;

	m_BPMDetect.Init();
	memset(m_iTicks, 0, BPM_TICK_HIST);
	m_iCurrentTick = 0;

	// Create message to start song

	m_msgPipeInStatus 	= MUS_STATUS_INITIAL_BUFFERING;
	m_msgPipeOutStatus 	= MUS_STATUS_PLAYING;
	
	//ReportError("Made it through Pipe Open Routine");

	return MUS_STATUS_INITIAL_BUFFERING;
}
Example #8
0
PDL_bool GetMetadata(PDL_JSParameters *parms)
{
	const char *cstrItem = PDL_GetJSParamString(parms, 0);

	ReportError1("Getting meta for tag %s", cstrItem);
	const char *cstrRet = g_Indexer.GetMetadata(cstrItem);

	PDL_Err err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	return PDL_TRUE;
}
Example #9
0
PDL_bool SetEQ(PDL_JSParameters *params)
{

	const char *cstrPath = PDL_GetJSParamString(params, 0);
	ReportError1("Open Message being created for %s", cstrPath);
	g_MusController.PassMessage(MUS_MESSAGE_ATTRIB_SET, ATTRIB_EQ, cstrPath);

	return PDL_TRUE;
}
Example #10
0
PDL_bool SetNext(PDL_JSParameters *parms)
{
	const char *cstrPath = PDL_GetJSParamString(parms, 0);
	double dGap = PDL_GetJSParamDouble(parms, 1);
	int32_t iTrack = PDL_GetJSParamInt(parms, 2);
	ReportError1("dGap val: %f", dGap);
	g_MusController.PassMessage(MUS_MESSAGE_SET_NEXT, cstrPath, dGap, iTrack);

	return PDL_TRUE;
}
Example #11
0
PDL_bool SetCrossfade(PDL_JSParameters *parms)
{
	double fVal = PDL_GetJSParamDouble(parms, 0);
	ReportError1("Setting Crossfade to %f", fVal);

	g_MusController.PassMessage(MUS_MESSAGE_ATTRIB_SET,
								ATTRIB_CROSS_FADE,
								fVal);

	return PDL_TRUE;
}
Example #12
0
PDL_bool Ping(PDL_JSParameters *parms)
{
	PDL_Err err = PDL_JSReply(parms, "Pong");

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	return PDL_TRUE;
}
Example #13
0
PDL_bool SetMetadataPath(PDL_JSParameters *parms)
{
	const char *cstrPath = PDL_GetJSParamString(parms, 0);

	if (ptagFile)
		delete ptagFile;

	ptagFile = new TagLib::FileRef(cstrPath);

	ReportError1("Setting meta path %s", cstrPath);

	return PDL_TRUE;
}
Example #14
0
void FinishSeek(const char *cstrVal, int32_t iTrack)
{
#if USE_PDL

	ReportError("Entering FinishSeek");

	const char *params[2];
	params[0] = cstrVal;

	char cstrIndex[15];
	sprintf(cstrIndex,"%i",iTrack);

	params[1] = cstrIndex;

	PDL_Err mjErr = PDL_CallJS("FinishSeek", params, 2);
	if ( mjErr != PDL_NOERROR )
	{
		ReportError1("error: %s\n", PDL_GetError());
	}
#endif
	ReportError1("Callback Val From FinishSeek: %s", cstrVal);

}
Example #15
0
void FinishIndex()
{
#if USE_PDL

	const char *params[1];
	params[0] = 0;

	PDL_Err mjErr = PDL_CallJS("FinishIndex", params, 0);
	if ( mjErr != PDL_NOERROR )
	{
		ReportError1("error: %s\n", PDL_GetError());
	}
#endif
	ReportError("Finish Index");

}
Example #16
0
void AddToIndex(const char *path, int32_t iLastMod)
{
	const char *params[2];
	params[0] = path;

	char cstrIndex[15];
	sprintf(cstrIndex,"%i",iLastMod);
	params[1] = cstrIndex;
#if USE_PDL
	PDL_Err mjErr = PDL_CallJS("AddToIndex", params, 2);
	if ( mjErr != PDL_NOERROR )
	{
		ReportError1("error: %s\n", PDL_GetError());
	}
#endif
	ReportError2("Callback Val: %s : %s", params[0], params[1]);

}
Example #17
0
PDL_bool GetCurrentDirLS(PDL_JSParameters *parms)
{
	PDL_Err err;

	const char *strVal = PDL_GetJSParamString(parms, 0);

	char *cstrRet = g_Indexer.GetDirFileList(strVal);

	err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	free(cstrRet);

	return PDL_TRUE;
}
Example #18
0
int
FMGUI_GetFileInfo(const char *path, FMGUI_FileInfo *i)
{
	DWORD attrs;
	FILE *f;
	
	if ((attrs = GetFileAttributes(path)) == INVALID_FILE_ATTRIBUTES) {
		ReportError1("%s: Failed to get information", path);
		return (-1);
	}
	i->flags = 0;
	i->perms = 0;

	if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
		i->type = FMGUI_FILE_DIRECTORY;
		i->perms |= FMGUI_FILE_EXECUTABLE;
	} else {
		i->type = FMGUI_FILE_REGULAR;
	}
	if (attrs & FILE_ATTRIBUTE_ARCHIVE) i->flags |= FMGUI_FILE_ARCHIVE;
	if (attrs & FILE_ATTRIBUTE_COMPRESSED) i->flags |= FMGUI_FILE_COMPRESSED;
	if (attrs & FILE_ATTRIBUTE_ENCRYPTED) i->flags |= FMGUI_FILE_ENCRYPTED;
	if (attrs & FILE_ATTRIBUTE_HIDDEN) i->flags |= FMGUI_FILE_HIDDEN;
	if (attrs & FILE_ATTRIBUTE_SPARSE_FILE) i->flags |= FMGUI_FILE_SPARSE;
	if (attrs & FILE_ATTRIBUTE_SYSTEM) i->flags |= FMGUI_FILE_SYSTEM;
	if (attrs & FILE_ATTRIBUTE_TEMPORARY) i->flags |= FMGUI_FILE_TEMPORARY;
	
	if ((f = fopen(path, "rb")) != NULL) {
		fclose(f);
		i->perms |= FMGUI_FILE_READABLE;
	}
	if (((attrs & FILE_ATTRIBUTE_READONLY) == 0) &&
	    (f = fopen(path, "a")) != NULL) {
		fclose(f);
		i->perms |= FMGUI_FILE_WRITEABLE;
	}
	return (0);
}
Example #19
0
PDL_bool GetEndTime(PDL_JSParameters *parms)
{
	//ReportError("Entering Get End");

	PDL_Err err;

	int32_t iTrack = PDL_GetJSParamInt(parms, 0);

	const char *cstrRet;
	cstrRet = g_MusController.PassMessage(MUS_MESSAGE_GET_SONG_END, iTrack);

	err = PDL_JSReply(parms, cstrRet);

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return PDL_FALSE;
	}

	//ReportError("Exiting Get End");

	return PDL_TRUE;
}
Example #20
0
int
FMGUI_MkPath(const char *path)
{
	FMGUI_FileInfo info;
	char *pathp, *slash;
	int done = 0;
	int rv;

	slash = pathp = strdup(path);

	while (!done) {
		slash += strspn(slash, FMGUI_PATHSEP);
		slash += strcspn(slash, FMGUI_PATHSEP);

		done = (*slash == '\0');
		*slash = '\0';

		if (FMGUI_GetFileInfo(pathp, &info) == -1) {
			if ((rv = FMGUI_FileExists(pathp)) == -1) {
				goto fail;
			} else if (rv == 0) {
				if (FMGUI_MkDir(pathp) == -1)
					goto fail;
			}
		} else if (info.type != FMGUI_FILE_DIRECTORY) {
			ReportError1("%s: Existing file", pathp);
			goto fail;
		}

		*slash = FMGUI_PATHSEPCHAR;
	}
	Free(pathp);
	return (0);
fail:
	Free(pathp);
	return (-1);
}
Example #21
0
int16_t AudioPipeline::SetNext(const char *cstrFileName, float fTransition)
{

	ReportError1("Set Next=%s", cstrFileName);

	if (m_spPipe[m_iActivePipe].GetInStatus() ==
								MUS_STATUS_WAITING_FOR_SONG)
	{
		return Open(cstrFileName);
	}

	if(QuickExtCheck(cstrFileName) == 0)
		return 0;

	m_bNextNotSet = 0;

	if ((fTransition > 0.5) || (fTransition < -0.5))
	{
		if (fTransition < 0)
		{
			fTransition *= -1;
			m_iEndType = END_TYPE_CROSSFADE;

			m_iCurScale = END_MAX_GAP;
			m_iEndLength = fTransition;
			if (m_iEndLength > 10)
			{
				m_iScaleBy = END_MAX_GAP/10;
				m_iEndLength = 10;

			}
			else
			{
				m_iScaleBy = END_MAX_GAP/fTransition;
			}

		}
		else
		{
			m_iEndType = END_TYPE_GAP;

			m_iEndLength = fTransition;
			if (m_iEndLength > 10)
			{
				m_iEndLength = DEST_FREQ * 10;
			}
			else
			{
				m_iEndLength = DEST_FREQ * fTransition;
			}

		}


	}
	else
	{
		m_iEndType = 0;
	}

	int32_t iInactivePipe = _GetInactivePipe();



	m_spPipe[iInactivePipe].Flush();
	m_spPipe[iInactivePipe].SetFilterRate(m_fRate);
	MUS_MESSAGE Msg = m_spPipe[_GetInactivePipe()].Open(cstrFileName);
	return Msg;

}
Example #22
0
int Register()
{
	PDL_Err err;
	err = PDL_Init(0);

	Worm_OpenLog("wormp3_plugin", LOG_PID | LOG_PERROR, LOG_USER);

	ReportError("*****************TEST***********************");

	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return 1;
	}

	err = PDL_RegisterJSHandler("Ping", Ping);
	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return 1;
	}

	err = PDL_RegisterJSHandler("GetCurrentDirLS", GetCurrentDirLS);
	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return 1;
	}


	err = PDL_RegisterJSHandler("Play", Play);
	err = PDL_RegisterJSHandler("Pause", Pause);
	err = PDL_RegisterJSHandler("Open", Open);
	err = PDL_RegisterJSHandler("SetNext", SetNext);
	err = PDL_RegisterJSHandler("SetBass", SetBass);
	err = PDL_RegisterJSHandler("SetTreble", SetTreble);
	err = PDL_RegisterJSHandler("SetMid", SetMid);
	err = PDL_RegisterJSHandler("GetCurTime", GetCurTime);
	err = PDL_RegisterJSHandler("GetMetadata", GetMetadata);
	err = PDL_RegisterJSHandler("GetEndTime", GetEndTime);
	err = PDL_RegisterJSHandler("SetSpeed", SetSpeed);
	err = PDL_RegisterJSHandler("SetVol", SetVol);
	err = PDL_RegisterJSHandler("Seek", Seek);
	err = PDL_RegisterJSHandler("Quit", PluginQuit);
	err = PDL_RegisterJSHandler("SetEQ", SetEQ);
	err = PDL_RegisterJSHandler("SetCrossfade", SetCrossfade);
	err = PDL_RegisterJSHandler("StartIndex", StartIndex);
	err = PDL_RegisterJSHandler("SetMetadataPath", SetMetadataPath);
	err = PDL_RegisterJSHandler("GetBPM", GetBPM);
	err = PDL_RegisterJSHandler("SetNoNext", SetNoNext);
	err = PDL_RegisterJSHandler("GetFreqString", GetFreqString);
	err = PDL_RegisterJSHandler("GetAvgMagString", GetAvgMagString);
	err = PDL_RegisterJSHandler("CheckPathForImg", CheckPathForImg);

		err = PDL_JSRegistrationComplete();
	if (err != PDL_NOERROR)
	{
		ReportError1("PDL_Init failed, err = %s", PDL_GetError());
		return 1;
	}

	return 0;
}