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