Beispiel #1
0
void audio_manager_exit(void)
{
	/* Bail out early if we haven't been initialized */
	if (connection == NULL)
		return;

	dbus_connection_unref(connection);
	connection = NULL;

	if (config) {
		g_key_file_free(config);
		config = NULL;
	}

	if (enabled.socket)
		unix_exit();

	if (enabled.media)
		btd_unregister_adapter_driver(&media_server_driver);

	if (enabled.headset)
		btd_unregister_adapter_driver(&headset_server_driver);

	if (enabled.gateway)
		btd_unregister_adapter_driver(&gateway_server_driver);

	if (enabled.source || enabled.sink)
		btd_unregister_adapter_driver(&a2dp_server_driver);

	if (enabled.control)
		btd_unregister_adapter_driver(&avrcp_server_driver);

	btd_unregister_device_driver(&audio_driver);
}
Beispiel #2
0
static void audio_exit(void)
{
	if (sco_server) {
		g_io_channel_shutdown(sco_server, TRUE, NULL);
		g_io_channel_unref(sco_server);
		sco_server = NULL;
	}

	audio_manager_exit();

	unix_exit();

	dbus_connection_unref(connection);
}
Beispiel #3
0
static int audio_init(void)
{
	GKeyFile *config;
	gboolean enable_sco;

	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
	if (connection == NULL)
		return -EIO;

	config = load_config_file(CONFIGDIR "/audio.conf");

	if (unix_init() < 0) {
		error("Unable to setup unix socket");
		goto failed;
	}

	if (audio_manager_init(connection, config, &enable_sco) < 0)
		goto failed;

	if (!enable_sco)
		return 0;

	sco_server = bt_io_listen(BT_IO_SCO, sco_server_cb, NULL, NULL,
					NULL, NULL,
					BT_IO_OPT_INVALID);
	if (!sco_server) {
		error("Unable to start SCO server socket");
		goto failed;
	}

	return 0;

failed:
	audio_manager_exit();
	unix_exit();

	if (connection) {
		dbus_connection_unref(connection);
		connection = NULL;
	}

	return -EIO;
}
Beispiel #4
0
Datei: trs.c Projekt: ldo/udd
int trs_main(void)
{
  const int value = u.c[UC_VALUE];
  int tmp, typ = TRS_NORM;
  int trs;
  double adj;
  if (debug_mode())
    printf("trs: l = %d\r\n", value);
  tmp = roll(1, 100);
  if (tmp > 80 && tmp <= 90)
    typ = TRS_CHEST;
  else if (tmp > 90)
    typ = TRS_OBJ;
  switch (typ) {
  case TRS_CHEST:
    if ((trs = trs_chest()) == YEP)
      return(YEP);
    if (trs == MAYBE)
      break;
    /* fall through */
  case TRS_OBJ:
    if (trs_obj() == YEP)
      return(YEP);
    break;
  case TRS_NORM:
    if (tmp <= 30) {
      printf("You see a pile of silver...\r\n");
      trs = 100 * rnd() * value + 10;
    } else
      if (tmp <= 40) {
        printf("You see a pile of gold...\r\n");
        trs = 500 * rnd() * value + 50;
      } else
        if (tmp <= 60) {
          printf("You see a pile of platinum...\r\n");
          trs = 1000 * rnd() * value + 100;
        } else
          if (tmp <= 72) {
            printf("You see some gems...\r\n");
            trs = 500.0 * sqrt((double)rnd()) * value + 150.0;
          } else {
            printf("You see a jewel...\r\n");
            trs = 6000.0 * rnd() * rnd() * rnd() * value + 500;
          }
trs_top:
    utl_dtrp();
    printf("Press <CR> to pick it up, <LF> to leave it behind: ");
    tmp = getchar();
    printf("\r\n");
    if (tmp < 0)
      tmp = '\n';
    if (tmp == '\n') {
      u.c[UC_STATE] = XXX_NORM;
      break;
    }
    if (tmp != '\r') {
      printf("DUMMY!\007\r\n");
      goto trs_top;
    }
    if (u.i[ROOM_TREASURE_BOOBYTRAPPED] == 1)
      if (cbt_ohitu((int) (u.c[UC_DGNLVL] / 1.2)) == YEP)
        return(YEP);
    printf("The treasure is worth %d gold.\r\n", trs);
    u.c[UC_GOLDFOUND] += trs;
    u.c[UC_STATE] = XXX_NORM;
    adj = u.c[UC_DGNLVL] / (double) u.c[UC_LEVEL];
    if (adj > 1.0)
      adj = 1.0;
    u.c[UC_EXPGAIN] += trs * adj;
    break;
  default:
    printf("trs: internal error\r\n");
    unix_exit(1);
  }
  u.i[ROOM_MONSTER] = u.i[ROOM_TREASURE] = u.i[ROOM_TREASURE_BOOBYTRAPPED] = 0;
  save_room(false);
  if (u.i[ROOM_SPECIAL] == 0) {
    u.c[UC_STATE] = DGN_PROMPT;
    return(NOPE);
  }
  utl_pplot(NOPE);
  return(spc_main());
}