LCOV - code coverage report
Current view: top level - media/server/gstplayer/source - FlushOnPrerollController.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 34 34
Test Date: 2026-02-18 13:48:45 Functions: 100.0 % 7 7

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2025 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #include "FlushOnPrerollController.h"
      21              : #include "RialtoServerLogging.h"
      22              : #include "TypeConverters.h"
      23              : #include <gst/gst.h>
      24              : 
      25              : namespace firebolt::rialto::server
      26              : {
      27           12 : void FlushOnPrerollController::waitIfRequired(const MediaSourceType &type)
      28              : {
      29           12 :     std::unique_lock lock{m_mutex};
      30           12 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Waiting if required for %s source entry",
      31              :                             common::convertMediaSourceType(type));
      32           12 :     m_conditionVariable.wait(lock, [this, &type]()
      33              :                              // coverity[MISSING_LOCK:FALSE]
      34           12 :                              { return !m_isPrerolled || m_flushingSources.find(type) == m_flushingSources.end(); });
      35           12 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Waiting if required for %s source exit",
      36              :                             common::convertMediaSourceType(type));
      37              : }
      38              : 
      39           11 : void FlushOnPrerollController::setFlushing(const MediaSourceType &type)
      40              : {
      41           11 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Set flushing for: %s", common::convertMediaSourceType(type));
      42           11 :     std::unique_lock lock{m_mutex};
      43           11 :     m_flushingSources.insert(type);
      44              : }
      45              : 
      46            1 : void FlushOnPrerollController::setPrerolling()
      47              : {
      48            1 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Set prerolling");
      49            1 :     std::unique_lock lock{m_mutex};
      50            1 :     m_isPrerolled = false;
      51            1 :     m_conditionVariable.notify_all();
      52              : }
      53              : 
      54            6 : void FlushOnPrerollController::stateReached(const GstState &newPipelineState)
      55              : {
      56            6 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: State reached %s", gst_element_state_get_name(newPipelineState));
      57            6 :     std::unique_lock lock{m_mutex};
      58            6 :     m_isPrerolled = true;
      59            6 :     if (m_targetState.has_value() && newPipelineState == m_targetState.value())
      60              :     {
      61            2 :         RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Clear state after state reached %s",
      62              :                                 gst_element_state_get_name(newPipelineState));
      63            2 :         m_flushingSources.clear();
      64              :     }
      65            6 :     m_conditionVariable.notify_all();
      66              : }
      67              : 
      68           11 : void FlushOnPrerollController::setTargetState(const GstState &state)
      69              : {
      70           11 :     std::unique_lock lock{m_mutex};
      71           11 :     m_targetState = state;
      72           11 :     RIALTO_SERVER_LOG_DEBUG("FlushOnPrerollController: Set target state %s", gst_element_state_get_name(state));
      73              : }
      74              : 
      75            1 : void FlushOnPrerollController::reset()
      76              : {
      77            1 :     RIALTO_SERVER_LOG_DEBUG("Reset FlushOnPrerollController");
      78            1 :     std::unique_lock lock{m_mutex};
      79            1 :     m_isPrerolled = false;
      80            1 :     m_flushingSources.clear();
      81            1 :     m_targetState = std::nullopt;
      82            1 :     m_conditionVariable.notify_all();
      83              : }
      84              : } // namespace firebolt::rialto::server
        

Generated by: LCOV version 2.0-1