コード例 #1
0
ファイル: shairplay.c プロジェクト: UIKit0/shairplay
static void
audio_process(void *cls, void *opaque, const void *buffer, int buflen)
{
	shairplay_session_t *session = opaque;
	int processed;

	if (session->buffering) {
		printf("Buffering...\n");
		if (session->buflen+buflen < sizeof(session->buffer)) {
			memcpy(session->buffer+session->buflen, buffer, buflen);
			session->buflen += buflen;
			return;
		}
		session->buffering = 0;
		printf("Finished buffering...\n");

		processed = 0;
		while (processed < session->buflen) {
			processed += audio_output(session,
			                          session->buffer+processed,
			                          session->buflen-processed);
		}
		session->buflen = 0;
	}

	processed = 0;
	while (processed < buflen) {
		processed += audio_output(session,
		                          buffer+processed,
		                          buflen-processed);
	}
}
コード例 #2
0
audio_player::audio_player(std::string const& source, std::string const& root_path, QWidget* player_container
                           , ncl_widget* ncl, gntl::structure::composed::component_location
                           <std::string, std::string> location
                           , ncl::executor* executor_)
  : common_player(executor_, location), sound_level_temporary(0)
  , media_object(0), audio_output(0)
{
  std::auto_ptr<audio_detail::MediaObject> media_object
    (new audio_detail::MediaObject(player_container, ncl, this));
  std::auto_ptr<Phonon::AudioOutput> audio_output(new Phonon::AudioOutput(player_container));

  QObject::connect(media_object.get(), SIGNAL(stateChanged(Phonon::State, Phonon::State))
                   , media_object.get(), SLOT(stateChanged_impl(Phonon::State, Phonon::State)));

  Phonon::Path phonon_path = Phonon::createPath(media_object.get(), audio_output.get());
  if(phonon_path.isValid())
  {
    QUrl url = create_url(source, root_path);
    Phonon::MediaSource media_source(url);
    media_object->setCurrentSource(media_source);
    media_object->play();
    this->media_object = media_object.release();
    this->audio_output = audio_output.release();
  }
  else
  {
    ncl->error_occurred("Error creating audio Path");
    throw std::runtime_error("Error creating audio Path");
  }
}
コード例 #3
0
//音声並列処理スレッド用関数
static unsigned __stdcall audio_output_parallel_func(void *prm) {
    AUDIO_OUTPUT_PRM *aud_prm = (AUDIO_OUTPUT_PRM *)prm;
    CONF_GUIEX *conf = aud_prm->_conf;
    const OUTPUT_INFO *oip = aud_prm->_oip;
    PRM_ENC *pe = aud_prm->_pe;
    const SYSTEM_DATA *sys_dat = aud_prm->_sys_dat;
    free(prm); //audio_output_parallel関数内で確保したものをここで解放

    //_endthreadexは明示的なCloseHandleが必要 (exit_audio_parallel_control内で実行)
    _endthreadex(audio_output(conf, oip, pe, sys_dat));
    return 0;
}
コード例 #4
0
ファイル: madplay.c プロジェクト: dirsors/ps2sdk-ports
/*
 * NAME:	main()
 * DESCRIPTION:	program entry point
 */
int main(int argc, char *argv[])
{
  struct player player;
  int result = 0;

  argv0 = argv[0];

  /* ensure binary standard I/O */

# if defined(_WIN32)
  _setmode(_fileno(stdin),  _O_BINARY);
  _setmode(_fileno(stdout), _O_BINARY);
# endif

  /* internationalization support */

# if defined(ENABLE_NLS)
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);
# endif

  /* initialize and get options */

  player_init(&player);

# if !defined(__CYGWIN__)  /* Cygwin support for this is currently buggy */

  /* check for default tty control */

  if (isatty(STDIN_FILENO))
    player.options |= PLAYER_OPTION_TTYCONTROL;
