Exemplo n.º 1
0
void CAMLPlayer::ToFFRW(int iSpeed)
{
  CLog::Log(LOGDEBUG, "CAMLPlayer::ToFFRW: iSpeed(%d), m_speed(%d)", iSpeed, m_speed);
  CSingleLock lock(m_aml_csection);

  if (!check_pid_valid(m_pid) && m_StopPlaying)
    return;

  if (m_speed != iSpeed)
  {
    // recover power of two value
    int ipower = 0;
    int ispeed = abs(iSpeed);
    while (ispeed >>= 1) ipower++;

    switch(ipower)
    {
      // regular playback
      case  0:
        player_forward(m_pid, 0);
        break;
      default:
        // N x fast forward/rewind (I-frames)
        // speed playback 1,2,4,8
        if (iSpeed > 0)
          player_forward(m_pid,   iSpeed);
        else
          player_backward(m_pid, -iSpeed);
        break;
    }

    m_speed = iSpeed;
  }
Exemplo n.º 2
0
void CAMLPlayer::SeekTime(__int64 seek_ms)
{
  CSingleLock lock(m_aml_csection);
  if (seek_ms <= 0)
    seek_ms = 100;

  // seek here
  if (check_pid_valid(m_pid))
  {
    player_timesearch(m_pid, seek_ms/1000.0);
    WaitForSearchOK(5000);
  }
}
Exemplo n.º 3
0
void CAMLPlayer::SetSubtitleVisible(bool bVisible)
{
  m_subtitle_show = (bVisible && m_subtitle_count);
  g_settings.m_currentVideoSettings.m_SubtitleOn = bVisible;

  if (m_subtitle_show)
  {
    // on startup, if asked to show subs and SetSubtitle has not
    // been called, we are expected to switch/show the 1st subtitle
    if (m_subtitle_index < 0 && m_subtitle_count)
      m_subtitle_index = 0;
    if (check_pid_valid(m_pid))
      player_sid(m_pid, m_subtitle_streams[m_subtitle_index]->id);
  }
}
Exemplo n.º 4
0
void CAMLPlayer::SetAudioStream(int SetAudioStream)
{
  //CLog::Log(LOGDEBUG, "CAMLPlayer::SetAudioStream");
  CSingleLock lock(m_aml_csection);

  if (SetAudioStream > (int)m_audio_streams.size() || SetAudioStream < 0)
    return;
  
  m_audio_index = SetAudioStream;

  if (check_pid_valid(m_pid))
  {
    player_aid(m_pid, m_audio_streams[m_audio_index]->id);
  }
}
Exemplo n.º 5
0
int
check_process_running(const char *prog, pid_t * pid)
{
	pid_t oldpid;
	FILE *fp;
	char filename[PATH_MAX];
	char *cmd;
	int ret;
	struct stat st;

	*pid = -1;

	/*
	 * Now see if there is a pidfile associated with this cmd in /var/run
	 */
	fp = NULL;
	memset(filename, 0, PATH_MAX);

	cmd = basename((char *)prog);
	snprintf(filename, sizeof (filename), "/var/run/%s.pid", cmd);

	ret = stat(filename, &st);
	if ((ret < 0) || (!st.st_size))
		return 0;

	/*
	 * Read the pid from the file.
	 */
	fp = fopen(filename, "r");
	if (fp == NULL) {	/* error */
		return 0;
	}

	ret = fscanf(fp, "%d\n", &oldpid);
	fclose(fp);

	if ((ret == EOF) || (ret != 1))
		return 0;

	if (check_pid_valid(oldpid, cmd)) {
		*pid = oldpid;
		return 1;
	}
	return 0;
}
Exemplo n.º 6
0
void CAMLPlayer::SetSubtitle(int iStream)
{
  CSingleLock lock(m_aml_csection);

  if (iStream > (int)m_subtitle_streams.size() || iStream < 0)
    return;

  m_subtitle_index = iStream;

  // smells like a bug, if no showing subs and we get called
  // to set the subtitle, we are expected to update internal state
  // but not show the subtitle.
  if (!m_subtitle_show)
    return;

  if (check_pid_valid(m_pid))
    player_sid(m_pid, m_subtitle_streams[m_subtitle_index]->id);
}
Exemplo n.º 7
0
void CAMLPlayer::SetVolume(long nVolume)
{
  CLog::Log(LOGDEBUG, "CAMLPlayer::SetVolume(%ld)", nVolume);
  CSingleLock lock(m_aml_csection);
  // nVolume is a milliBels from -6000 (-60dB or mute) to 0 (0dB or full volume)
  // 0db is represented by Volume = 0x10000000
  // bit shifts adjust by 6db.
  // Maximum gain is 0xFFFFFFFF ~=24db
  //uint32_t volume = (1.0f + (nVolume / 6000.0f)) * (float)0x10000000;
  if (check_pid_valid(m_pid))
  {
    //int min, max;
    //float volume =
    // int audio_set_mute(m_pid, int mute_on);
    //audio_get_volume_range(m_pid, &min, &max)
    //audio_set_volume(m_pid, volume);
  }
}
Exemplo n.º 8
0
/*
 * Class:     com_farcore_playerservice_MediaPlayer
 * Method:    uninit
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_com_farcore_playerservice_AmPlayer_native_uninit
  (JNIEnv *env, jclass clazz){
    //int ret = -1;
    //ret = amadec_thread_exit();
    pid_info_t alive_pids;
    int i =-1;
    player_list_allpid(&alive_pids);
    for(i=0;i<alive_pids.num;i++){
        if(check_pid_valid(alive_pids.pid[i]))
            player_exit(alive_pids.pid[i]);
    }
    
    if(_plCtrl.file_name !=NULL){
        LOGI("collect memory for player para\n");
        free(_plCtrl.file_name);
        _plCtrl.file_name = NULL;
    }
    LOGI("player uninit ok"); 
    return 0;

}
Exemplo n.º 9
0
int
check_process_running(const char *cmd, const char *filename, pid_t * pid)
{
	pid_t oldpid;
	FILE *fp;
	int ret;
	struct stat st;

	*pid = -1;

	/*
	 * Now see if there is a pidfile associated with this cmd in /var/run
	 */
	fp = NULL;
	ret = stat(filename, &st);
	if ((ret < 0) || (!st.st_size))
		return 0;

	/*
	 * Read the pid from the file.
	 */
	fp = fopen(filename, "r");
	if (fp == NULL) {	/* error */
		return 0;
	}

	ret = fscanf(fp, "%d\n", &oldpid);
	fclose(fp);

	if ((ret == EOF) || (ret != 1))
		return 0;

	if (check_pid_valid(oldpid, cmd)) {
		*pid = oldpid;
		return 1;
	}
	return 0;
}