Browse files

Merge pull request #2691 from davilla/amlcodec

Amlcodec
  • Loading branch information...
2 parents 65c2623 + 73fae08 commit 1c4bf5d2431f09aae8489eb963a404a21a53740d @davilla davilla committed May 8, 2013
Showing with 4,122 additions and 606 deletions.
  1. +29 −0 configure.in
  2. +1 −0 tools/depends/target/libamplayer/libamplayer/include/amports/vformat.h
  3. +93 −0 tools/depends/target/libamplayer/libamplayer/include/codec.h
  4. +37 −0 tools/depends/target/libamplayer/libamplayer/include/codec_error.h
  5. +19 −0 tools/depends/target/libamplayer/libamplayer/include/codec_msg.h
  6. +108 −0 tools/depends/target/libamplayer/libamplayer/include/codec_type.h
  7. +49 −3 tools/depends/target/libamplayer/libamplayer/include/player_type.h
  8. +1 −1 xbmc/Application.cpp
  9. +1 −1 xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
  10. +35 −8 xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
  11. +2 −0 xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
  12. +6 −0 xbmc/cores/VideoRenderers/BaseRenderer.cpp
  13. +6 −17 xbmc/cores/VideoRenderers/BaseRenderer.h
  14. +1 −0 xbmc/cores/VideoRenderers/LinuxRendererGL.h
  15. +14 −0 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
  16. +1 −0 xbmc/cores/VideoRenderers/LinuxRendererGLES.h
  17. +39 −0 xbmc/cores/VideoRenderers/RenderFeatures.h
  18. +14 −0 xbmc/cores/VideoRenderers/RenderManager.cpp
  19. +4 −0 xbmc/cores/VideoRenderers/RenderManager.h
  20. +1 −0 xbmc/cores/VideoRenderers/WinRenderer.h
  21. +225 −192 xbmc/cores/amlplayer/AMLPlayer.cpp
  22. +7 −13 xbmc/cores/amlplayer/AMLPlayer.h
  23. +0 −138 xbmc/cores/amlplayer/AMLUtils.cpp
  24. +27 −4 xbmc/cores/amlplayer/DllLibamplayer.h
  25. +4 −0 xbmc/cores/amlplayer/FileURLProtocol.cpp
  26. +2 −2 xbmc/cores/amlplayer/Makefile.in
  27. +0 −1 xbmc/cores/amlplayer/amlplayer_advancedsettings.xml
  28. +13 −2 xbmc/cores/dvdplayer/DVDClock.cpp
  29. +2 −1 xbmc/cores/dvdplayer/DVDClock.h
  30. +19 −1 xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
  31. +2,175 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.cpp
  32. +86 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/AMLCodec.h
  33. +467 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.cpp
  34. +67 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecAmlogic.h
  35. +6 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
  36. +4 −0 xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h
  37. +12 −0 xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  38. +10 −4 xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
  39. +12 −0 xbmc/cores/dvdplayer/DVDStreamInfo.cpp
  40. +3 −0 xbmc/cores/dvdplayer/DVDStreamInfo.h
  41. +2 −1 xbmc/guilib/GUIVideoControl.cpp
  42. +218 −0 xbmc/utils/AMLUtils.cpp
  43. +2 −1 xbmc/{cores/amlplayer → utils}/AMLUtils.h
  44. +123 −2 xbmc/utils/BitstreamConverter.cpp
  45. +19 −7 xbmc/utils/BitstreamConverter.h
  46. +4 −0 xbmc/utils/Makefile.in
  47. +149 −201 xbmc/windowing/egl/EGLNativeTypeAmlogic.cpp
  48. +3 −6 xbmc/windowing/egl/EGLNativeTypeAmlogic.h