# endif

  get_options(argc, argv, &player);

  /* main processing */

  if (player.verbosity >= 0)
    ver_banner(stderr);

  if (player.options & PLAYER_OPTION_CROSSFADE) {
    if (!(player.options & PLAYER_OPTION_GAP))
      warn(_("cross-fade ignored without gap"));
    else if (mad_timer_sign(player.gap) >= 0)
      warn(_("cross-fade ignored without negative gap"));
  }

  if (player.output.replay_gain & PLAYER_RGAIN_ENABLED) {
    if (player.options & PLAYER_OPTION_IGNOREVOLADJ)
      warn(_("volume adjustment ignored with Replay Gain enabled"));
    else
      player.options |= PLAYER_OPTION_IGNOREVOLADJ;
  }

  if ((player.options & PLAYER_OPTION_SHOWTAGSONLY) &&
      player.repeat != 1) {
    warn(_("ignoring repeat"));
    player.repeat = 1;
  }

  /* make stop time absolute */
  if (player.options & PLAYER_OPTION_TIMED)
    mad_timer_add(&player.global_stop, player.global_start);

  /* get default audio output module */
  if (player.output.command == 0 &&
      !(player.options & PLAYER_OPTION_SHOWTAGSONLY))
    player.output.command = audio_output(0);

# if defined(EXPERIMENTAL)
  if (external_mix) {
    player.options |= PLAYER_OPTION_EXTERNALMIX;
    player.output.command = 0;
  }
  if (experimental)
    player.options |= PLAYER_OPTION_EXPERIMENTAL;
# endif

  /* run the player */
  if (player_run(&player, argc - optind, (char const **) &argv[optind]) == -1)
    result = 4;

  /* finish up */
  player_finish(&player);

  return result;
}
コード例 #5
0
ファイル: madplay.c プロジェクト: dirsors/ps2sdk-ports
/*
 * NAME:	get_options()
 * DESCRIPTION:	parse command-line options or die
 */
