コード例 #1
0
ファイル: fcFMRadio.c プロジェクト: deeice/FlipClockPandora
/**************************************************************************
* D-Bus callback handler...
*
**************************************************************************/
gint dbus_req_handler(const gchar * interface, const gchar * method, GArray *arguments, gpointer data, osso_rpc_t * retval)
{
	osso_rpc_t argValue;
	long alarmTime = 0;	//Used for triggerAlarm call
	int alarmIndex = -1;	//Used for triggerAlarm call (-1 means no index passed)
	int alarmDResult = 0;	//Status of alarmD calls.
	unsigned int frequency = 107100;
	

	//char test[100];
	

	//osso_system_note_infoprint(ossoAppContext, test, NULL);
	
	if (arguments->len > 0) {
		argValue = g_array_index(arguments, osso_rpc_t, 0);
		
		if (argValue.type == DBUS_TYPE_UINT32) {
			frequency = argValue.value.u;
		}
		
		//printf("args len: %i\n", arguments->len);
		
		//check for fadeIn time
		if (arguments->len > 1) {
			argValue = g_array_index(arguments, osso_rpc_t, 1);
			
			if (argValue.type == DBUS_TYPE_UINT32) {
				//printf("new max vol is %u\n", argValue.value.u);
				fadeTime = argValue.value.u;
			}
		}
		
		//check for max volume
		if (arguments->len > 2) {
			argValue = g_array_index(arguments, osso_rpc_t, 2);
			
			if (argValue.type == DBUS_TYPE_UINT32) {
				//printf("new max vol is %u\n", argValue.value.u);
				maxVol = argValue.value.u;
			}
		}
	}
	
	

	//Handle dbus calls here!
	if (strcmp(method, "radioOn") == 0) {
		printf("Turn radio on!\n");
		//Just turn the radio on
		radio_unmute(radioObj);
		radio_setfreq(radioObj, frequency);	
		radio_setvolume(radioObj, maxVol);
	} else if (strcmp(method, "radioFadeIn") == 0) {
		//Fade the radio in like a regular alarm
		radio_unmute(radioObj);
		radio_setfreq(radioObj, frequency);	
		radio_setvolume(radioObj, 0);
		
		//Start the fade in
		stepVolumeUp(fadeTime / 20);
		
		
	} else if (strcmp(method, "radioOff") == 0) {
		printf("turn radio off!\n");
		//Just turn the radio on
		radio_mute(radioObj);
		
	} else if (strcmp(method, "exit") == 0) {
		//Request to exit
		osso_rpc_free_val(retval);
		deinitializeApp();
   		exit(0);
	} 
	
	
	//Cleanup
	osso_rpc_free_val(retval);

	return OSSO_OK;
}
コード例 #2
0
ファイル: gkrellm_radio.c プロジェクト: bvargo/gkrellm-radio
gint mutetimeout(gpointer *user_data) {
  radio_unmute();
  mute_timeout_tag = -1;
  return FALSE;			/* dont call again */
}