Java 带AudioFlinger(57):写入被阻止1068毫秒,1次延迟写入,线程0x40d98ec0

Java 带AudioFlinger(57):写入被阻止1068毫秒,1次延迟写入,线程0x40d98ec0,java,android,c++,media-player,android-mediaplayer,Java,Android,C++,Media Player,Android Mediaplayer,我尝试调用mediaplayer.cpp的API来播放mp4文件。 但没有画面,有时会断断续续地发出声音 #include <sys/stat.h> #include <fcntl.h> #include "PlayerListener.h" #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> using namespace

我尝试调用mediaplayer.cpp的API来播放mp4文件。 但没有画面,有时会断断续续地发出声音

 #include <sys/stat.h>
    #include <fcntl.h>
    #include "PlayerListener.h"
    #include <binder/IPCThreadState.h>
    #include <binder/ProcessState.h>
    using namespace std;
    using namespace android;

    char flag = 0;
    CedarMediaPlayer mp;
    int main(int argc, char ** argv)
    {


        String8 filepath(argv[1]);

        sp<ProcessState> proc(ProcessState::self());
        ProcessState::self()->startThreadPool();
        printf("demo start\n");


        PlayerListener mPlayerListener;
        printf("new a MediaPlayer done\n");


        mp.setOnPreparedListener(&mPlayerListener);
        mp.setOnCompletionListener(&mPlayerListener);
        mp.setOnErrorListener(&mPlayerListener);
        mp.setOnVideoSizeChangedListener(&mPlayerListener);
        mp.setOnInfoListener(&mPlayerListener);
        mp.setOnSeekCompleteListener(&mPlayerListener); 

        mp.setDataSource(filepath);
        mp.setLooping(0);
        mp.setAudioStreamType(AUDIO_STREAM_MUSIC);
        mp.setDisplay(0);
        mp.setVolume(0.5f, 0.9f);
        printf("set source mp4 done \n");
        mp.prepareAsync();

        printf("wait huanchong\n\n");

        if(flag == 1)
        {
                printf("i get 1 start \n");
                mp.start();
        }
    //  mp.release();
        printf("play start\n");
        while(1);
        return 0;
}
以及logcat:

W/AudioFlinger(   58): Thread AudioOut_2 cannot connect to the power manager service

D/mydemo  (  117): (f:PlayerListener, l:33) PlayerListener::PlayerListener!

D/mydemo  (  117): 

D/CedarXPlayer(   58): =============================================

D/CedarXPlayer(   58): CDX_PLATFORM: A23-JB42

D/CedarXPlayer(   58): CDX_SVN_REPOSITORY: xxxx

D/CedarXPlayer(   58): CDX_SVN_VERSION: xxxx

D/CedarXPlayer(   58): CDX_SVN_COMMITTER: 93eddbd6e60f302b9fcf428e2cdee0eb2dd5925c

D/CedarXPlayer(   58): CDX_SVN_DATE:   Mon Aug 24 17:29:52 2015 +0800

D/CedarXPlayer(   58): CDX_RELEASE_AUTHOR: gushiming

D/CedarXPlayer(   58): =============================================

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x0], ret[0x0]

V/aw_demux(   58): DemuxSetDataSource

D/cedarx_demux(   58): cedarx_demux_create: 0x0

D/aw_demux(   58): (f:aw_demux_open, l:848) ==== aw_demux_open url:fd://22?offset=0&length=7182674====

D/awplayer(   58): <CdxParserPrepare:575>: source uri 'fd://22?offset=0&length=7182674'

D/awplayer(   58): <__FileStreamCreate:500>: local file 'fd://22?offset=0&length=7182674'

D/awplayer(   58): <__FileStreamConnect:427>: (23/0/7182674) path:'file:///mnt/extsd/a.aac'

D/awplayer(   58): <__FileStreamConnect:453>: :16:[ff f1 50 80 3e 7f fc de 02 00 4c 61 76 63 35 37]

D/awplayer(   58): <__FileStreamGetMetaData:344>: redriect url 'file:///mnt/extsd/a.aac'

W/awplayer(   58): <__AacParserProbe:1615>: aac probe ok.

D/awplayer(   58): <CdxParserCreate:534>: Good, it's 'aac'

D/awplayer(   58): <CdxParserCreate:537>: parser type(22)

W/awplayer(   58): <__AacParserControl:1297>: not implement...(265)

W/awplayer(   58): <AacInit:1227>: AAC ulDuration:289386

D/aw_demux(   58): aw_demux_open: aw_dmx->pParser(0x411f17a0), parserType[22], is it forbiden:)?

