From a3ed7d44e3114f247f575edec2bd69d58e0e5a9b Mon Sep 17 00:00:00 2001 From: Mahesh Kondiparthi Date: Mon, 12 Oct 2015 11:23:03 +0530 Subject: [PATCH] Corrections to State checks of pause [Sync with 2.4]. Corrected improper State check for mx_pause call pause pre-state is restricted to Muxing. Ready is avoided in the state check. Change-Id: I3f14eec9e843efcd5a3906b4e5e269448d8900fc Signed-off-by: Mahesh Kondiparthi --- src/mediamuxer.c | 6 +++--- src/port_gst/mediamuxer_port_gst.c | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mediamuxer.c b/src/mediamuxer.c index 6618f5b..d3a1b4a 100644 --- a/src/mediamuxer.c +++ b/src/mediamuxer.c @@ -249,9 +249,9 @@ int mediamuxer_pause(mediamuxer_h muxer) int ret = MEDIAMUXER_ERROR_NONE; MUXER_INSTANCE_CHECK(muxer); mediamuxer_s *handle = (mediamuxer_s *)(muxer); - ret = mx_pause(handle->mx_handle); - if (handle->muxer_state == MEDIAMUXER_STATE_READY - || handle->muxer_state == MEDIAMUXER_STATE_MUXING) { + + if (handle->muxer_state == MEDIAMUXER_STATE_MUXING) { + ret = mx_pause(handle->mx_handle); if (ret != MEDIAMUXER_ERROR_NONE) { MX_E ("[CoreAPI][%s] MUXER_ERROR_INVALID_OPERATION(0x%08x)", diff --git a/src/port_gst/mediamuxer_port_gst.c b/src/port_gst/mediamuxer_port_gst.c index 0466e42..bfaa39a 100644 --- a/src/port_gst/mediamuxer_port_gst.c +++ b/src/port_gst/mediamuxer_port_gst.c @@ -1122,13 +1122,14 @@ static int gst_muxer_pause(MMHandleType pHandle) int ret = MX_ERROR_NONE; MEDIAMUXER_CHECK_NULL(pHandle); mxgst_handle_t *gst_handle = (mxgst_handle_t *) pHandle; - GstState state; + MX_I("gst_muxer_pause setting pipeline to pause"); gst_element_get_state(gst_handle->pipeline, &state, NULL, GST_CLOCK_TIME_NONE); + if (state == GST_STATE_PLAYING) { - if (gst_element_set_state(gst_handle->pipeline, GST_STATE_PAUSED) == - GST_STATE_CHANGE_FAILURE) { + if (gst_element_set_state(gst_handle->pipeline, GST_STATE_PAUSED) + == GST_STATE_CHANGE_FAILURE) { MX_I("Setting pipeline to pause failed"); ret = MX_ERROR_INVALID_ARGUMENT; } @@ -1152,9 +1153,9 @@ static int gst_muxer_resume(MMHandleType pHandle) MEDIAMUXER_CHECK_NULL(pHandle); mxgst_handle_t *gst_handle = (mxgst_handle_t *) pHandle; - MX_I("gst_muxer_resume setting pipeline to playing"); - if (gst_element_set_state(gst_handle->pipeline, GST_STATE_PLAYING) == - GST_STATE_CHANGE_FAILURE) { + MX_I("gst_muxer_resume setting pipeline back to playing"); + if (gst_element_set_state(gst_handle->pipeline, GST_STATE_PLAYING) + == GST_STATE_CHANGE_FAILURE) { MX_I("Setting pipeline to resume failed"); ret = MX_ERROR_INVALID_ARGUMENT; } -- 2.7.4