LCOV - code coverage report
Current view: top level - media/client/main/source - AttachedSources.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.2 % 26 25
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 5 5

            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 2023 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 "AttachedSources.h"
      21              : 
      22              : namespace firebolt::rialto::client
      23              : {
      24           38 : void AttachedSources::add(std::uint32_t id, const MediaSourceType &mediaSourceType)
      25              : {
      26           38 :     std::unique_lock<std::mutex> lock{m_mutex};
      27           38 :     m_attachedSources.emplace(id, Source{mediaSourceType});
      28              : }
      29              : 
      30            5 : void AttachedSources::remove(std::uint32_t id)
      31              : {
      32            5 :     std::unique_lock<std::mutex> lock{m_mutex};
      33            5 :     m_attachedSources.erase(id);
      34              : }
      35              : 
      36           49 : MediaSourceType AttachedSources::getType(std::uint32_t id) const
      37              : {
      38           49 :     std::unique_lock<std::mutex> lock{m_mutex};
      39           49 :     auto iter = m_attachedSources.find(id);
      40           49 :     if (m_attachedSources.end() == iter)
      41              :     {
      42            2 :         return MediaSourceType::UNKNOWN;
      43              :     }
      44           47 :     return iter->second.type;
      45           49 : }
      46              : 
      47           50 : bool AttachedSources::isFlushing(std::uint32_t id) const
      48              : {
      49           50 :     std::unique_lock<std::mutex> lock{m_mutex};
      50           50 :     auto iter = m_attachedSources.find(id);
      51           50 :     if (m_attachedSources.end() == iter)
      52              :     {
      53            0 :         return false;
      54              :     }
      55           50 :     return iter->second.isFlushing;
      56              : }
      57              : 
      58           10 : void AttachedSources::setFlushing(std::uint32_t id, bool flushing)
      59              : {
      60           10 :     std::unique_lock<std::mutex> lock{m_mutex};
      61           10 :     auto iter = m_attachedSources.find(id);
      62           10 :     if (m_attachedSources.end() == iter)
      63              :     {
      64            2 :         return;
      65              :     }
      66            8 :     iter->second.isFlushing = flushing;
      67           10 : }
      68              : } // namespace firebolt::rialto::client
        

Generated by: LCOV version 2.0-1