View
29 configure.in
@@ -30,6 +30,21 @@ AC_DEFUN([XB_ADD_PLAYER],
esac
])
+# check for enabling additional codecs
+AC_DEFUN([XB_ADD_CODEC],
+[
+ AC_MSG_CHECKING([for $2])
+ case $add_codecs in
+ *$2*)
+ AC_SUBST([USE_$1], 1)
+ AC_DEFINE([HAS_$1], 1, [using $2])
+ AC_MSG_RESULT([enabling $2])
+ ;;
+ *)
+ AC_MSG_RESULT([$2 is not enabled])
+ esac
+])
+
# check for library basenames
AC_DEFUN([XB_FIND_SONAME],
[
@@ -513,6 +528,12 @@ AC_ARG_ENABLE([gtest],
[configure_gtest=$enableval],
[configure_gtest=no])
+AC_ARG_ENABLE([codec],
+ [AS_HELP_STRING([--enable-codec],
+ [enable additional codecs from a list of comma separated names, (default is none, choices are amcodec)])],
+ [add_codecs=$enableval],
+ [add_codecs=no])
+
### External libraries options
AC_ARG_ENABLE([external-libraries],
[AS_HELP_STRING([--enable-external-libraries],
@@ -1878,6 +1899,14 @@ case $add_players in
;;
esac
+# additional internal codecs
+case $add_codecs in
+ *amcodec*)
+ AC_CHECK_HEADER([amlplayer/codec_error.h],, AC_MSG_ERROR($missing_headers))
+ XB_ADD_CODEC([LIBAMCODEC], [amcodec])
+ ;;
+esac
+
# platform specific bin utilities
if test "$build_vendor" != "apple" ; then
AC_CHECK_PROG(HAVE_GAWK,gawk,"yes","no",)
View
1 tools/depends/target/libamplayer/libamplayer/include/amports/vformat.h
@@ -48,6 +48,7 @@ typedef enum {
VIDEO_DEC_FORMAT_WMV3,
VIDEO_DEC_FORMAT_WVC1,
VIDEO_DEC_FORMAT_SW,
+ VIDEO_DEC_FORMAT_AVS,
VIDEO_DEC_FORMAT_MAX
} vdec_type_t;
View
93 tools/depends/target/libamplayer/libamplayer/include/codec.h
@@ -0,0 +1,93 @@
+/**
+* @file codec.h
+* @brief Function prototypes of codec lib
+* @author Zhang Chen <chen.zhang@amlogic.com>
+* @version 1.0.0
+* @date 2011-02-24
+*/
+/* Copyright (C) 2007-2011, Amlogic Inc.
+* All right reserved
+*
+*/
+#ifndef CODEC_CTRL_H_
+#define CODEC_CTRL_H_
+
+#include <codec_type.h>
+#include <codec_error.h>
+
+
+int codec_init(codec_para_t *);
+int codec_close(codec_para_t *);
+void codec_audio_basic_init(void);
+void codec_close_audio(codec_para_t *);
+void codec_resume_audio(codec_para_t *, unsigned int);
+int codec_reset(codec_para_t *);
+int codec_init_sub(codec_para_t *);
+int codec_open_sub_read(void);
+int codec_close_sub(codec_para_t *);
+int codec_close_sub_fd(CODEC_HANDLE);
+int codec_reset_subtile(codec_para_t *pcodec);
+int codec_poll_sub(codec_para_t *);
+int codec_poll_sub_fd(CODEC_HANDLE, int);
+int codec_get_sub_size(codec_para_t *);
+int codec_get_sub_size_fd(CODEC_HANDLE);
+int codec_read_sub_data(codec_para_t *, char *, unsigned int);
+int codec_read_sub_data_fd(CODEC_HANDLE, char *, unsigned int);
+int codec_write_sub_data(codec_para_t *, char *, unsigned int);
+int codec_init_cntl(codec_para_t *);
+int codec_close_cntl(codec_para_t *);
+int codec_poll_cntl(codec_para_t *);
+int codec_get_cntl_state(codec_para_t *);
+int codec_set_cntl_mode(codec_para_t *, unsigned int);
+int codec_set_cntl_avthresh(codec_para_t *, unsigned int);
+int codec_set_cntl_syncthresh(codec_para_t *pcodec, unsigned int syncthresh);
+int codec_reset_audio(codec_para_t *pcodec);
+int codec_set_audio_pid(codec_para_t *pcodec);
+int codec_set_sub_id(codec_para_t *pcodec);
+int codec_set_sub_type(codec_para_t *pcodec);
+int codec_audio_reinit(codec_para_t *pcodec);
+int codec_set_dec_reset(codec_para_t *pcodec);
+
+int codec_write(codec_para_t *pcodec, void *buffer, int len);
+int codec_checkin_pts(codec_para_t *pcodec, unsigned long pts);
+int codec_get_vbuf_state(codec_para_t *, struct buf_status *);
+int codec_get_abuf_state(codec_para_t *, struct buf_status *);
+int codec_get_vdec_state(codec_para_t *, struct vdec_status *);
+int codec_get_adec_state(codec_para_t *, struct adec_status *);
+
+int codec_pause(codec_para_t *);
+int codec_resume(codec_para_t *);
+int codec_audio_search(codec_para_t *p);
+int codec_set_mute(codec_para_t *p, int mute);
+int codec_get_volume_range(codec_para_t *, int *min, int *max);
+int codec_set_volume(codec_para_t *, float val);
+int codec_get_volume(codec_para_t *, float *val);
+int codec_set_lrvolume(codec_para_t *, float lvol,float rvol);
+int codec_get_lrvolume(codec_para_t *, float *lvol,float* rvol);
+int codec_get_mutesta(codec_para_t *);
+int codec_set_volume_balance(codec_para_t *, int); /*left£¨0-100)right*/
+int codec_swap_left_right(codec_para_t *);
+int codec_left_mono(codec_para_t *p);
+int codec_right_mono(codec_para_t *p);
+int codec_stereo(codec_para_t *p);
+int codec_get_soundtrack(codec_para_t *p,int* strack);
+int codec_audio_automute(void *priv, int auto_mute);
+int codec_audio_spectrum_switch(codec_para_t *p, int isStart, int interval);
+int codec_audio_isready(codec_para_t *p);
+int codec_audio_get_nb_frames(codec_para_t *p);
+int codec_audio_set_audioinfo(codec_para_t *p);
+
+int codec_get_apts(codec_para_t *pcodec);
+int codec_get_vpts(codec_para_t *pcodec);
+int codec_get_pcrscr(codec_para_t *pcodec);
+int codec_set_pcrscr(codec_para_t *pcodec, int val);
+int codec_set_syncenable(codec_para_t *pcodec, int enable);
+int codec_set_sync_audio_discont(codec_para_t *pcodec, int discontinue);
+int codec_get_sync_audio_discont(codec_para_t *pcodec);
+int codec_set_sync_video_discont(codec_para_t *pcodec, int discontinue);
+int codec_get_sync_video_discont(codec_para_t *pcodec);
+
+int codec_get_sub_num(codec_para_t *pcodec);
+int codec_get_sub_info(codec_para_t *pcodec, subtitle_info_t *sub_info);
+
+#endif
View
37 tools/depends/target/libamplayer/libamplayer/include/codec_error.h
@@ -0,0 +1,37 @@
+/**
+* @file codec_error.h
+* @brief Codec error type definitions
+* @author Zhang Chen <chen.zhang@amlogic.com>
+* @version 1.0.0
+* @date 2011-02-24
+*/
+/* Copyright (C) 2007-2011, Amlogic Inc.
+* All right reserved
+*
+*/
+
+#ifndef CODEC_ERROR_H_
+#define CODEC_ERROR_H_
+
+#define C_PAE (0x01000000)
+
+#define CODEC_ERROR_NONE ( 0)
+#define CODEC_ERROR_INVAL (C_PAE | 1)
+#define CODEC_ERROR_NOMEM (C_PAE | 2)
+#define CODEC_ERROR_BUSY (C_PAE | 3)
+#define CODEC_ERROR_IO (C_PAE | 4)
+#define CODEC_ERROR_PARAMETER (C_PAE | 5)
+#define CODEC_ERROR_AUDIO_TYPE_UNKNOW (C_PAE | 6)
+#define CODEC_ERROR_VIDEO_TYPE_UNKNOW (C_PAE | 7)
+#define CODEC_ERROR_STREAM_TYPE_UNKNOW (C_PAE | 8)
+#define CODEC_ERROR_VDEC_TYPE_UNKNOW (C_PAE | 9)
+
+#define CODEC_ERROR_INIT_FAILED (C_PAE | 10)
+#define CODEC_ERROR_SET_BUFSIZE_FAILED (C_PAE | 11)
+#define CODEC_OPEN_HANDLE_FAILED (C_PAE | 12)
+
+
+
+
+#endif
+
View
19 tools/depends/target/libamplayer/libamplayer/include/codec_msg.h
@@ -0,0 +1,19 @@
+/**
+* @file codec_msg.h
+* @brief Function prototype of codec error
+* @author Zhang Chen <chen.zhang@amlogic.com>
+* @version 1.0.0
+* @date 2011-02-24
+*/
+/* Copyright (C) 2007-2011, Amlogic Inc.
+* All right reserved
+*
+*/
+#ifndef CODEC_MSG_H
+#define CODEC_MSG_H
+
+const char * codec_error_msg(int error);
+int system_error_to_codec_error(int error);
+void print_error_msg(int error, int syserr, char *func, int line);
+
+#endif
View
108 tools/depends/target/libamplayer/libamplayer/include/codec_type.h
@@ -0,0 +1,108 @@
+/**
+* @file codec_type.h
+* @brief Definitions of codec type and structures
+* @author Zhang Chen <chen.zhang@amlogic.com>
+* @version 1.0.0
+* @date 2011-02-24
+*/
+/* Copyright (C) 2007-2011, Amlogic Inc.
+* All right reserved
+*
+*/
+#ifndef CODEC_TYPE_H_
+#define CODEC_TYPE_H_
+
+#include "amports/amstream.h"
+#include "amports/vformat.h"
+#include "amports/aformat.h"
+
+typedef int CODEC_HANDLE;
+
+typedef enum {
+ STREAM_TYPE_UNKNOW,
+ STREAM_TYPE_ES_VIDEO,
+ STREAM_TYPE_ES_AUDIO,
+ STREAM_TYPE_ES_SUB,
+ STREAM_TYPE_PS,
+ STREAM_TYPE_TS,
+ STREAM_TYPE_RM,
+} stream_type_t;
+
+typedef struct {
+ unsigned int format; ///< video format, such as H264, MPEG2...
+ unsigned int width; ///< video source width
+ unsigned int height; ///< video source height
+ unsigned int rate; ///< video source frame duration
+ unsigned int extra; ///< extra data information of video stream
+ unsigned int status; ///< status of video stream
+ unsigned int ratio; ///< aspect ratio of video source
+ void * param; ///< other parameters for video decoder
+ unsigned long long ratio64; ///< aspect ratio of video source
+} dec_sysinfo_t;
+
+typedef struct {
+ int valid; ///< audio extradata valid(1) or invalid(0), set by dsp
+ int sample_rate; ///< audio stream sample rate
+ int channels; ///< audio stream channels
+ int bitrate; ///< audio stream bit rate
+ int codec_id; ///< codec format id
+ int block_align; ///< audio block align from ffmpeg
+ int extradata_size; ///< extra data size
+ char extradata[AUDIO_EXTRA_DATA_SIZE]; ///< extra data information for decoder
+} audio_info_t;
+
+typedef struct {
+ CODEC_HANDLE handle; ///< codec device handler
+ CODEC_HANDLE cntl_handle; ///< video control device handler
+ CODEC_HANDLE sub_handle; ///< subtile device handler
+ stream_type_t stream_type; ///< stream type(es, ps, rm, ts)
+ unsigned int has_video:1; ///< stream has video(1) or not(0)
+ unsigned int has_audio:1; ///< stream has audio(1) or not(0)
+ unsigned int has_sub:1; ///< stream has subtitle(1) or not(0)
+ unsigned int noblock:1; ///< codec device is NONBLOCK(1) or not(0)
+ int video_type; ///< stream video type(H264, VC1...)
+ int audio_type; ///< stream audio type(PCM, WMA...)
+ int sub_type; ///< stream subtitle type(TXT, SSA...)
+ int video_pid; ///< stream video pid
+ int audio_pid; ///< stream audio pid
+ int sub_pid; ///< stream subtitle pid
+ int audio_channels; ///< stream audio channel number
+ int audio_samplerate; ///< steram audio sample rate
+ int vbuf_size; ///< video buffer size of codec device
+ int abuf_size; ///< audio buffer size of codec device
+ dec_sysinfo_t am_sysinfo; ///< system information for video
+ audio_info_t audio_info; ///< audio information pass to audiodsp
+ int packet_size; ///< data size per packet
+ int avsync_threshold; ///<for adec in ms>
+ void * adec_priv; ///<for adec>
+} codec_para_t;
+
+typedef struct
+{
+ signed char id;
+ unsigned char width;
+ unsigned char height;
+ unsigned char type;
+} subtitle_info_t;
+#define MAX_SUB_NUM (32)
+
+#define IS_VALID_PID(t) (t>=0 && t<=0x1fff)
+#define IS_VALID_STREAM(t) (t>0 && t<=0x1fff)
+#define IS_VALID_ATYPE(t) (t>=0 && t<AFORMAT_MAX)
+#define IS_VALID_VTYPE(t) (t>=0 && t<VFORMAT_MAX)
+
+//pass to arm audio decoder
+typedef struct {
+ int sample_rate; ///< audio stream sample rate
+ int channels; ///< audio stream channels
+ int format; ///< codec format id
+ int handle; ///< codec device handler
+ int extradata_size; ///< extra data size
+ char extradata[AUDIO_EXTRA_DATA_SIZE];
+} arm_audio_info;
+
+//audio decoder type, default arc
+#define AUDIO_ARC_DECODER 0
+#define AUDIO_ARM_DECODER 1
+#define AUDIO_FFMPEG_DECODER 2
+#endif
View
52 tools/depends/target/libamplayer/libamplayer/include/player_type.h
@@ -5,7 +5,14 @@
#include <stream_format.h>
#define MSG_SIZE 64
+#if defined(HAS_AMLPLAYER_CHAPTERS)
+#define MAX_CHAPTERS 64
+#endif
+#if defined(HAS_AMLPLAYER_VIDEO_STREAMS10)
+#define MAX_VIDEO_STREAMS 10
+#else
#define MAX_VIDEO_STREAMS 8
+#endif
#define MAX_AUDIO_STREAMS 8
#define MAX_SUB_INTERNAL 8
#define MAX_SUB_EXTERNAL 24
@@ -64,8 +71,6 @@ typedef enum
PLAYER_DIVX_AUTHORERR = 0x40001,
PLAYER_DIVX_RENTAL_EXPIRED = 0x40002,
PLAYER_DIVX_RENTAL_VIEW = 0x40003,
-
-
}player_status;
@@ -107,17 +112,22 @@ typedef struct
typedef struct
{
+ int index;
int id;
int channel;
int sample_rate;
int bit_rate;
aformat_t aformat;
int duration;
audio_tag_info *audio_tag;
+#if defined(HAS_AMLPLAYER_AUDIO_LANG)
+ char audio_language[4];
+#endif
}maudio_info_t;
typedef struct
{
+ int index;
char id;
char internal_external; //0:internal_sub 1:external_sub
unsigned short width;
@@ -147,14 +157,33 @@ typedef struct
int cur_sub_index;
int seekable;
int drm_check;
+#if defined(HAS_AMLPLAYER_VIDEO_STREAMS10)
+ int t1;
+ int t2;
+#endif
+#if defined(HAS_AMLPLAYER_CHAPTERS)
+ int has_chapter;
+ int total_chapter_num;
+#endif
}mstream_info_t;
+#if defined(HAS_AMLPLAYER_CHAPTERS)
+typedef struct
+{
+ char *name;
+ int64_t seekto_ms;
+} mchapter_info_t;
+#endif
+
typedef struct
{
mstream_info_t stream_info;
mvideo_info_t *video_info[MAX_VIDEO_STREAMS];
maudio_info_t *audio_info[MAX_AUDIO_STREAMS];
msub_info_t *sub_info[MAX_SUB_STREAMS];
+#if defined(HAS_AMLPLAYER_CHAPTERS)
+ mchapter_info_t *chapter_info[MAX_CHAPTERS];
+#endif
}media_info_t;
typedef struct player_info
@@ -213,10 +242,25 @@ typedef enum
PLAYER_EVENTS_ERROR, ///<ext1=error_code,ext2=message char *
PLAYER_EVENTS_BUFFERING, ///<ext1=buffered=d,d={0-100},ext2=0,
PLAYER_EVENTS_FILE_TYPE, ///<ext1=player_file_type_t*,ext2=0
+ PLAYER_EVENTS_HTTP_WV, ///<(need use DRMExtractor),ext1=0, ext2=0
+ PLAYER_EVENTS_HWBUF_DATA_SIZE_CHANGED, ///<(need use DRMExtractor),ext1=0, ext2=0
}player_events;
typedef struct
{
+ int vbufused;
+ int vbufsize;
+ int vdatasize;
+ int abufused;
+ int abufsize;
+ int adatasize;
+ int sbufused;
+ int sbufsize;
+ int sdatasize;
+}hwbufstats_t;
+
+typedef struct
+{
update_state_fun_t update_statue_callback;
int update_interval;
long callback_old_time;
@@ -231,7 +275,7 @@ typedef struct
int video_index; //video track, no assigned, please set to -1
int audio_index; //audio track, no assigned, please set to -1
int sub_index; //subtitle track, no assigned, please set to -1
- int t_pos; //start postion, use second as unit
+ float t_pos; //start postion, use second as unit
int read_max_cnt; //read retry maxium counts, if exceed it, return error
int avsync_threshold; //for adec av sync threshold in ms
union
@@ -265,7 +309,9 @@ typedef struct
int is_type_parser; //is try to get file type
int buffing_starttime_s; //for rest buffing_middle,buffering seconds data to start.
int buffing_force_delay_s;
+ int lowbuffermode_flag;
int reserved [56]; //reserved for furthur used,some one add more ,can del reserved num
+ int SessionID;
}play_control_t;
#endif
View
2 xbmc/Application.cpp
@@ -2086,7 +2086,7 @@ void CApplication::Render()
bool extPlayerActive = m_eCurrentPlayer == EPC_EXTPLAYER && IsPlaying() && !m_AppFocused;
m_bPresentFrame = false;
- if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused())
+ if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused() && g_renderManager.RendererHandlesPresent())
{
CSingleLock lock(m_frameMutex);
View
2 xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
@@ -146,7 +146,7 @@ bool CAESinkALSA::Initialize(AEAudioFormat &format, std::string &device)
m_channelLayout = GetChannelLayout(format);
m_passthrough = false;
}
-#if defined(HAS_AMLPLAYER)
+#if defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC)
if (aml_present())
{
aml_set_audio_passthrough(m_passthrough);
View
43 xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
@@ -23,8 +23,8 @@
#include "Utils/AERingBuffer.h"
#include "android/activity/XBMCApp.h"
#include "utils/log.h"
-#if defined(HAS_AMLPLAYER)
-#include "cores/amlplayer/AMLUtils.h"
+#if defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC)
+#include "utils/AMLUtils.h"
#endif
#include <jni.h>
@@ -83,14 +83,14 @@ CAESinkAUDIOTRACK::CAESinkAUDIOTRACK()
m_audiotrackbuffer_sec = 0.0;
m_audiotrack_empty_sec = 0.0;
m_volume = 0.0;
-#if defined(HAS_AMLPLAYER)
+#if defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC)
aml_cpufreq_limit(true);
#endif
}
CAESinkAUDIOTRACK::~CAESinkAUDIOTRACK()
{
-#if defined(HAS_AMLPLAYER)
+#if defined(HAS_AMLPLAYER) || defined(HAS_LIBAMCODEC)
aml_cpufreq_limit(false);
#endif
}
@@ -99,6 +99,16 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
{
m_format = format;
+ if (AE_IS_RAW(m_format.m_dataFormat))
+ m_passthrough = true;
+ else
+ m_passthrough = false;
+
+#if defined(HAS_LIBAMCODEC)
+ if (aml_present())
+ aml_set_audio_passthrough(m_passthrough);
+#endif
+
// default to 44100, all android devices support it.
// then check if we can support the requested rate.
unsigned int sampleRate = 44100;
@@ -173,7 +183,12 @@ double CAESinkAUDIOTRACK::GetDelay()
// AudioMixer (if any) and audio hardware driver.
double sinkbuffer_seconds_to_empty = m_sinkbuffer_sec_per_byte * (double)m_sinkbuffer->GetReadSize();
- return sinkbuffer_seconds_to_empty + m_audiotrack_empty_sec;
+ sinkbuffer_seconds_to_empty += m_audiotrack_empty_sec;
+#if defined(HAS_LIBAMCODEC)
+ if (sinkbuffer_seconds_to_empty > 0.0)
+ sinkbuffer_seconds_to_empty += 0.250;
+#endif
+ return sinkbuffer_seconds_to_empty;
}
double CAESinkAUDIOTRACK::GetCacheTime()
@@ -182,7 +197,12 @@ double CAESinkAUDIOTRACK::GetCacheTime()
// to underrun the buffer if no sample is added.
double sinkbuffer_seconds_to_empty = m_sinkbuffer_sec_per_byte * (double)m_sinkbuffer->GetReadSize();
- return sinkbuffer_seconds_to_empty + m_audiotrack_empty_sec;
+ sinkbuffer_seconds_to_empty += m_audiotrack_empty_sec;
+#if defined(HAS_LIBAMCODEC)
+ if (sinkbuffer_seconds_to_empty > 0.0)
+ sinkbuffer_seconds_to_empty += 0.250;
+#endif
+ return sinkbuffer_seconds_to_empty;
}
double CAESinkAUDIOTRACK::GetCacheTotal()
@@ -244,7 +264,8 @@ void CAESinkAUDIOTRACK::SetVolume(float scale)
// Android uses fixed steps, reverse scale back to percent
float gain = CAEUtil::ScaleToGain(scale);
m_volume = CAEUtil::GainToPercent(gain);
- m_volume_changed = true;
+ if (!m_passthrough)
+ m_volume_changed = true;
}
void CAESinkAUDIOTRACK::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
@@ -313,6 +334,12 @@ void CAESinkAUDIOTRACK::Process()
min_buffer_size,
GetStaticIntField(jenv, "AudioTrack", "MODE_STREAM"));
+ // Set the initial volume
+ float volume = 1.0;
+ if (!m_passthrough)
+ volume = m_volume;
+ CXBMCApp::SetSystemVolume(jenv, volume);
+
// The AudioTrack object has been created and waiting to play,
m_inited.Set();
// yield to give other threads a chance to do some work.
@@ -329,7 +356,7 @@ void CAESinkAUDIOTRACK::Process()
while (!m_bStop)
{
- if (m_volume_changed)
+ if (m_volume_changed && !m_passthrough)
{
// check of volume changes and make them,
// do it here to keep jni calls local to this thread.
View
2 xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
@@ -62,6 +62,8 @@ class CAESinkAUDIOTRACK : public CThread, public IAESink
CEvent m_wake;
CEvent m_inited;
volatile bool m_draining;
+ bool m_passthrough;
+
double m_audiotrackbuffer_sec;
double m_audiotrack_empty_sec;
};
View
6 xbmc/cores/VideoRenderers/BaseRenderer.cpp
@@ -69,6 +69,12 @@ void CBaseRenderer::RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCa
m_RenderUpdateCallBackCtx = ctx;
}
+void CBaseRenderer::RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn)
+{
+ m_RenderFeaturesCallBackFn = fn;
+ m_RenderFeaturesCallBackCtx = ctx;
+}
+
void CBaseRenderer::ChooseBestResolution(float fps)
{
if (fps == 0.0) return;
View
23 xbmc/cores/VideoRenderers/BaseRenderer.h
@@ -25,6 +25,7 @@
#include "guilib/Resolution.h"
#include "guilib/Geometry.h"
#include "RenderFormats.h"
+#include "RenderFeatures.h"
#define MAX_PLANES 3
#define MAX_FIELDS 3
@@ -52,23 +53,6 @@ enum EFIELDSYNC
FS_BOT
};
-enum ERENDERFEATURE
-{
- RENDERFEATURE_GAMMA,
- RENDERFEATURE_BRIGHTNESS,
- RENDERFEATURE_CONTRAST,
- RENDERFEATURE_NOISE,
- RENDERFEATURE_SHARPNESS,
- RENDERFEATURE_NONLINSTRETCH,
- RENDERFEATURE_ROTATION,
- RENDERFEATURE_STRETCH,
- RENDERFEATURE_CROP,
- RENDERFEATURE_ZOOM,
- RENDERFEATURE_VERTICAL_SHIFT,
- RENDERFEATURE_PIXEL_RATIO,
- RENDERFEATURE_POSTPROCESS
-};
-
// Render Methods
enum RenderMethods
{
@@ -82,6 +66,7 @@ enum RenderMethods
};
typedef void (*RenderUpdateCallBackFn)(const void *ctx, const CRect &SrcRect, const CRect &DestRect);
+typedef void (*RenderFeaturesCallBackFn)(const void *ctx, Features &renderFeatures);
struct DVDVideoPicture;
@@ -107,6 +92,7 @@ class CBaseRenderer
std::vector<ERenderFormat> SupportedFormats() { return std::vector<ERenderFormat>(); }
virtual void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
+ virtual void RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn);
static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current);
@@ -149,4 +135,7 @@ class CBaseRenderer
const void* m_RenderUpdateCallBackCtx;
RenderUpdateCallBackFn m_RenderUpdateCallBackFn;
+
+ const void* m_RenderFeaturesCallBackCtx;
+ RenderFeaturesCallBackFn m_RenderFeaturesCallBackFn;
};
View
1 xbmc/cores/VideoRenderers/LinuxRendererGL.h
@@ -30,6 +30,7 @@
#include "guilib/Shader.h"
#include "settings/VideoSettings.h"
#include "RenderFlags.h"
+#include "RenderFormats.h"
#include "guilib/GraphicContext.h"
#include "BaseRenderer.h"
#include "RenderFormats.h"
View
14 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -202,6 +202,18 @@ bool CLinuxRendererGLES::Configure(unsigned int width, unsigned int height, unsi
m_RenderUpdateCallBackCtx = NULL;
if ((m_format == RENDER_FMT_BYPASS) && g_application.GetCurrentPlayer())
{
+ m_renderFeatures.clear();
+ m_scalingMethods.clear();
+ m_deinterlaceModes.clear();
+ m_deinterlaceMethods.clear();
+
+ if (m_RenderFeaturesCallBackFn)
+ {
+ (*m_RenderFeaturesCallBackFn)(m_RenderFeaturesCallBackCtx, m_renderFeatures);
+ // after setting up m_renderFeatures, we are done with the callback
+ m_RenderFeaturesCallBackFn = NULL;
+ m_RenderFeaturesCallBackCtx = NULL;
+ }
g_application.m_pPlayer->GetRenderFeatures(m_renderFeatures);
g_application.m_pPlayer->GetDeinterlaceMethods(m_deinterlaceMethods);
g_application.m_pPlayer->GetDeinterlaceModes(m_deinterlaceModes);
@@ -758,6 +770,8 @@ void CLinuxRendererGLES::UnInit()
m_bConfigured = false;
m_RenderUpdateCallBackFn = NULL;
m_RenderUpdateCallBackCtx = NULL;
+ m_RenderFeaturesCallBackFn = NULL;
+ m_RenderFeaturesCallBackCtx = NULL;
}
inline void CLinuxRendererGLES::ReorderDrawPoints()
View
1 xbmc/cores/VideoRenderers/LinuxRendererGLES.h
@@ -29,6 +29,7 @@
#include "xbmc/guilib/Shader.h"
#include "settings/VideoSettings.h"
#include "RenderFlags.h"
+#include "RenderFormats.h"
#include "guilib/GraphicContext.h"
#include "BaseRenderer.h"
#include "xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
View
39 xbmc/cores/VideoRenderers/RenderFeatures.h
@@ -0,0 +1,39 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+enum ERENDERFEATURE
+{
+ RENDERFEATURE_GAMMA,
+ RENDERFEATURE_BRIGHTNESS,
+ RENDERFEATURE_CONTRAST,
+ RENDERFEATURE_NOISE,
+ RENDERFEATURE_SHARPNESS,
+ RENDERFEATURE_NONLINSTRETCH,
+ RENDERFEATURE_ROTATION,
+ RENDERFEATURE_STRETCH,
+ RENDERFEATURE_CROP,
+ RENDERFEATURE_ZOOM,
+ RENDERFEATURE_VERTICAL_SHIFT,
+ RENDERFEATURE_PIXEL_RATIO,
+ RENDERFEATURE_POSTPROCESS
+};
+
+typedef std::vector<int> Features;
View
14 xbmc/cores/VideoRenderers/RenderManager.cpp
@@ -261,6 +261,9 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
CApplicationMessenger::Get().SwitchToFullscreen();
lock.Enter();
}
+ if( format & RENDER_FMT_BYPASS )
+ m_presentmethod = PRESENT_METHOD_BYPASS;
+
m_pRenderer->Update(false);
m_bIsStarted = true;
m_bReconfigured = true;
@@ -271,6 +274,11 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
return result;
}
+bool CXBMCRenderManager::RendererHandlesPresent()
+{
+ return IsConfigured() && m_presentmethod != PRESENT_METHOD_BYPASS;
+}
+
bool CXBMCRenderManager::IsConfigured()
{
if (!m_pRenderer)
@@ -657,6 +665,12 @@ void CXBMCRenderManager::RegisterRenderUpdateCallBack(const void *ctx, RenderUpd
m_pRenderer->RegisterRenderUpdateCallBack(ctx, fn);
}
+void CXBMCRenderManager::RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn)
+{
+ if (m_pRenderer)
+ m_pRenderer->RegisterRenderFeaturesCallBack(ctx, fn);
+}
+
void CXBMCRenderManager::Render(bool clear, DWORD flags, DWORD alpha)
{
CSharedLock lock(m_sharedSection);
View
4 xbmc/cores/VideoRenderers/RenderManager.h
@@ -110,6 +110,8 @@ class CXBMCRenderManager
void UpdateResolution();
+ bool RendererHandlesPresent();
+
#ifdef HAS_GL
CLinuxRendererGL *m_pRenderer;
#elif HAS_GLES == 2
@@ -131,6 +133,7 @@ class CXBMCRenderManager
CSharedSection& GetSection() { return m_sharedSection; };
void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
+ void RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn);
protected:
void Render(bool clear, DWORD flags, DWORD alpha);
@@ -164,6 +167,7 @@ class CXBMCRenderManager
PRESENT_METHOD_BLEND,
PRESENT_METHOD_WEAVE,
PRESENT_METHOD_BOB,
+ PRESENT_METHOD_BYPASS,
};
double m_displayLatency;
View
1 xbmc/cores/VideoRenderers/WinRenderer.h
@@ -24,6 +24,7 @@
#include "guilib/GraphicContext.h"
#include "RenderFlags.h"
+#include "RenderFormats.h"
#include "BaseRenderer.h"
#include "guilib/D3DResource.h"
#include "RenderCapture.h"
View
417 xbmc/cores/amlplayer/AMLPlayer.cpp
@@ -27,6 +27,7 @@
#include "GUIInfoManager.h"
#include "video/VideoThumbLoader.h"
#include "Util.h"
+#include "cores/AudioEngine/AEFactory.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "cores/VideoRenderers/RenderFlags.h"
#include "cores/VideoRenderers/RenderFormats.h"
@@ -55,9 +56,23 @@
#include "settings/VideoSettings.h"
// amlogic libplayer
-#include "AMLUtils.h"
+#include "utils/AMLUtils.h"
#include "DllLibamplayer.h"
+static float VolumePercentToScale(float volume)
+{
+ float audio_volume = 0.0;
+ if (volume > VOLUME_MINIMUM)
+ {
+ float dB = CAEUtil::PercentToGain(volume);
+ audio_volume = CAEUtil::GainToScale(dB);
+ }
+ if (audio_volume >= 0.99f)
+ audio_volume = 1.0f;
+
+ return audio_volume;
+}
+
struct AMLChapterInfo
{
std::string name;
@@ -302,7 +317,7 @@ static const char* AudioCodecName(int aformat)
////////////////////////////////////////////////////////////////////////////////////////////
CAMLSubTitleThread::CAMLSubTitleThread(DllLibAmplayer *dll) :
- CThread("AMLSubTitle"),
+ CThread("CAMLSubTitleThread"),
m_dll(dll),
m_subtitle_codec(-1)
{
@@ -313,6 +328,20 @@ CAMLSubTitleThread::~CAMLSubTitleThread()
StopThread();
}
+void CAMLSubTitleThread::Flush()
+{
+ CSingleLock lock(m_subtitle_csection);
+ if (m_subtitle_strings.size())
+ {
+ // remove any expired subtitles
+ std::deque<AMLSubtitle*>::iterator it = m_subtitle_strings.begin();
+ while (it != m_subtitle_strings.end())
+ {
+ it = m_subtitle_strings.erase(it);
+ }
+ }
+}
+
void CAMLSubTitleThread::UpdateSubtitle(CStdString &subtitle, int64_t elapsed_ms)
{
CSingleLock lock(m_subtitle_csection);
@@ -364,6 +393,7 @@ void CAMLSubTitleThread::Process(void)
int sub_size = m_dll->codec_get_sub_size_fd(m_subtitle_codec);
if (sub_size > 0)
{
+ int sub_type = 0, sub_pts = 0;
// calloc sub_size + 1 so we auto terminate the string
char *sub_buffer = (char*)calloc(sub_size + 1, 1);
m_dll->codec_read_sub_data_fd(m_subtitle_codec, sub_buffer, sub_size);
@@ -380,9 +410,10 @@ void CAMLSubTitleThread::Process(void)
CSingleLock lock(m_subtitle_csection);
AMLSubtitle *subtitle = new AMLSubtitle;
- int sub_type = (sub_buffer[5] << 16) | (sub_buffer[6] << 8) | sub_buffer[7];
+
+ sub_type = (sub_buffer[5] << 16) | (sub_buffer[6] << 8) | sub_buffer[7];
// sub_pts are in ffmpeg timebase, not ms timebase, convert it.
- int sub_pts = (sub_buffer[12] << 24) | (sub_buffer[13] << 16) | (sub_buffer[14] << 8) | sub_buffer[15];
+ sub_pts = (sub_buffer[12] << 24) | (sub_buffer[13] << 16) | (sub_buffer[14] << 8) | sub_buffer[15];
/* TODO: handle other subtitle codec types
// subtitle codecs
@@ -482,12 +513,14 @@ void CAMLSubTitleThread::Process(void)
}
else
{
- usleep(100 * 1000);
+ if (!m_bStop)
+ usleep(100 * 1000);
}
}
else
{
- usleep(250 * 1000);
+ if (!m_bStop)
+ usleep(250 * 1000);
}
}
m_subtitle_strings.clear();
@@ -524,7 +557,6 @@ CAMLPlayer::CAMLPlayer(IPlayerCallback &callback)
m_subtitle_show (false ),
m_subtitle_delay (0 ),
m_subtitle_thread (NULL ),
- m_chapter_index (0 ),
m_chapter_count (0 ),
m_show_mainvideo (0 ),
m_view_mode (0 ),
@@ -544,6 +576,13 @@ CAMLPlayer::CAMLPlayer(IPlayerCallback &callback)
// for external subtitles
m_dvdOverlayContainer = new CDVDOverlayContainer;
m_dvdPlayerSubtitle = new CDVDPlayerSubtitle(m_dvdOverlayContainer);
+
+ // Suspend AE temporarily so exclusive or hog-mode sinks
+ // don't block external player's access to audio device
+ if (!CAEFactory::Suspend())
+ {
+ CLog::Log(LOGNOTICE,"%s: Failed to suspend AudioEngine before launching external player", __FUNCTION__);
+ }
}
CAMLPlayer::~CAMLPlayer()
@@ -553,6 +592,12 @@ CAMLPlayer::~CAMLPlayer()
delete m_dvdPlayerSubtitle;
delete m_dvdOverlayContainer;
delete m_dll, m_dll = NULL;
+
+ // Resume AE processing of XBMC native audio
+ if (!CAEFactory::Resume())
+ {
+ CLog::Log(LOGFATAL, "%s: Failed to restart AudioEngine after return from external player",__FUNCTION__);
+ }
}
bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
@@ -570,11 +615,14 @@ bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
m_item = file;
m_options = options;
+ m_pid = -1;
m_elapsed_ms = 0;
m_duration_ms = 0;
m_audio_info = "none";
m_audio_delay = 0;
+ m_audio_mute = CAEFactory::IsMuted();
+ m_audio_volume = VolumePercentToScale(CAEFactory::GetVolume());
m_audio_passthrough_ac3 = CSettings::Get().GetBool("audiooutput.ac3passthrough");
m_audio_passthrough_dts = CSettings::Get().GetBool("audiooutput.dtspassthrough");
@@ -587,7 +635,6 @@ bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
m_subtitle_delay = 0;
m_subtitle_thread = NULL;
- m_chapter_index = 0;
m_chapter_count = 0;
m_show_mainvideo = -1;
@@ -598,6 +645,9 @@ bool CAMLPlayer::OpenFile(const CFileItem &file, const CPlayerOptions &options)
ClearStreamInfos();
+ if (m_item.IsDVDFile() || m_item.IsDVD())
+ return false;
+
// setup to spin the busy dialog until we are playing
m_ready.Reset();
@@ -805,7 +855,8 @@ float CAMLPlayer::GetPercentage()
void CAMLPlayer::SetMute(bool bOnOff)
{
m_audio_mute = bOnOff;
-#if !defined(TARGET_ANDROID)
+
+#if defined(HAS_AMLPLAYER_AUDIO_SETVOLUME)
CSingleLock lock(m_aml_csection);
if (m_dll->check_pid_valid(m_pid))
{
@@ -819,16 +870,10 @@ void CAMLPlayer::SetMute(bool bOnOff)
void CAMLPlayer::SetVolume(float volume)
{
- m_audio_volume = 0.0f;
- if (volume > VOLUME_MINIMUM)
- {
- float dB = CAEUtil::PercentToGain(volume);
- m_audio_volume = CAEUtil::GainToScale(dB);
- }
- if (m_audio_volume >= 0.99f)
- m_audio_volume = 1.0f;
+ // volume is a float percent from 0.0 to 1.0
+ m_audio_volume = VolumePercentToScale(volume);
-#if !defined(TARGET_ANDROID)
+#if defined(HAS_AMLPLAYER_AUDIO_SETVOLUME)
CSingleLock lock(m_aml_csection);
if (!m_audio_mute && m_dll->check_pid_valid(m_pid))
m_dll->audio_set_volume(m_pid, m_audio_volume);
@@ -892,11 +937,13 @@ void CAMLPlayer::SetAVDelay(float fValue)
CLog::Log(LOGDEBUG, "CAMLPlayer::SetAVDelay (%f)", fValue);
m_audio_delay = fValue * 1000.0;
+#if defined(HAS_AMLPLAYER_AUDIO_SETDELAY)
if (m_audio_streams.size() && m_dll->check_pid_valid(m_pid))
{
CSingleLock lock(m_aml_csection);
m_dll->audio_set_delay(m_pid, m_audio_delay);
}
+#endif
}
float CAMLPlayer::GetAVDelay()
@@ -961,7 +1008,12 @@ void CAMLPlayer::SetSubtitle(int iStream)
return;
if (m_dll->check_pid_valid(m_pid) && m_subtitle_streams[m_subtitle_index]->source == STREAM_SOURCE_NONE)
+ {
m_dll->player_sid(m_pid, m_subtitle_streams[m_subtitle_index]->id);
+ aml_set_sysfs_int("/sys/class/subtitle/curr", m_subtitle_index);
+ if (m_subtitle_thread)
+ m_subtitle_thread->Flush();
+ }
else
{
m_dvdPlayerSubtitle->CloseStream(true);
@@ -981,12 +1033,19 @@ void CAMLPlayer::SetSubtitleVisible(bool bVisible)
if (m_subtitle_show && m_subtitle_count)
{
+ if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream < m_subtitle_count)
+ m_subtitle_index = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
// 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_index = 0;
if (m_dll->check_pid_valid(m_pid) && m_subtitle_streams[m_subtitle_index]->source == STREAM_SOURCE_NONE)
+ {
m_dll->player_sid(m_pid, m_subtitle_streams[m_subtitle_index]->id);
+ aml_set_sysfs_int("/sys/class/subtitle/curr", m_subtitle_index);
+ if (m_subtitle_thread)
+ m_subtitle_thread->Flush();
+ }
else
OpenSubtitleStream(m_subtitle_index);
}
@@ -1004,21 +1063,33 @@ void CAMLPlayer::Update(bool bPauseDrawing)
g_renderManager.Update(bPauseDrawing);
}
+void CAMLPlayer::GetVideoRect(CRect& SrcRect, CRect& DestRect)
+{
+ g_renderManager.GetVideoRect(SrcRect, DestRect);
+}
+
+void CAMLPlayer::GetVideoAspectRatio(float &fAR)
+{
+ fAR = g_renderManager.GetAspectRatio();
+}
+
int CAMLPlayer::GetChapterCount()
{
return m_chapter_count;
}
int CAMLPlayer::GetChapter()
{
+ // returns a one based value or zero if no chapters
GetStatus();
- for (int i = 0; i < m_chapter_count - 1; i++)
+ int chapter_index = -1;
+ for (int i = 0; i < m_chapter_count; i++)
{
- if (m_elapsed_ms >= m_chapters[i]->seekto_ms && m_elapsed_ms < m_chapters[i + 1]->seekto_ms)
- return i + 1;
+ if (m_elapsed_ms >= m_chapters[i]->seekto_ms)
+ chapter_index = i;
}
- return 0;
+ return chapter_index + 1;
}
void CAMLPlayer::GetChapterName(CStdString& strChapterName)
@@ -1071,7 +1142,7 @@ float CAMLPlayer::GetActualFPS()
return video_fps;
}
-void CAMLPlayer::SeekTime(__int64 seek_ms)
+void CAMLPlayer::SeekTime(int64_t seek_ms)
{
CSingleLock lock(m_aml_csection);
@@ -1091,17 +1162,15 @@ void CAMLPlayer::SeekTime(__int64 seek_ms)
m_dll->player_timesearch(m_pid, (float)seek_ms/1000.0);
WaitForSearchOK(5000);
WaitForPlaying(5000);
- // restore system volume setting.
- SetVolume(m_audio_volume);
}
}
-__int64 CAMLPlayer::GetTime()
+int64_t CAMLPlayer::GetTime()
{
return m_elapsed_ms;
}
-__int64 CAMLPlayer::GetTotalTime()
+int64_t CAMLPlayer::GetTotalTime()
{
return m_duration_ms;
}
@@ -1268,7 +1337,6 @@ void CAMLPlayer::OnStartup()
void CAMLPlayer::OnExit()
{
//CLog::Log(LOGNOTICE, "CAMLPlayer::OnExit()");
- Sleep(1000);
m_bStop = true;
// if we didn't stop playing, advance to the next item in xbmc's playlist
@@ -1289,15 +1357,6 @@ void CAMLPlayer::Process()
CLog::Log(LOGNOTICE, "CAMLPlayer::Process");
try
{
- if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
- {
- if (!WaitForPausedThumbJobs(20000))
- {
- CJobManager::GetInstance().UnPause(kJobTypeMediaFlags);
- throw "CAMLPlayer::Process:thumbgen jobs still running !!!";
- }
- }
-
static AML_URLProtocol vfs_protocol = {
"vfs",
CFileURLProtocol::Open,
@@ -1368,6 +1427,33 @@ void CAMLPlayer::Process()
vfs_protocol.name = http_name;
url = "xb-" + url;
}
+ else if (url.Left(strlen("sftp://")).Equals("sftp://"))
+ {
+ // the name string needs to persist
+ static const char *http_name = "xb-sftp";
+ vfs_protocol.name = http_name;
+ url = "xb-" + url;
+ }
+ else if (url.Left(strlen("udp://")).Equals("udp://"))
+ {
+ std::string udp_params;
+ // bump up the default udp params for ffmpeg.
+ // ffmpeg will strip out 'dummy=10', we only add it
+ // to make the logic below with prpending '&' work right.
+ // to watch for udp errors, 'cat /proc/net/udp'
+ if (url.find("?") == std::string::npos)
+ udp_params.append("?dummy=10");
+ if (url.find("pkt_size=") == std::string::npos)
+ udp_params.append("&pkt_size=5264");
+ if (url.find("buffer_size=") == std::string::npos)
+ udp_params.append("&buffer_size=5390336");
+ // newer ffmpeg uses fifo_size instead of buf_size
+ if (url.find("buf_size=") == std::string::npos)
+ udp_params.append("&buf_size=5390336");
+
+ if (udp_params.size() > 0)
+ url.append(udp_params);
+ }
CLog::Log(LOGDEBUG, "CAMLPlayer::Process: URL=%s", url.c_str());
if (m_dll->player_init() != PLAYER_SUCCESS)
@@ -1376,7 +1462,7 @@ void CAMLPlayer::Process()
throw "CAMLPlayer::Process:player init failed";
}
CLog::Log(LOGDEBUG, "player init......");
- usleep(250 * 1000);
+ usleep(50 * 1000);
// must be after player_init
m_dll->av_register_protocol2(&vfs_protocol, sizeof(vfs_protocol));
@@ -1400,13 +1486,20 @@ void CAMLPlayer::Process()
play_control.need_start = 1; // if 0,you can omit player_start_play API.
// just play video/audio immediately.
// if 1,then need call "player_start_play" API;
- //play_control.auto_buffing_enable = 1;
- //play_control.buffing_min = 0.2;
- //play_control.buffing_middle = 0.5;
- //play_control.buffing_max = 0.8;
- //play_control.byteiobufsize =; // maps to av_open_input_file buffer size
- //play_control.loopbufsize =;
- //play_control.enable_rw_on_pause =;
+ play_control.displast_frame = 0; // 0:black out when player exit 1:keep last frame when player exit
+
+ // tweak player playback buffers for udp
+ if (url.Left(strlen("udp://")).Equals("udp://"))
+ {
+ play_control.auto_buffing_enable = 1;
+ play_control.buffing_min = 0.01; // default = 0.01
+ play_control.buffing_middle = 0.02; // default = 0.02
+ play_control.buffing_max = 0.20; // default = 0.80
+ play_control.byteiobufsize = 1024 * 128; // maps to av_open_input_file buffer size (1024 * 32)
+ //play_control.loopbufsize =;
+ //play_control.enable_rw_on_pause =;
+ }
+
m_aml_state.clear();
m_aml_state.push_back(0);
m_pid = m_dll->player_start(&play_control, 0);
@@ -1445,13 +1538,7 @@ void CAMLPlayer::Process()
// get our initial status.
GetStatus();
- // restore mute setting.
- SetMute(g_application.IsMuted());
-
- // restore system volume setting.
- SetVolume(g_application.GetVolume(false));
-
- // the default staturation is to high, drop it
+ // the default staturation is too high, drop it
SetVideoSaturation(110);
// drop CGUIDialogBusy dialog and release the hold in OpenFile.
@@ -1557,13 +1644,14 @@ void CAMLPlayer::Process()
case PLAYER_EXIT:
if (m_log_level > 5)
{
- CLog::Log(LOGDEBUG, "CAMLPlayer::Process PLAYER_STOPED");
+ CLog::Log(LOGDEBUG, "CAMLPlayer::Process PLAYER_STOPPED");
CLog::Log(LOGDEBUG, "CAMLPlayer::Process: %s", m_dll->player_status2str(pstatus));
}
stopPlaying = true;
break;
}
- usleep(250 * 1000);
+ if (!stopPlaying)
+ usleep(250 * 1000);
}
}
}
@@ -1599,48 +1687,45 @@ void CAMLPlayer::Process()
if (m_log_level > 5)
CLog::Log(LOGDEBUG, "CAMLPlayer::Process exit");
}
-/*
-void CAMLPlayer::GetRenderFeatures(Features* renderFeatures)
+
+void CAMLPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
{
- renderFeatures->push_back(RENDERFEATURE_ZOOM);
- renderFeatures->push_back(RENDERFEATURE_CONTRAST);
- renderFeatures->push_back(RENDERFEATURE_BRIGHTNESS);
- renderFeatures->push_back(RENDERFEATURE_STRETCH);
- return;
+ renderFeatures.push_back(RENDERFEATURE_ZOOM);
+ renderFeatures.push_back(RENDERFEATURE_CONTRAST);
+ renderFeatures.push_back(RENDERFEATURE_BRIGHTNESS);
+ renderFeatures.push_back(RENDERFEATURE_STRETCH);
}
-void CAMLPlayer::GetDeinterlaceMethods(Features* deinterlaceMethods)
+void CAMLPlayer::GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods)
{
- deinterlaceMethods->push_back(VS_INTERLACEMETHOD_DEINTERLACE);
- return;
+ deinterlaceMethods.push_back(VS_INTERLACEMETHOD_DEINTERLACE);
}
-void CAMLPlayer::GetDeinterlaceModes(Features* deinterlaceModes)
+void CAMLPlayer::GetDeinterlaceModes(std::vector<int> &deinterlaceModes)
{
- deinterlaceModes->push_back(VS_DEINTERLACEMODE_AUTO);
- return;
+ deinterlaceModes.push_back(VS_DEINTERLACEMODE_AUTO);
}
-void CAMLPlayer::GetScalingMethods(Features* scalingMethods)
+void CAMLPlayer::GetScalingMethods(std::vector<int> &scalingMethods)
{
- return;
}
-void CAMLPlayer::GetAudioCapabilities(Features* audioCaps)
+void CAMLPlayer::GetAudioCapabilities(std::vector<int> &audioCaps)
{
- audioCaps->push_back(IPC_AUD_OFFSET);
- audioCaps->push_back(IPC_AUD_SELECT_STREAM);
- return;
+ audioCaps.push_back(IPC_AUD_SELECT_STREAM);
+ audioCaps.push_back(IPC_AUD_SELECT_OUTPUT);
+#if defined(HAS_AMLPLAYER_AUDIO_SETDELAY)
+ audioCaps.push_back(IPC_AUD_OFFSET);
+#endif
}
-void CAMLPlayer::GetSubtitleCapabilities(Features* subCaps)
+void CAMLPlayer::GetSubtitleCapabilities(std::vector<int> &subCaps)
{
- subCaps->push_back(IPC_SUBS_EXTERNAL);
- subCaps->push_back(IPC_SUBS_OFFSET);
- subCaps->push_back(IPC_SUBS_SELECT);
- return;
+ subCaps.push_back(IPC_SUBS_EXTERNAL);
+ subCaps.push_back(IPC_SUBS_SELECT);
+ subCaps.push_back(IPC_SUBS_OFFSET);
}
-*/
+
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
@@ -1695,23 +1780,6 @@ void CAMLPlayer::SetAudioPassThrough(int format)
(m_audio_passthrough_dts && format == AFORMAT_DTS));
}
-bool CAMLPlayer::WaitForPausedThumbJobs(int timeout_ms)
-{
- // use m_bStop and Sleep so we can get canceled.
- while (!m_bStop && (timeout_ms > 0))
- {
- if (CJobManager::GetInstance().IsProcessing(CJob::PRIORITY_LOW))
- {
- Sleep(100);
- timeout_ms -= 100;
- }
- else
- return true;
- }
-
- return false;
-}
-
int CAMLPlayer::GetPlayerSerializedState(void)
{
CSingleLock lock(m_aml_state_csection);
@@ -1774,8 +1842,8 @@ bool CAMLPlayer::WaitForStopped(int timeout_ms)
switch(pstatus)
{
default:
- usleep(100 * 1000);
- timeout_ms -= 100;
+ usleep(20 * 1000);
+ timeout_ms -= 20;
break;
case PLAYER_PLAYEND:
case PLAYER_STOPED:
@@ -1800,8 +1868,8 @@ bool CAMLPlayer::WaitForSearchOK(int timeout_ms)
switch(pstatus)
{
default:
- usleep(100 * 1000);
- timeout_ms -= 100;
+ usleep(20 * 1000);
+ timeout_ms -= 20;
break;
case PLAYER_STOPED:
return false;
@@ -1821,30 +1889,31 @@ bool CAMLPlayer::WaitForSearchOK(int timeout_ms)
bool CAMLPlayer::WaitForPlaying(int timeout_ms)
{
- // force the volume off in case we are starting muted
- m_audio_mute = true;
while (!m_bAbortRequest && (timeout_ms > 0))
{
-#if !defined(TARGET_ANDROID)
- // anoying that we have to hammer audio_set_volume
- // but have to catch it before any audio comes out.
- m_dll->audio_set_volume(m_pid, 0.0);
-#endif
+ // anoying that we have to hammer setting audio volume via mute
+ // but we have to catch it before any audio comes out.
+ // we cannot do this for m1 (playback will bork) so trap it out.
+ if (aml_get_cputype() != 1)
+ SetMute(m_audio_mute);
+
player_status pstatus = (player_status)GetPlayerSerializedState();
if (m_log_level > 5)
CLog::Log(LOGDEBUG, "CAMLPlayer::WaitForPlaying: %s", m_dll->player_status2str(pstatus));
switch(pstatus)
{
default:
- usleep(100 * 1000);
- timeout_ms -= 100;
+ usleep(20 * 1000);
+ timeout_ms -= 20;
break;
case PLAYER_ERROR:
case PLAYER_EXIT:
m_bAbortRequest = true;
return false;
break;
case PLAYER_RUNNING:
+ // restore mute/volume settings
+ SetMute(m_audio_mute);
return true;
break;
}
@@ -1863,8 +1932,8 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
switch(pstatus)
{
default:
- usleep(100 * 1000);
- timeout_ms -= 100;
+ usleep(20 * 1000);
+ timeout_ms -= 20;
break;
case PLAYER_ERROR:
case PLAYER_EXIT:
@@ -1875,35 +1944,50 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
ClearStreamInfos();
- media_info_t media_info;
+ media_info_t media_info = {{0}};
+#if defined(TARGET_ANDROID)
+ // media_info_t might be different so check its size.
+ // player_get_media_info will memset to zero the passed
+ // structure so alloc more space and preset to a know value
+ // so we can compare the size we use to the size the lib uses.
+ int msize = sizeof(media_info_t) + 10240;
+ media_info_t *test_media_info = (media_info_t*)calloc(msize, 1);
+ memset(test_media_info, 0xEF, msize);
+
+ int res = m_dll->player_get_media_info(m_pid, test_media_info);
+
+ uint8_t *t1 = (uint8_t*)test_media_info;
+ for (size_t i = msize-1; i >= 0; i--)
+ {
+ if (t1[i] != 0xEF)
+ {
+ if (sizeof(media_info_t) != i+1)
+ {
+ CLog::Log(LOGERROR, "CAMLPlayer::media_info_t(%d) size changed to %d",
+ sizeof(media_info_t), i+1);
+ // size is different, we cannot trust it
+ free(test_media_info);
+ return false;
+ }
+ break;
+ }
+ }
+ media_info = *test_media_info;
+ free(test_media_info);
+#else
int res = m_dll->player_get_media_info(m_pid, &media_info);
+#endif
if (res != PLAYER_SUCCESS)
return false;
if (m_log_level > 5)
- {
media_info_dump(&media_info);
- // m_video_index, m_audio_index, m_subtitle_index might be -1 eventhough
- // total_video_xxx is > 0, not sure why, they should be set to zero or
- // some other sensible value.
- CLog::Log(LOGDEBUG, "CAMLPlayer::WaitForFormatValid: "
- "m_video_index(%d), m_audio_index(%d), m_subtitle_index(%d), m_chapter_count(%d)",
- media_info.stream_info.cur_video_index,
- media_info.stream_info.cur_audio_index,
-#if !defined(TARGET_ANDROID)
- media_info.stream_info.cur_sub_index,
- media_info.stream_info.total_chapter_num);
-#else
- media_info.stream_info.cur_sub_index,
- 0);
-#endif
- }
-
// video info
if (media_info.stream_info.has_video && media_info.stream_info.total_video_num > 0)
{
- for (int i = 0; i < media_info.stream_info.total_video_num; i++)
+ for (int i = 0; i < media_info.stream_info.total_video_num &&
+ media_info.stream_info.total_video_num < MAX_VIDEO_STREAMS; i++)
{
AMLPlayerStreamInfo *info = new AMLPlayerStreamInfo;
info->Clear();
@@ -1940,7 +2024,8 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
// audio info
if (media_info.stream_info.has_audio && media_info.stream_info.total_audio_num > 0)
{
- for (int i = 0; i < media_info.stream_info.total_audio_num; i++)
+ for (int i = 0; i < media_info.stream_info.total_audio_num &&
+ media_info.stream_info.total_audio_num < MAX_AUDIO_STREAMS; i++)
{
AMLPlayerStreamInfo *info = new AMLPlayerStreamInfo;
info->Clear();
@@ -1952,19 +2037,11 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
info->bit_rate = media_info.audio_info[i]->bit_rate;
info->duration = media_info.audio_info[i]->duration;
info->format = media_info.audio_info[i]->aformat;
-#if !defined(TARGET_ANDROID)
+#if defined(HAS_AMLPLAYER_AUDIO_LANG)
if (media_info.audio_info[i]->audio_language[0] != 0)
- {
info->language = std::string(media_info.audio_info[i]->audio_language, 3);
-
- if (info->language.length() == 2)
- {
- CStdString lang;
- g_LangCodeExpander.ConvertToThreeCharCode(lang, info->language);
- info->language = lang;
- }
- }
#endif
+
m_audio_streams.push_back(info);
}
@@ -1979,24 +2056,15 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
// subtitle info
if (media_info.stream_info.has_sub && media_info.stream_info.total_sub_num > 0)
{
- for (int i = 0; i < media_info.stream_info.total_sub_num; i++)
+ for (int i = 0; i < media_info.stream_info.total_sub_num && i < MAX_SUB_STREAMS; i++)
{
AMLPlayerStreamInfo *info = new AMLPlayerStreamInfo;
info->Clear();
info->id = media_info.sub_info[i]->id;
info->type = STREAM_SUBTITLE;
if (media_info.sub_info[i]->sub_language && media_info.sub_info[i]->sub_language[0] != 0)
- {
info->language = std::string(media_info.sub_info[i]->sub_language, 3);
-
- if (info->language.length() == 2)
- {
- CStdString lang;
- g_LangCodeExpander.ConvertToThreeCharCode(lang, info->language);
- info->language = lang;
- }
- }
m_subtitle_streams.push_back(info);
}
m_subtitle_index = media_info.stream_info.cur_sub_index;
@@ -2008,12 +2076,12 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
if (m_subtitle_count && m_subtitle_index != 0)
m_subtitle_index = 0;
-#if !defined(TARGET_ANDROID)
+#if defined(HAS_AMLPLAYER_CHAPTERS)
// chapter info
if (media_info.stream_info.total_chapter_num > 0)
{
m_chapter_count = media_info.stream_info.total_chapter_num;
- for (int i = 0; i < m_chapter_count; i++)
+ for (int i = 0; i < m_chapter_count && m_chapter_count < MAX_CHAPTERS; i++)
{
if (media_info.chapter_info[i] != NULL)
{
@@ -2026,6 +2094,7 @@ bool CAMLPlayer::WaitForFormatValid(int timeout_ms)
}
}
#endif
+
return true;
break;
}
@@ -2127,11 +2196,11 @@ void CAMLPlayer::FindSubtitleFiles()
int CAMLPlayer::AddSubtitleFile(const std::string &filename, const std::string &subfilename)
{
std::string ext = URIUtils::GetExtension(filename);
+ std::string vobsubfile = subfilename;
if(ext == ".idx")
{
/* TODO: we do not handle idx/sub binary subs yet.
- std::string vobsubfile = subfilename;
if (vobsubfile.empty())
vobsubfile = URIUtils::ReplaceExtension(filename, ".sub");
@@ -2303,6 +2372,8 @@ void CAMLPlayer::SetVideoRect(const CRect &SrcRect, const CRect &DestRect)
char video_axis[256] = {0};
sprintf(video_axis, "%d %d %d %d", (int)dst_rect.x1, (int)dst_rect.y1, (int)dst_rect.x2, (int)dst_rect.y2);
aml_set_sysfs_str("/sys/class/video/axis", video_axis);
+ // make sure we are in 'full stretch' so we can stretch
+ aml_set_sysfs_int("/sys/class/video/screen_mode", 1);
/*
CStdString rectangle;
rectangle.Format("%i,%i,%i,%i",
@@ -2321,41 +2392,3 @@ void CAMLPlayer::RenderUpdateCallBack(const void *ctx, const CRect &SrcRect, con
player->SetVideoRect(SrcRect, DestRect);
}
-void CAMLPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
-{
- renderFeatures.push_back(RENDERFEATURE_ZOOM);
- renderFeatures.push_back(RENDERFEATURE_CONTRAST);
- renderFeatures.push_back(RENDERFEATURE_BRIGHTNESS);
- renderFeatures.push_back(RENDERFEATURE_STRETCH);
-}
-
-void CAMLPlayer::GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods)
-{
- deinterlaceMethods.push_back(VS_INTERLACEMETHOD_DEINTERLACE);
-}
-
-void CAMLPlayer::GetDeinterlaceModes(std::vector<int> &deinterlaceModes)
-{
- deinterlaceModes.push_back(VS_DEINTERLACEMODE_AUTO);
-}
-
-void CAMLPlayer::GetScalingMethods(std::vector<int> &scalingMethods)
-{
-}
-
-void CAMLPlayer::GetAudioCapabilities(std::vector<int> &audioCaps)
-{
- audioCaps.push_back(IPC_AUD_SELECT_STREAM);
- audioCaps.push_back(IPC_AUD_SELECT_OUTPUT);
-#if !defined(TARGET_ANDROID)
- audioCaps.push_back(IPC_AUD_OFFSET);
-#endif
-}
-
-void CAMLPlayer::GetSubtitleCapabilities(std::vector<int> &subCaps)
-{
- subCaps.push_back(IPC_SUBS_EXTERNAL);
- subCaps.push_back(IPC_SUBS_SELECT);
- subCaps.push_back(IPC_SUBS_OFFSET);
-}
-
View
20 xbmc/cores/amlplayer/AMLPlayer.h
@@ -43,6 +43,7 @@ class CAMLSubTitleThread : public CThread
CAMLSubTitleThread(DllLibAmplayer* dll);
virtual ~CAMLSubTitleThread();
+ void Flush();
void UpdateSubtitle(CStdString &subtitle, int64_t elapsed_ms);
protected:
virtual void Process(void);
@@ -81,13 +82,15 @@ class CAMLPlayer : public IPlayer, public CThread
virtual void SeekPercentage(float fPercent = 0.0f);
virtual float GetPercentage();
virtual void SetMute(bool bOnOff);
- virtual void SetVolume(float volume);
virtual bool ControlsVolume() {return true;}
+ virtual void SetVolume(float volume);
virtual void SetDynamicRangeCompression(long drc) {}
virtual void GetAudioInfo(CStdString &strAudioInfo);
virtual void GetVideoInfo(CStdString &strVideoInfo);
virtual void GetGeneralInfo(CStdString &strVideoInfo) {};
virtual void Update(bool bPauseDrawing);
+ virtual void GetVideoRect(CRect& SrcRect, CRect& DestRect);
+ virtual void GetVideoAspectRatio(float &fAR);
virtual bool CanRecord() {return false;};
virtual bool IsRecording() {return false;};
virtual bool Record(bool bOnOff) {return false;};
@@ -118,9 +121,9 @@ class CAMLPlayer : public IPlayer, public CThread
virtual int SeekChapter(int iChapter);
virtual float GetActualFPS();
- virtual void SeekTime(__int64 iTime = 0);
- virtual __int64 GetTime();
- virtual __int64 GetTotalTime();
+ virtual void SeekTime(int64_t iTime = 0);
+ virtual int64_t GetTime();
+ virtual int64_t GetTotalTime();
virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
virtual int GetSourceBitrate();
@@ -150,14 +153,6 @@ class CAMLPlayer : public IPlayer, public CThread
virtual bool SetPlayerState(CStdString state) {return false;};
virtual CStdString GetPlayingTitle() {return "";};
-/*
- virtual void GetRenderFeatures(Features* renderFeatures);
- virtual void GetDeinterlaceMethods(Features* deinterlaceMethods);
- virtual void GetDeinterlaceModes(Features* deinterlaceModes);
- virtual void GetScalingMethods(Features* scalingMethods);
- virtual void GetAudioCapabilities(Features* audioCaps);
- virtual void GetSubtitleCapabilities(Features* subCaps);
-*/
virtual void GetRenderFeatures(std::vector<int> &renderFeatures);
virtual void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
@@ -236,7 +231,6 @@ class CAMLPlayer : public IPlayer, public CThread
CDVDPlayerSubtitle *m_dvdPlayerSubtitle;
CDVDOverlayContainer *m_dvdOverlayContainer;
- int m_chapter_index;
int m_chapter_count;
int m_show_mainvideo;
View
138 xbmc/cores/amlplayer/AMLUtils.cpp
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2011-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string>
-
-int aml_set_sysfs_str(const char *path, const char *val)
-{
- int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
- if (fd >= 0)
- {
- write(fd, val, strlen(val));
- close(fd);
- return 0;
- }
- return -1;
-}
-
-int aml_get_sysfs_str(const char *path, char *valstr, const int size)
-{
- int fd = open(path, O_RDONLY);
- if (fd >= 0)
- {
- read(fd, valstr, size - 1);
- valstr[strlen(valstr)] = '\0';
- close(fd);
- return 0;
- }
-
- sprintf(valstr, "%s", "fail");
- return -1;
-}
-
-int aml_set_sysfs_int(const char *path, const int val)
-{
- int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
- if (fd >= 0)
- {
- char bcmd[16];
- sprintf(bcmd, "%d", val);
- write(fd, bcmd, strlen(bcmd));
- close(fd);
- return 0;
- }
- return -1;
-}
-
-int aml_get_sysfs_int(const char *path)
-{
- int val = 0;
- int fd = open(path, O_RDONLY);
- if (fd >= 0)
- {
- char bcmd[16];
- read(fd, bcmd, sizeof(bcmd));
- val = strtol(bcmd, NULL, 16);
- close(fd);
- }
- return val;
-}
-
-bool aml_present()
-{
- static int has_aml = -1;
- if (has_aml == -1)
- {
- if (aml_get_sysfs_int("/sys/class/amhdmitx/amhdmitx0/disp_cap") != -1)
- has_aml = 1;
- else
- has_aml = 0;
- }
- return has_aml;
-}
-
-void aml_cpufreq_limit(bool limit)
-{
- static int audiotrack_cputype = -1;
- if (audiotrack_cputype == -1)
- {
- // defualt to m1 SoC
- audiotrack_cputype = 1;
-
- FILE *cpuinfo_fd = fopen("/proc/cpuinfo", "r");
- if (cpuinfo_fd)
- {
- char buffer[512];
- while (fgets(buffer, sizeof(buffer), cpuinfo_fd))
- {
- std::string stdbuffer(buffer);
- if (stdbuffer.find("MESON-M3") != std::string::npos)
- {
- audiotrack_cputype = 3;
- break;
- }
- }
- fclose(cpuinfo_fd);
- }
- }
- // On M1 SoCs, when playing hw decoded audio, we cannot drop below 600MHz
- // or risk hw audio dropouts. AML code does a 2X scaling based off
- // /sys/class/audiodsp/codec_mips but tests show that this is
- // seems risky so we just clamp to 600Mhz to be safe.
- if (audiotrack_cputype == 3)
- return;
-
- int cpufreq = 300000;
- if (limit)
- cpufreq = 600000;
-
- aml_set_sysfs_int("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", cpufreq);
-}
-
-void aml_set_audio_passthrough(bool passthrough)
-{
- if (aml_present())
- aml_set_sysfs_int("/sys/class/audiodsp/digital_raw", passthrough ? 1:0);
-}
View
31 xbmc/cores/amlplayer/DllLibamplayer.h
@@ -25,6 +25,17 @@
extern "C"
{
+// beware, these will alter the structs
+// in player_type.h.
+#if 1
+ #define HAS_AMLPLAYER_CHAPTERS
+ #define HAS_AMLPLAYER_AUDIO_LANG
+ #define HAS_AMLPLAYER_AUDIO_SETDELAY
+ #define HAS_AMLPLAYER_AUDIO_SETVOLUME
+#else
+ #define HAS_AMLPLAYER_VIDEO_STREAMS10
+#endif
+
#include <player_type.h>
#include <player_error.h>
}
@@ -62,9 +73,13 @@ class DllLibAmplayerInterface
virtual int player_register_update_callback(callback_t *cb,update_state_fun_t up_fn,int interval_s)=0;
virtual char* player_status2str(player_status status)=0;
- virtual int audio_set_volume(int pid,float val)=0;
+#if defined(HAS_AMLPLAYER_AUDIO_SETDELAY)
virtual int audio_set_delay(int pid, int delay)=0;
-
+#endif
+#if defined(HAS_AMLPLAYER_AUDIO_SETVOLUME)
+ virtual int audio_set_volume(int pid,float val)=0;
+#endif
+
virtual int codec_open_sub_read(void)=0;
virtual int codec_close_sub_fd(int sub_fd)=0;
virtual int codec_get_sub_size_fd(int sub_fd)=0;
@@ -103,8 +118,12 @@ class DllLibAmplayer : public DllDynamic, DllLibAmplayerInterface
DEFINE_METHOD3(int, player_register_update_callback, (callback_t *p1, update_state_fun_t p2, int p3))
DEFINE_METHOD1(char*, player_status2str, (player_status p1))
- DEFINE_METHOD2(int, audio_set_volume, (int p1, float p2))
+#if defined(HAS_AMLPLAYER_AUDIO_SETDELAY)
DEFINE_METHOD2(int, audio_set_delay, (int p1, int p2))
+#endif
+#if defined(HAS_AMLPLAYER_AUDIO_SETVOLUME)
+ DEFINE_METHOD2(int, audio_set_volume, (int p1, float p2))
+#endif
DEFINE_METHOD0(int, codec_open_sub_read)
DEFINE_METHOD1(int, codec_close_sub_fd, (int p1))
@@ -140,8 +159,12 @@ class DllLibAmplayer : public DllDynamic, DllLibAmplayerInterface
RESOLVE_METHOD(player_register_update_callback)
RESOLVE_METHOD(player_status2str)
- RESOLVE_METHOD(audio_set_volume)
+#if defined(HAS_AMLPLAYER_AUDIO_SETDELAY)
RESOLVE_METHOD(audio_set_delay)
+#endif
+#if defined(HAS_AMLPLAYER_AUDIO_SETVOLUME)
+ RESOLVE_METHOD(audio_set_volume)
+#endif
RESOLVE_METHOD(codec_open_sub_read)
RESOLVE_METHOD(codec_close_sub_fd)
View
4 xbmc/cores/amlplayer/FileURLProtocol.cpp
@@ -56,6 +56,10 @@ int CFileURLProtocol::Open(AML_URLContext *h, const char *filename, int flags)
{
url = url.Right(url.size() - strlen("xb-"));
}
+ else if (url.Left(strlen("xb-sftp://")).Equals("xb-sftp://"))
+ {
+ url = url.Right(url.size() - strlen("xb-"));
+ }
else if (url.Left(strlen("xb-hdhomerun://")).Equals("xb-hdhomerun://"))
{
url = url.Right(url.size() - strlen("xb-"));
View
4 xbmc/cores/amlplayer/Makefile.in
@@ -3,14 +3,14 @@
INCLUDES += -I$(prefix)/include/amlplayer
SRCS = AMLPlayer.cpp
-SRCS+= AMLUtils.cpp
SRCS+= FileURLProtocol.cpp
LIB = amlplayer.a
+ifneq (@USE_LIBAMCODEC@,1)
@abs_top_srcdir@/system/advancedsettings.xml: $(LIB)
cp -f amlplayer_advancedsettings.xml $@
+endif
include @abs_top_srcdir@/Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
-
View
1 xbmc/cores/amlplayer/amlplayer_advancedsettings.xml
@@ -1,6 +1,5 @@
<advancedsettings>
<video>
<defaultplayer>amlplayer</defaultplayer>
- <defaultdvdplayer>amlplayer</defaultdvdplayer>
</video>
</advancedsettings>
View
15 xbmc/cores/dvdplayer/DVDClock.cpp
@@ -28,8 +28,8 @@
int64_t CDVDClock::m_systemOffset;
int64_t CDVDClock::m_systemFrequency;
CCriticalSection CDVDClock::m_systemsection;
-
bool CDVDClock::m_ismasterclock;
+CDVDClock *CDVDClock::m_playerclock = NULL;;
CDVDClock::CDVDClock()
{
@@ -45,10 +45,15 @@ CDVDClock::CDVDClock()
m_ismasterclock = true;
m_startClock = 0;
+
+ m_playerclock = this;
}
CDVDClock::~CDVDClock()
-{}
+{
+ CSingleLock lock(m_systemsection);
+ m_playerclock = NULL;
+}
// Returns the current absolute clock in units of DVD_TIME_BASE (usually microseconds).
double CDVDClock::GetAbsoluteClock(bool interpolated /*= true*/)
@@ -90,6 +95,12 @@ double CDVDClock::WaitAbsoluteClock(double target)
return (double)systemtarget / freq * DVD_TIME_BASE;
}
+CDVDClock* CDVDClock::GetMasterClock()
+{
+ CSingleLock lock(m_systemsection);
+ return m_playerclock;
+}
+
double CDVDClock::GetClock(bool interpolated /*= true*/)
{
CSharedLock lock(m_critSection);
View