示例#1
0
文件: wasap.c 项目: Erikhht/TCPMP
static void LoadFile(HWND hWnd)
{
	HANDLE fh;
	static unsigned char module[65000];
	DWORD module_len;
	fh = CreateFile(strFile, GENERIC_READ, 0, NULL, OPEN_EXISTING,
	                FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
	if (fh == INVALID_HANDLE_VALUE)
		return;
	if (!ReadFile(fh, module, sizeof(module), &module_len, NULL)) {
		CloseHandle(fh);
		return;
	}
	CloseHandle(fh);
	WaveOut_Close();
	if (ASAP_Load(strFile, module, (unsigned int) module_len)) {
		if (!WaveOut_Open(FREQUENCY, use_16bit, ASAP_GetChannels())) {
			SetSongs(0);
			Tray_Modify(hWnd, hStopIcon);
			MessageBox(hWnd, "Error initalizing WaveOut", APP_TITLE,
					   MB_OK | MB_ICONERROR);
			return;
		}
		SetSongs(ASAP_GetSongs());
		PlaySong(hWnd, ASAP_GetDefSong());
	}
	else {
		SetSongs(0);
		Tray_Modify(hWnd, hStopIcon);
		MessageBox(hWnd, "Unsupported file format", APP_TITLE,
		           MB_OK | MB_ICONERROR);
	}
}
示例#2
0
文件: wasap.c 项目: 070499/xbmc
static void LoadAndPlay(int song)
{
	byte module[ASAP_MODULE_MAX];
	int module_len;
	int duration;
	if (!loadModule(current_filename, module, &module_len))
		return;
	if (songs > 0) {
		ClearSongsMenu();
		StopPlayback();
		songs = 0;
		EnableMenuItem(hTrayMenu, IDM_SAVE_WAV, MF_BYCOMMAND | MF_GRAYED);
	}
	if (!DoLoad(&asap, module, module_len))
		return;
	if (!WaveOut_Open(asap.module_info.channels)) {
		ShowError("Error initalizing WaveOut");
		return;
	}
	if (song < 0)
		song = asap.module_info.default_song;
	songs = asap.module_info.songs;
	EnableMenuItem(hTrayMenu, IDM_SAVE_WAV, MF_BYCOMMAND | MF_ENABLED);
	updateInfoDialog(current_filename, song);
	SetSongsMenu(songs);
	CheckMenuRadioItem(hSongMenu, 0, songs - 1, song, MF_BYPOSITION);
	current_song = song;
	duration = asap.module_info.durations[song];
	if (asap.module_info.loops[song])
		duration = -1;
	ASAP_PlaySong(&asap, song, duration);
	Tray_Modify(hPlayIcon);
	WaveOut_Start();
}
示例#3
0
文件: wasap.c 项目: Erikhht/TCPMP
static void PlaySong(HWND hWnd, unsigned int n)
{
	CheckMenuRadioItem(hSongMenu, 0, songs - 1, n, MF_BYPOSITION);
	cursong = n;
	ASAP_PlaySong(n);
	Tray_Modify(hWnd, hPlayIcon);
	WaveOut_Start();
}
示例#4
0
文件: wasap.c 项目: Erikhht/TCPMP
static void SetQuality(HWND hWnd, unsigned int new_16bit, unsigned int new_quality)
{
	int reopen = FALSE;
	if (songs > 0) {
		WaveOut_Stop();
		SetSongs(0);
		Tray_Modify(hWnd, hStopIcon);
		reopen = TRUE;
	}
	CheckMenuRadioItem(hQualityMenu, IDM_8BIT, IDM_16BIT,
		IDM_8BIT + new_16bit, MF_BYCOMMAND);
	CheckMenuRadioItem(hQualityMenu, IDM_QUALITY_RF, IDM_QUALITY_MB3,
		IDM_QUALITY_RF + new_quality, MF_BYCOMMAND);
	ASAP_Initialize(FREQUENCY, new_16bit, new_quality);
	use_16bit = new_16bit;
	quality = new_quality;
	if (reopen)
		LoadFile(hWnd);
}
示例#5
0
文件: wasap.c 项目: Erikhht/TCPMP
static LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
                                    LPARAM lParam)
{
	UINT idc;
	POINT pt;
	PCOPYDATASTRUCT pcds;
	switch (msg) {
	case WM_COMMAND:
		if (opening)
			break;
		idc = LOWORD(wParam);
		switch (idc) {
		case IDM_OPEN:
			SelectAndLoadFile(hWnd);
			break;
		case IDM_STOP:
			WaveOut_Stop();
			Tray_Modify(hWnd, hStopIcon);
			break;
		case IDM_ABOUT:
			MessageBox(hWnd,
				ASAP_CREDITS
				"WASAP icons (C) 2005 Lukasz Sychowicz\n\n"
				ASAP_COPYRIGHT,
				APP_TITLE " " ASAP_VERSION,
				MB_OK | MB_ICONINFORMATION);
			break;
		case IDM_EXIT:
			PostQuitMessage(0);
			break;
		default:
			if (idc >= IDM_SONG1 && idc < IDM_SONG1 + songs) {
				WaveOut_Stop();
				PlaySong(hWnd, idc - IDM_SONG1);
			}
			else if (idc >= IDM_QUALITY_RF && idc <= IDM_QUALITY_MB3)
				SetQuality(hWnd, use_16bit, idc - IDM_QUALITY_RF);
			else if (idc >= IDM_8BIT && idc <= IDM_16BIT)
				SetQuality(hWnd, idc - IDM_8BIT, quality);
			break;
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case MYWM_NOTIFYICON:
		if (opening) {
			SetForegroundWindow(GetLastActivePopup(hWnd));
			break;
		}
		switch (lParam) {
		case WM_LBUTTONDOWN:
			SelectAndLoadFile(hWnd);
			break;
		case WM_RBUTTONDOWN:
			GetCursorPos(&pt);
			SetForegroundWindow(hWnd);
			TrackPopupMenu(hTrayMenu,
				TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
				pt.x, pt.y, 0, hWnd, NULL);
			PostMessage(hWnd, WM_NULL, 0, 0);
			break;
		default:
			break;
		}
		break;
	case WM_COPYDATA:
		pcds = (PCOPYDATASTRUCT) lParam;
		if (pcds->dwData == 'O' && pcds->cbData <= sizeof(strFile)) {
			memcpy(strFile, pcds->lpData, pcds->cbData);
			LoadFile(hWnd);
		}
		break;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
示例#6
0
文件: wasap.c 项目: 070499/xbmc
static void StopPlayback(void)
{
	WaveOut_Stop();
	Tray_Modify(hStopIcon);
}