調整releaseSurface的呼叫時機
This commit is contained in:
parent
2897cdca0d
commit
d77fc98280
@ -114,6 +114,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
binding.viewPager.setCurrentItem(0, false)
|
binding.viewPager.setCurrentItem(0, false)
|
||||||
for (i in 0 until splitVideoViewAdapter.itemCount) {
|
for (i in 0 until splitVideoViewAdapter.itemCount) {
|
||||||
splitVideoViewAdapter.pause(i)
|
splitVideoViewAdapter.pause(i)
|
||||||
|
splitVideoViewAdapter.destroy(i)
|
||||||
}
|
}
|
||||||
//delay(oldSplitMode * Constants.CONF_DELAY_BASE_MILLIS)
|
//delay(oldSplitMode * Constants.CONF_DELAY_BASE_MILLIS)
|
||||||
delay((oldSplitMode * 100) + Constants.CONF_DELAY_BASE_MILLIS)
|
delay((oldSplitMode * 100) + Constants.CONF_DELAY_BASE_MILLIS)
|
||||||
|
|||||||
@ -83,10 +83,10 @@ class SplitViewFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
|
||||||
//destroyAll()
|
//destroyAll()
|
||||||
stopAll()
|
stopAll()
|
||||||
Log.d("${TAG}_$mPageNum", "onDestroy()")
|
Log.d("${TAG}_$mPageNum", "onDestroy()")
|
||||||
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
@ -214,8 +214,8 @@ class SplitViewFragment : Fragment() {
|
|||||||
fun destroyAll() /*= MainScope().launch(Dispatchers.Main)*/ {
|
fun destroyAll() /*= MainScope().launch(Dispatchers.Main)*/ {
|
||||||
if (videoViews.isEmpty()) return
|
if (videoViews.isEmpty()) return
|
||||||
for (index in data.indices) {
|
for (index in data.indices) {
|
||||||
videoViews[index].destroy()
|
//videoViews[index].destroy()
|
||||||
//delay(100)
|
videoViews[index].destroySurface()
|
||||||
}
|
}
|
||||||
}//.start()
|
}//.start()
|
||||||
|
|
||||||
|
|||||||
@ -105,8 +105,9 @@ class VideoView : ConstraintLayout, GstCallback {
|
|||||||
|
|
||||||
fun play() {
|
fun play() {
|
||||||
if (data == null) return
|
if (data == null) return
|
||||||
videoView.postInvalidate()
|
if (this::gstLibrary.isInitialized) {
|
||||||
gstLibrary.play()
|
gstLibrary.play()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause() {
|
||||||
@ -117,6 +118,12 @@ class VideoView : ConstraintLayout, GstCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun destroySurface() {
|
||||||
|
if (this::gstLibrary.isInitialized) {
|
||||||
|
gstLibrary.releaseSurface()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy() {
|
||||||
if (this::gstLibrary.isInitialized) {
|
if (this::gstLibrary.isInitialized) {
|
||||||
gstLibrary.close()
|
gstLibrary.close()
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class GstLibrary(context: Context) : Closeable, SurfaceHolder.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause() {
|
||||||
if (!isInit) return
|
//if (!isInit) return
|
||||||
nativePause()
|
nativePause()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class GstLibrary(context: Context) : Closeable, SurfaceHolder.Callback {
|
|||||||
// Called from native code. Native code calls this once it has created its pipeline and
|
// Called from native code. Native code calls this once it has created its pipeline and
|
||||||
// the main loop is running, so it is ready to accept commands.
|
// the main loop is running, so it is ready to accept commands.
|
||||||
private fun onGStreamerInitialized() {
|
private fun onGStreamerInitialized() {
|
||||||
Log.i("$TAG+$tag", "GStreamer initialized:")
|
Log.i("$TAG+$tag", "GStreamer Initialization complete")
|
||||||
if (gstCallback != null) {
|
if (gstCallback != null) {
|
||||||
gstCallback!!.onStatus(GstStatus.READY)
|
gstCallback!!.onStatus(GstStatus.READY)
|
||||||
}
|
}
|
||||||
@ -127,8 +127,6 @@ class GstLibrary(context: Context) : Closeable, SurfaceHolder.Callback {
|
|||||||
|
|
||||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||||
Log.d("$TAG+$tag", "Surface created: " + holder.surface)
|
Log.d("$TAG+$tag", "Surface created: " + holder.surface)
|
||||||
Log.i("$TAG+$tag", "GStreamer surfaceCreated")
|
|
||||||
isInit = true
|
|
||||||
nativeSurfaceInit(holder.surface)
|
nativeSurfaceInit(holder.surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +137,9 @@ class GstLibrary(context: Context) : Closeable, SurfaceHolder.Callback {
|
|||||||
|
|
||||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||||
Log.d("$TAG+$tag", "Surface destroyed")
|
Log.d("$TAG+$tag", "Surface destroyed")
|
||||||
pause()
|
|
||||||
releaseSurface()
|
|
||||||
isInit = false
|
isInit = false
|
||||||
|
//pause()
|
||||||
|
//releaseSurface()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user