static
void get_options(int argc, char *argv[], struct player *player)
{
  int opt, index;
  int ttyset = 0, preamp = 0;

  while ((opt = getopt_long(argc, argv,
			    "vqQ"		/* verbosity options */
			    "i"			/* decoding options */
			    "o:b:R:da:A:G::"	/* audio output options */
# if 0
			    "g:x"
# endif
			    "12mS"		/* channel selection options */
			    "s:t:zr::"		/* playback options */
			    "TVh",		/* miscellaneous options */
			    options, &index)) != -1) {
    switch (opt) {
    case 0:
      break;

    case '1':
    case '2':
      player->output.select = PLAYER_CHANNEL_LEFT + (opt - '1');
      break;

    case 'a':
      player->output.attamp_db = get_decibels(optarg);
      preamp = 1;
      break;

    case 'A':
      player->output.voladj_db = get_decibels(optarg);
      player->options |= PLAYER_OPTION_IGNOREVOLADJ;
      break;

    case -'a':
      if (player->ancillary.path)
	die(_("multiple output destinations not supported"));

      player->ancillary.path = optarg;
      break;

    case 'b':
      opt = atoi(optarg);
      if (opt <= 0)
	die(_("invalid bit depth \"%s\""), optarg);

      player->output.precision_in = opt;
      break;

# if defined(USE_TTY)
    case -'c':
      player->options |= PLAYER_OPTION_TTYCONTROL;
      ttyset = 1;
      break;

    case -'C':
      player->options &= ~PLAYER_OPTION_TTYCONTROL;
      ttyset = 1;
      break;
# endif

    case 'd':
      player->output.mode = AUDIO_MODE_ROUND;
      break;

    case -'d':
      player->options |= PLAYER_OPTION_DOWNSAMPLE;
      break;

# if 0
    case 'g':
      player->gap = get_time(optarg, 0, _("gap time"));
      player->options |= PLAYER_OPTION_GAP;
      break;
# endif

    case 'G':
      player->output.replay_gain |= PLAYER_RGAIN_ENABLED;

      if (optarg) {
	size_t len;

	len = strlen(optarg);

	if (len && strncmp(optarg, "audiophile", len) == 0)
	  player->output.replay_gain |= PLAYER_RGAIN_AUDIOPHILE;
	else if (len && strncmp(optarg, "radio", len) == 0)
	  ;
	else
	  die(_("invalid Replay Gain argument \"%s\""), optarg);
      }

      if (!preamp)
	player->output.attamp_db = +6;  /* default pre-amp */
      break;

    case 'h':
      show_usage(1);
      exit(0);

    case 'i':
      player->options |= PLAYER_OPTION_IGNORECRC;
      break;

    case -'i':
      player->fade_in = get_time(optarg ? optarg : FADE_DEFAULT, 1,
				 _("fade-in time"));
      player->options |= PLAYER_OPTION_FADEIN;
      break;

    case -'l':
      ver_license(stdout);
      exit(0);

    case 'm':
      player->output.select = PLAYER_CHANNEL_MONO;
      break;

    case 'o':
      if (player->output.path)
	die(_("multiple output destinations not supported"));

      player->output.path = optarg;

      player->output.command = audio_output(&player->output.path);
      if (player->output.command == 0)
	die(_("unknown output format type for \"%s\""), optarg);

      if (!ttyset)
	player->options &= ~PLAYER_OPTION_TTYCONTROL;
      break;

# if 0
    case -'o':
      player->fade_out = get_time(optarg ? optarg : FADE_DEFAULT, 1,
				  _("fade-out time"));
      player->options |= PLAYER_OPTION_FADEOUT;
      break;
# endif

    case 'q':
      player->verbosity = -1;

      if (!ttyset)
	player->options &= ~PLAYER_OPTION_TTYCONTROL;
      break;

    case 'Q':
      player->verbosity = -2;

      if (!ttyset)
	player->options &= ~PLAYER_OPTION_TTYCONTROL;
      break;

    case 'r':
      if (optarg == 0)
	player->repeat = -1;
      else {
	player->repeat = atoi(optarg);
	if (player->repeat <= 0)
	  die(_("invalid repeat count \"%s\""), optarg);
      }
      break;

    case 'R':
      player->output.speed_request = get_hertz(optarg);
      break;

    case 's':
      player->global_start = get_time(optarg, 0, _("start time"));
      player->options |= PLAYER_OPTION_SKIP;
      break;

    case 'S':
      player->output.select = PLAYER_CHANNEL_STEREO;
      break;

    case 't':
      player->global_stop = get_time(optarg, 1, _("playing time"));
      player->options |= PLAYER_OPTION_TIMED;
      break;

    case -'t':
      {
	size_t len;

	len = strlen(optarg);

	if (len && strncmp(optarg, "remaining", len) == 0)
	  player->stats.show = STATS_SHOW_REMAINING;
	else if (len && strncmp(optarg, "current", len) == 0)
	  player->stats.show = STATS_SHOW_CURRENT;
	else if (len && strncmp(optarg, "overall", len) == 0)
	  player->stats.show = STATS_SHOW_OVERALL;
	else
	  die(_("invalid display time argument \"%s\""), optarg);
      }
      break;

    case 'T':
      player->options |= PLAYER_OPTION_SHOWTAGSONLY;
      break;

    case 'v':
      player->verbosity = +1;
      break;

    case 'V':
      ver_version(stdout);
      fprintf(stderr, "`%s --license' %s.\n", argv0,
	      _("for license and warranty information"));
      exit(0);

# if 0
    case 'x':
      player->options |= PLAYER_OPTION_CROSSFADE;
      break;
# endif

    case 'z':
      player->options |= PLAYER_OPTION_SHUFFLE;
      break;

    case '?':
      show_usage(0);
      exit(1);

    default:
      assert(!"option handler");
    }
  }

  if (optind == argc) {
    show_usage(0);
    exit(2);
  }
}