Exemple #1
0
int main(int argc, CHAR* argv[])
{
	HRESULT hr;
	float newVolume = 0;
	IAudioEndpointVolume *endpointVolume = nullptr;

	// Exit early if only displaying help
	if (argc == 1 || argc > 1 && strcmp(argv[1], "help") == 0) {
		DisplayUsageAndExit();
	}

	// Find devices for manipulating mixer volumes
	InitializeAudioEndpoint(&endpointVolume);

	// Parse command line arguments and perform actions
	if (argc == 2 && strcmp(argv[1], "get") == 0) {
		printf("%.0f\n", GetVolume(endpointVolume) * 100);
	} else if (argc == 3 && strcmp(argv[1], "set") == 0) {
		newVolume = strtof(argv[2], nullptr) / 100;

		if (argv[2][0] == '+' || argv[2][0] == '-') {
			newVolume += GetVolume(endpointVolume);
		}

		if (newVolume < 0) newVolume = 0;
		if (newVolume > 1) newVolume = 1;
		SetVolume(endpointVolume, newVolume);
	} else if (argc == 2 && strcmp(argv[1], "mute") == 0) {
		BOOL currentValue = GetMute(endpointVolume);
		if (currentValue != TRUE)
			SetMute(endpointVolume, TRUE);
	} else if (argc == 2 && strcmp(argv[1], "unmute") == 0) {
		BOOL currentValue = GetMute(endpointVolume);
		if (currentValue != FALSE)
			SetMute(endpointVolume, FALSE);
	} else if (argc == 2 && strcmp(argv[1], "togglemute") == 0) {
		BOOL currentValue = GetMute(endpointVolume);
		SetMute(endpointVolume, !currentValue);
	}

	// Cleanup
	DestroyAudioEndpoint(endpointVolume);
	return 0;
}
int CMixereView::MemberSortCompare(const void *elem1, const void *elem2)
{
	const CChannel *p1 = *((CChannel **)elem1);
	const CChannel *p2 = *((CChannel **)elem2);
	// empty channels sort last
	if (p1->IsEmpty())
		return(p2->IsEmpty() ? 0 : 1);
	if (p2->IsEmpty())
		return(p1->IsEmpty() ? 0 : -1);
	int	retc;
	switch (m_SortKey) {
	case COL_NUMBER:
		CMIXER_SORT(GetID());
		break;
	case COL_NAME:
		retc = stricmp(p1->GetTitle(), p2->GetTitle()) * m_SortDir;
		break;
	case COL_TRANSPORT:
		CMIXER_SORT(GetTransport());
		if (!retc)
			retc = stricmp(p1->GetTitle(), p2->GetTitle());
		break;
	case COL_MUTE:
		CMIXER_SORT2(GetMute(), GetSolo());
		break;
	case COL_VOLUME:
		CMIXER_SORT(GetVolume());
		break;
	case COL_PAN:
		CMIXER_SORT(GetPan());
		break;
	case COL_PITCH:
		CMIXER_SORT(GetPitch());
		break;
	case COL_POS:
		CMIXER_SORT(GetNormPosition());
		break;
	default:
		ASSERT(FALSE);	// unknown sort key
		return(0);
	}
	return(retc);
}