D/aw_demux(   58): <PrintMediaInfo:363>: *********PrintMediaInfo begin*********

D/aw_demux(   58): <PrintMediaInfo:377>: fileSize = 7182674, bSeekable = 1, duration = 289386, audioNum = 1, videoNum = 0, subtitleNum = 0 

D/aw_demux(   58): <PrintMediaInfo:413>: ***Audio[0]*** eCodecFormat = 0xf, eSubCodecFormat = 0x0, nChannelNum = 2, nBitsPerSample = 16, nSampleRate = 44100 

D/aw_demux(   58): <PrintMediaInfo:429>: *********PrintMediaInfo end*********

D/aw_demux(   58): <aw_demux_open:948>: aw_demux_open success.

W/Demux_Component(   58): (f:CreateDemuxPorts, l:870) no video?[0][0]

W/Demux_Component(   58): (f:CreateDemuxPorts, l:906) no subtitle?[0][0]

D/Demux_Component(   58): (f:DemuxGetParameter, l:365) OMX_IndexVendor GetMediaType, default normal tmp

D/CedarXPlayer(   58): (f:setNativeWindow_l, l:1013), set layerId[0]

W/CedarXPlayer(   58): (f:prepareAsync, l:1457) property key[media.cedarx.chipver] get value[3], len[1] 

D/CedarXPlayer(   58): play vps[0] before CDX CMD_PREPARE_ASYNC!

D/CDX_Player(   58): same vpsspeed[0]

D/CDX_Player(   58): hnd_demuxer 0x4119ec68

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x1], ret[0x0]

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x3], ret[0x0]

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x4], ret[0x0]

D/CDX_Player(   58): components info:[url ], [demux 0x4119ec68], [vd 0x0], [vr 0x0], [ad 0x4119e758], [ar 0x41207d70], [sd 0x0], [sr 0x0]

W/CedarXPlayer(   58): unkown video size after prepared

D/mydemo  (  117): (f:onPrepared, l:38) receive onPrepared message!  flag = 1

