Пример #1
0
static int run(void)
{
    player_t* pl[2];
    int res = 0;


    pl[0]= new_player(ch_stream1, ch_stream1_info, 0);
    pl[1]= new_player(ch_stream2, ch_stream2_info, 1);
    hd_channel_invalidate(ch_stream1, 1);
    hd_channel_invalidate(ch_stream2, 1);
    new_osd(ch_osd);
    start_thread();
    signal(SIGINT, signalhandler);
    signal(SIGQUIT, signalhandler);
    signal(SIGTERM, signalhandler);
    signal(SIGSEGV, signalhandlerCrash);
    signal(SIGBUS, signalhandlerCrash);

    hda->hdp_running=1;
    hda->active_player[0] = HD_PLAYER_MODE_LIVE; // Save mode
    hda->active_player[1] = HD_PLAYER_MODE_LIVE; // Save mode
    hda->osd_dont_touch&=~2; // Clear xine draw bit (prevent no fb osd if hdplayer crashes)
    /* TB: avoid busy-waiting */
    while ((res = run_player(pl[0])|run_player(pl[1]))) {
	    if(res==1) 
		    usleep(5*1000);
            if (hda->hdp_terminate==1)
		    break;
    };
    delete_player(pl[1]);
    delete_player(pl[0]);
    hda->hdp_terminate=0;
    printf("hdplayer clean exit %i\n",hda->hdp_terminate);

    return 0;
}
Пример #2
0
bool Vivaldi::UpdateKnownOSDs(list<KnownOSD>* updated_osds,
                              const VivaldiNode& own_node) {
  // TODO(mno): Requesting the list of all OSDs does not scale with the number
  //            of services. Therefore, request only a subset of it.
  bool retval = true;
  boost::scoped_ptr<rpc::SyncCallbackBase> response;

  try {
    serviceGetByTypeRequest request;
    request.set_type(SERVICE_TYPE_OSD);

    response.reset(ExecuteSyncRequest(
        boost::bind(
            &xtreemfs::pbrpc::DIRServiceClient
                ::xtreemfs_service_get_by_type_sync,
            dir_client_.get(),
            _1,
            boost::cref(auth_bogus_),
            boost::cref(user_credentials_bogus_),
            &request),
        dir_service_addresses_.get(),
        NULL,
        RPCOptionsFromOptions(vivaldi_options_),
        true));

    ServiceSet* received_osds = static_cast<ServiceSet*>(response->response());
    updated_osds->clear();

    // Fill the list, ignoring every offline OSD
    for (int i = 0; i < received_osds->services_size(); i++) {
      const Service& service = received_osds->services(i);
      if (service.last_updated_s() > 0) {  // only online OSDs
        const ServiceDataMap& sdm = service.data();
        const string* coordinates_string = NULL;
        for (int j = 0; j < sdm.data_size(); ++j) {
          if (sdm.data(j).key() == "vivaldi_coordinates") {
            coordinates_string = &sdm.data(j).value();
            break;
          }
        }

        // If the DIR does not have the OSD's coordinates, we discard this
        // entry
        if (coordinates_string) {
          // Parse the coordinates provided by the DIR
          VivaldiCoordinates osd_coords;
          OutputUtils::StringToCoordinates(*coordinates_string, osd_coords);
          KnownOSD new_osd(service.uuid(), osd_coords);

          // Calculate the current distance from the client to the new OSD
          double new_osd_distance = own_node.CalculateDistance(
               *(own_node.GetCoordinates()),
               osd_coords);

          list<KnownOSD>::iterator up_iterator = updated_osds->begin();
          while (up_iterator != updated_osds->end()) {
            double old_osd_distance =
                own_node.CalculateDistance(*up_iterator->GetCoordinates(),
                                           *(own_node.GetCoordinates()));
            if (old_osd_distance >= new_osd_distance) {
              updated_osds->insert(up_iterator, new_osd);
              break;
            } else {
              up_iterator++;
            }
          }

          if (up_iterator == updated_osds->end()) {
            updated_osds->push_back(new_osd);
          }
        }  // if (coordinates_string)
      }
    }  // for
    response->DeleteBuffers();
  } catch (const XtreemFSException& e) {
    if (response.get()) {
      response->DeleteBuffers();
    }
    Logging::log->getLog(LEVEL_ERROR)
       << "Vivaldi: Failed to update known OSDs: " << e.what() << endl;
    retval = false;
  }

  return retval;
}  // update_known_osds
Пример #3
0
int main(int argc, char **argv)
{
    XEvent event;

    config_init();
    parse_cli_options(argc, argv);
    config_read();

    mixer_init(config.mixer_device, config.verbose, (const char **)config.exclude_channel);
    mixer_set_channel(0);

    display = XOpenDisplay(config.display_name);
    if (display == NULL) {
	const char *name;

	if (config.display_name) {
	    name = config.display_name;
	} else {
	    name = getenv("DISPLAY");
	    if (name == NULL) {
		fprintf(stderr, "wmix:error: Unable to open display, variable $DISPLAY not set\n");
		return EXIT_FAILURE;
	    }
	}
	fprintf(stderr, "wmix:error: Unable to open display \"%s\"\n", name);
	return EXIT_FAILURE;
    }
    display_width = (float)DisplayWidth(display, DefaultScreen(display)) / 4.0;
    display_height = (float)DisplayHeight(display, DefaultScreen(display)) / 2.0;

    dockapp_init(display);
    new_window("wmix", 64, 64);
    new_osd(DisplayWidth(display, DefaultScreen(display)) - 200, 60);

    if (config.mmkeys)
	    mmkey_install(display);

    config_release();

    blit_string("wmix " VERSION);
    scroll_text(3, 4, 57, true);
    ui_update();

    /* add click regions */
    add_region(1, 37, 36, 25, 25);	/* knob */
    add_region(2, 4, 42, 27, 15);	/* balancer */
    add_region(3, 2, 26, 7, 10);	/* previous channel */
    add_region(4, 10, 26, 7, 10);	/* next channel */
    add_region(5, 39, 14, 20, 7);	/* mute toggle */
    add_region(6, 4, 14, 13, 7);	/* rec toggle */
    add_region(10, 3, 4, 56, 7);	/* re-scroll current channel name */

    /* setup up/down signal handler */
    create_pid_file();
    signal(SIGUSR1, (void *) signal_catch);
    signal(SIGUSR2, (void *) signal_catch);

    while (true) {
	if (button_pressed || slider_pressed || (XPending(display) > 0)) {
	    XNextEvent(display, &event);
	    switch (event.type) {
		case KeyPress:
		    if (key_press_event(&event.xkey))
			idle_loop = 0;
		    break;
		case Expose:
		    redraw_window();
		    break;
		case ButtonPress:
		    button_press_event(&event.xbutton);
		    idle_loop = 0;
		    break;
		case ButtonRelease:
		    button_release_event(&event.xbutton);
		    idle_loop = 0;
		    break;
		case MotionNotify:
		    /* process cursor change, or drag events */
		    motion_event(&event.xmotion);
		    idle_loop = 0;
		    break;
		case LeaveNotify:
		    /* go back to standard cursor */
		    if ((!button_pressed) && (!slider_pressed))
			set_cursor(NORMAL_CURSOR);
		    break;
		case DestroyNotify:
		    XCloseDisplay(display);
		    return EXIT_SUCCESS;
		default:
		    break;
	    }
	} else {
	    usleep(100000);
	    scroll_text(3, 4, 57, false);
	    /* rescroll message after some delay */
	    if (idle_loop++ > 256) {
		scroll_text(3, 4, 57, true);
		idle_loop = 0;
	    }
	    /* get rid of OSD after a few seconds of idle */
	    if ((idle_loop > 15) && osd_mapped() && !button_pressed) {
		unmap_osd();
		idle_loop = 0;
	    }
	    if (mixer_is_changed())
		ui_update();
	}
    }
    return EXIT_SUCCESS;
}