提交 ee7a307a 编写于 作者: D dongwei

偶现阻塞修复

Signed-off-by: Ndongwei <dongwei@kaihong.com>
上级 68e601ea
...@@ -425,7 +425,6 @@ function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done) { ...@@ -425,7 +425,6 @@ function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTime, done) {
console.info('playPauseLoopWithCallBack avPlayer from play to stop') console.info('playPauseLoopWithCallBack avPlayer from play to stop')
avPlayer.release().then(() => { avPlayer.release().then(() => {
console.info('playPauseLoopWithCallBack avPlayer from stop to release') console.info('playPauseLoopWithCallBack avPlayer from stop to release')
offCallback(avPlayer, ['stateChange', 'error']);
done(); done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
...@@ -556,7 +555,6 @@ async function playToCompletedLoop(src, avPlayer, done) { ...@@ -556,7 +555,6 @@ async function playToCompletedLoop(src, avPlayer, done) {
console.info('playToCompletedLoop avPlayer from play to stop') console.info('playToCompletedLoop avPlayer from play to stop')
avPlayer.release().then(() => { avPlayer.release().then(() => {
console.info('playToCompletedLoop avPlayer from stop to release') console.info('playToCompletedLoop avPlayer from stop to release')
offCallback(avPlayer, ['stateChange', 'error']);
done(); done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
...@@ -611,29 +609,30 @@ export async function seekLoop(src, avPlayer, done) { ...@@ -611,29 +609,30 @@ export async function seekLoop(src, avPlayer, done) {
}, (err) => { }, (err) => {
console.error('seekLoop play filed,error message is :' + err.message) console.error('seekLoop play filed,error message is :' + err.message)
}) })
if(avPlayer.state == AV_PLAYER_STATE.PLAYING){ await seekLoopWithCallback(avPlayer)
console.info('seekLoop avPlayer from play to seek') console.info('seekLoop avPlayer from play to seek')
// play seek loop 1000 times // play seek loop 1000 times
for(var loopTime = 0;loopTime < 1000; loopTime++){
avPlayer.seek(loopTime)
console.info(`case seekLoopWithCallback loopTime is ${loopTime}`);
}
}
await avPlayer.stop().then(() => { await avPlayer.stop().then(() => {
console.info('seekLoopWithCallback avPlayer from play to stop') console.info('seekLoopWithCallback avPlayer from play to stop')
offCallback(avPlayer, ['stateChange', 'seekDone']); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.release().then(() => { await avPlayer.release().then(() => {
console.info('seekLoopWithCallback avPlayer from stop to release') console.info('seekLoopWithCallback avPlayer from stop to release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
done(); done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
} }
async function seekLoopWithCallback(avPlayer) { async function seekLoopWithCallback(avPlayer) {
avPlayer.on('seekDone', async (seekDoneTime) => { for (let loopTime = 0; loopTime < 5000; loopTime += 5) {
console.info(`case seekDone called seekDoneTime is ${seekDoneTime}`); await new Promise(resolve => {
}); avPlayer.on('seekDone', seekDoneTime => {
console.info(`case seekDone called seekDoneTime is ${seekDoneTime}`);
resolve();
});
avPlayer.seek(loopTime);
console.info(`case seekLoopWithCallback loopTime is ${loopTime}`);
});
}
} }
export async function seekLoopWithoutCallback(src, avPlayer, done) { export async function seekLoopWithoutCallback(src, avPlayer, done) {
...@@ -767,15 +766,12 @@ export async function createToReleaseLoop(src, avPlayer, done) { ...@@ -767,15 +766,12 @@ export async function createToReleaseLoop(src, avPlayer, done) {
await avPlayer.release().then(() => { await avPlayer.release().then(() => {
console.info('createToReleaseLoop avPlayer from stop to release') console.info('createToReleaseLoop avPlayer from stop to release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
if(i==999){
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
console.info(`case createToReleaseLoop loop is ${i}`); console.info(`case createToReleaseLoop loop is ${i}`);
} }
await avPlayer.release().then(() => {
console.info('createToReleaseLoop avPlayer from stop to release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
} }
let createLoopTime = 0; let createLoopTime = 0;
...@@ -785,7 +781,7 @@ export async function createTimeWithCallback(src, avPlayer, done) { ...@@ -785,7 +781,7 @@ export async function createTimeWithCallback(src, avPlayer, done) {
avPlayer = await idle(src, avPlayer) avPlayer = await idle(src, avPlayer)
createStart = Date.now(); createStart = Date.now();
console.info(`createTimeWithCallback createStart time is : ${createStart}`) console.info(`createTimeWithCallback createStart time is : ${createStart}`)
createTimeWithCallback(src, avPlayer, done) createTimeCallback(src, avPlayer, done)
} }
function createTimeCallback(src, avPlayer, done){ function createTimeCallback(src, avPlayer, done){
...@@ -1778,7 +1774,6 @@ function setSpeedTimeCallback(avPlayer, done) { ...@@ -1778,7 +1774,6 @@ function setSpeedTimeCallback(avPlayer, done) {
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
if(loopTime == 10){ if(loopTime == 10){
avPlayer.release().then(() => { avPlayer.release().then(() => {
offCallback(avPlayer, ['stateChange', 'error']);
console.info('setSpeedTimeCallback avPlayer is release') console.info('setSpeedTimeCallback avPlayer is release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
let avg = totalTime/10; let avg = totalTime/10;
...@@ -1889,7 +1884,6 @@ function setBitrateTimeCallback(avPlayer, done) { ...@@ -1889,7 +1884,6 @@ function setBitrateTimeCallback(avPlayer, done) {
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
if(loopTime == 10){ if(loopTime == 10){
avPlayer.release().then(() => { avPlayer.release().then(() => {
offCallback(avPlayer, ['stateChange', 'error']);
console.info('setBitrateTimeCallback avPlayer is release') console.info('setBitrateTimeCallback avPlayer is release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
let avg = totalTime/10; let avg = totalTime/10;
...@@ -2001,7 +1995,6 @@ function setVolumeTimeCallback(avPlayer, done) { ...@@ -2001,7 +1995,6 @@ function setVolumeTimeCallback(avPlayer, done) {
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
if(loopTime == 10){ if(loopTime == 10){
avPlayer.release().then(() => { avPlayer.release().then(() => {
offCallback(avPlayer, ['stateChange', 'error']);
console.info('setVolumeTimeCallback avPlayer is release') console.info('setVolumeTimeCallback avPlayer is release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
let avg = totalTime/10; let avg = totalTime/10;
...@@ -2058,7 +2051,6 @@ export async function firstFrameTime(src, avPlayer, done) { ...@@ -2058,7 +2051,6 @@ export async function firstFrameTime(src, avPlayer, done) {
console.info("firstFrameTime execution time is :" + execution) console.info("firstFrameTime execution time is :" + execution)
sleep(100) sleep(100)
avPlayer.release().then(() => { avPlayer.release().then(() => {
offCallback(avPlayer, ['stateChange','startRenderFrame']);
console.info('firstFrameTime avPlayer is release') console.info('firstFrameTime avPlayer is release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
avPlayer = null; avPlayer = null;
...@@ -2122,6 +2114,13 @@ function setAVPlayerPlay(src, avPlayer, done) { ...@@ -2122,6 +2114,13 @@ function setAVPlayerPlay(src, avPlayer, done) {
case AV_PLAYER_STATE.PLAYING: case AV_PLAYER_STATE.PLAYING:
console.info('setAVPlayerPlay play state is PLAYING') console.info('setAVPlayerPlay play state is PLAYING')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING); expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
if(avPlayer.duration > 3000){
mediaTestBase.msleepAsync(3000);
avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC)
}else{
mediaTestBase.msleepAsync(500);
avPlayer.seek(avPlayer.duration, media.SeekMode.SEEK_NEXT_SYNC)
}
break; break;
case AV_PLAYER_STATE.COMPLETED: case AV_PLAYER_STATE.COMPLETED:
expect(avPlayer.currentTime).assertEqual(avPlayer.duration); expect(avPlayer.currentTime).assertEqual(avPlayer.duration);
...@@ -2131,7 +2130,6 @@ function setAVPlayerPlay(src, avPlayer, done) { ...@@ -2131,7 +2130,6 @@ function setAVPlayerPlay(src, avPlayer, done) {
break; break;
case AV_PLAYER_STATE.RELEASED: case AV_PLAYER_STATE.RELEASED:
expect(avPlayer.state).assertEqual('released'); expect(avPlayer.state).assertEqual('released');
offCallback(avPlayer, ['stateChange', 'error']);
avPlayer = null; avPlayer = null;
done(); done();
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册