D/CedarXPlayer(   58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=0!

D/awplayer(   58): <DecodeAudioStream:909>: ==============================pAudioDecoder->pBsInFor->bitrate:171921

D/CedarXPlayer(   58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=1!

D/AudioRender_Component(   58): >>>>>audio render init sample_rate:44100 channels:2

D/AudioRender_Component(   58): (f:AudioRender_ComponentThread, l:1199) audio set config start time to [0]us

D/Clock_Component(   58): (f:ClockSetConfig, l:549) notifyStartToRun, Mediatimebase=[0]ms walltimebase=[20]ms

V/codec_audio_plan_v3(   58): in normal mode, speaker on,****LINE:64,FUNC:set_normal_path, speaker_on=2

D/CedarXPlayer(   58): (f:play_l, l:855) cdx play alread!

W/CDX_Player(   58): only one audio track!
W/AudioFlinger(58):线程AudioOut_2无法连接到电源管理器服务
D/mydemo(117):(f:PlayerListener,l:33)PlayerListener::PlayerListener!
D/mydemo(117):
D/X层(58):=============================================
D/CedarXPlayer(58):CDX_平台:A23-JB42
D/CedarXPlayer(58):CDX\U SVN\U存储库:xxxx
D/CedarXPlayer(58):CDX\U SVN\U版本:xxxx
D/CedarXPlayer(58):CDX提交人:93EDDB6E60F302B9FCF428E2CDEE0EB2DD5925C
D/CedarXPlayer(58):CDX\u SVN\u日期:2015年8月24日星期一17:29:52+0800
D/CedarXPlayer(58):CDX发行版作者:顾世明
D/X层(58):=============================================
D/CDX_组件_公共(58):(f:CDX_CreateComponent,l:57)创建组件类型[0x0],ret[0x0]
V/aw_demux(58):DemuxSetDataSource
D/cedarx_demux(58):cedarx_demux_创建:0x0
D/aw_demux(58):(f:aw_demux_open,l:848)===aw_demux_open url:fd://22?offset=0&length=7182674====
D/awplayer(58)::源uri'fd://22?offset=0&length=7182674'
D/awplayer(58)::本地文件'fd://22?offset=0&length=7182674'
D/awplayer(58):(23/0/7182674)路径:'file:///mnt/extsd/a.aac'
D/awplayer(58)::16:[ff f1 50 80 3e 7f fc de 02 00 4c 61 76 63 35 37]
D/awplayer(58)::redriect url'file:///mnt/extsd/a.aac'
带awplayer(58)::aac探头正常。
D/awplayer(58)::很好,是“aac”
D/awplayer(58)::解析器类型(22)
W/awplayer(58)::未执行…(265)
W/awplayer(58)::AAC持续时间:289386
D/aw_demux(58):aw_demux_open:aw_dmx->pParser(0x411f17a0),解析器类型[22],是否禁止:)?
D/AWU demux(58):*********打印媒体信息开始*********
D/aw_demux(58)::文件大小=7182674,b可查看=1,持续时间=289386,audioNum=1,videoNum=0,subtitnum=0
数据交换(58):***音频[0]***eCodecFormat=0xf,ESUBCODEFORMAT=0x0,nChannelNum=2,nBitsPerSample=16,nSampleRate=44100
D/AWU demux(58):*********打印媒体信息结束*********
D/aw_demux(58):aw_demux_公开赛成功。
W/Demux_组件(58):(f:CreateDemuxPorts,l:870)没有视频?[0][0]
W/Demux_组件(58):(f:CreateDemuxPorts,l:906)无字幕?[0][0]
D/Demux_组件(58):(f:DemuxGetParameter,l:365)OMX_索引供应商GetMediaType,默认正常tmp
D/CedarXPlayer(58):(f:setNativeWindow,l:1013),SetLayerid[0]
W/CedarXPlayer(58):(f:prepareAsync,l:1457)属性键[media.cedarx.chipver]获取值[3],len[1]
D/CedarXPlayer(58):在CDX CMD\u PREPARE\u ASYNC之前播放vps[0]!
D/CDX_播放器(58):相同的VPS速度[0]
D/CDX_播放器(58):hnd_解复用器0x4119ec68
D/CDX_组件_公共(58):(f:CDX_CreateComponent,l:57)创建组件类型[0x1],ret[0x0]
D/CDX_组件_公共(58):(f:CDX_CreateComponent,l:57)创建组件类型[0x3],ret[0x0]
D/CDX_组件_公共(58):(f:CDX_CreateComponent,l:57)创建组件类型[0x4],ret[0x0]
D/CDX_播放器(58):组件信息:[url],[demux 0x4119ec68],[vd 0x0],[vr 0x0],[ad 0x4119e758],[ar 0x41207d70],[sd 0x0],[sr 0x0]
W/CedarXPlayer(58):准备后的未知视频大小
D/mydemo(117):(f:onPrepared,l:38)接收onPrepared消息!标志=1
D/CedarXPlayer(58):(f:play_l,l:860)cdx_state=0x2,睡眠10毫秒等待cdx播放,等待时间=0!
D/awplayer(58):=================================pAudioDecoder->pBsInFor->比特率:171921
D/CedarXPlayer(58):(f:play_l,l:860)cdx_state=0x2,睡眠10毫秒等待cdx播放,等待时间=1!
D/AudioRender_组件(58):>>>>>>音频渲染初始采样率:44100个通道:2个
D/AudioRender_组件(58):(f:AudioRender_组件线程,l:1199)音频集配置开始时间为[0]us
D/Clock_组件(58):(f:ClockSetConfig,l:549)NotifyStartRun,Mediatimebase=[0]毫秒walltimebase=[20]毫秒
V/codec\u audio\u plan\u v3(58):在正常模式下,扬声器打开,****行:64,FUNC:set\u normal\u path,扬声器打开=2
D/CedarXPlayer(58):(f:play_l,l:855)cdx play alread!
带CDX_播放器(58):只有一个音轨!
所以我猜是MP4视频输出内存跨境发生的

./3mydemo1 /mnt/extsd/a.aac 
W/AudioFlinger(   58): Thread AudioOut_2 cannot connect to the power manager service

D/mydemo  (  117): (f:PlayerListener, l:33) PlayerListener::PlayerListener!

D/mydemo  (  117): 

D/CedarXPlayer(   58): =============================================

D/CedarXPlayer(   58): CDX_PLATFORM: A23-JB42

D/CedarXPlayer(   58): CDX_SVN_REPOSITORY: xxxx

D/CedarXPlayer(   58): CDX_SVN_VERSION: xxxx

D/CedarXPlayer(   58): CDX_SVN_COMMITTER: 93eddbd6e60f302b9fcf428e2cdee0eb2dd5925c

D/CedarXPlayer(   58): CDX_SVN_DATE:   Mon Aug 24 17:29:52 2015 +0800

D/CedarXPlayer(   58): CDX_RELEASE_AUTHOR: gushiming

D/CedarXPlayer(   58): =============================================

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x0], ret[0x0]

V/aw_demux(   58): DemuxSetDataSource

D/cedarx_demux(   58): cedarx_demux_create: 0x0

D/aw_demux(   58): (f:aw_demux_open, l:848) ==== aw_demux_open url:fd://22?offset=0&length=7182674====

D/awplayer(   58): <CdxParserPrepare:575>: source uri 'fd://22?offset=0&length=7182674'

D/awplayer(   58): <__FileStreamCreate:500>: local file 'fd://22?offset=0&length=7182674'

D/awplayer(   58): <__FileStreamConnect:427>: (23/0/7182674) path:'file:///mnt/extsd/a.aac'

D/awplayer(   58): <__FileStreamConnect:453>: :16:[ff f1 50 80 3e 7f fc de 02 00 4c 61 76 63 35 37]

D/awplayer(   58): <__FileStreamGetMetaData:344>: redriect url 'file:///mnt/extsd/a.aac'

W/awplayer(   58): <__AacParserProbe:1615>: aac probe ok.

D/awplayer(   58): <CdxParserCreate:534>: Good, it's 'aac'

D/awplayer(   58): <CdxParserCreate:537>: parser type(22)

W/awplayer(   58): <__AacParserControl:1297>: not implement...(265)

W/awplayer(   58): <AacInit:1227>: AAC ulDuration:289386

D/aw_demux(   58): aw_demux_open: aw_dmx->pParser(0x411f17a0), parserType[22], is it forbiden:)?

D/aw_demux(   58): <PrintMediaInfo:363>: *********PrintMediaInfo begin*********

D/aw_demux(   58): <PrintMediaInfo:377>: fileSize = 7182674, bSeekable = 1, duration = 289386, audioNum = 1, videoNum = 0, subtitleNum = 0 

D/aw_demux(   58): <PrintMediaInfo:413>: ***Audio[0]*** eCodecFormat = 0xf, eSubCodecFormat = 0x0, nChannelNum = 2, nBitsPerSample = 16, nSampleRate = 44100 

D/aw_demux(   58): <PrintMediaInfo:429>: *********PrintMediaInfo end*********

D/aw_demux(   58): <aw_demux_open:948>: aw_demux_open success.

W/Demux_Component(   58): (f:CreateDemuxPorts, l:870) no video?[0][0]

W/Demux_Component(   58): (f:CreateDemuxPorts, l:906) no subtitle?[0][0]

D/Demux_Component(   58): (f:DemuxGetParameter, l:365) OMX_IndexVendor GetMediaType, default normal tmp

D/CedarXPlayer(   58): (f:setNativeWindow_l, l:1013), set layerId[0]

W/CedarXPlayer(   58): (f:prepareAsync, l:1457) property key[media.cedarx.chipver] get value[3], len[1] 

D/CedarXPlayer(   58): play vps[0] before CDX CMD_PREPARE_ASYNC!

D/CDX_Player(   58): same vpsspeed[0]

D/CDX_Player(   58): hnd_demuxer 0x4119ec68

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x1], ret[0x0]

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x3], ret[0x0]

D/CDX_Component_Common(   58): (f:CDX_CreateComponent, l:57) create component type[0x4], ret[0x0]

D/CDX_Player(   58): components info:[url ], [demux 0x4119ec68], [vd 0x0], [vr 0x0], [ad 0x4119e758], [ar 0x41207d70], [sd 0x0], [sr 0x0]

W/CedarXPlayer(   58): unkown video size after prepared

D/mydemo  (  117): (f:onPrepared, l:38) receive onPrepared message!  flag = 1

D/CedarXPlayer(   58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=0!

D/awplayer(   58): <DecodeAudioStream:909>: ==============================pAudioDecoder->pBsInFor->bitrate:171921

D/CedarXPlayer(   58): (f:play_l, l:860) cdx_state=0x2, sleep 10ms to wait cdx to play, wait_time=1!

D/AudioRender_Component(   58): >>>>>audio render init sample_rate:44100 channels:2

D/AudioRender_Component(   58): (f:AudioRender_ComponentThread, l:1199) audio set config start time to [0]us

D/Clock_Component(   58): (f:ClockSetConfig, l:549) notifyStartToRun, Mediatimebase=[0]ms walltimebase=[20]ms

V/codec_audio_plan_v3(   58): in normal mode, speaker on,****LINE:64,FUNC:set_normal_path, speaker_on=2

D/CedarXPlayer(   58): (f:play_l, l:855) cdx play alread!

W/CDX_Player(   58): only one audio track!