LCOV - code coverage report
Current view: top level - source - WebAudioClientBackend.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 24 24
Test Date: 2025-06-24 14:11:58 Functions: 100.0 % 13 13

            Line data    Source code
       1              : /*
       2              :  * Copyright (C) 2023 Sky UK
       3              :  *
       4              :  * This library is free software; you can redistribute it and/or
       5              :  * modify it under the terms of the GNU Lesser General Public
       6              :  * License as published by the Free Software Foundation;
       7              :  * version 2.1 of the License.
       8              :  *
       9              :  * This library is distributed in the hope that it will be useful,
      10              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12              :  * Lesser General Public License for more details.
      13              :  *
      14              :  * You should have received a copy of the GNU Lesser General Public
      15              :  * License along with this library; if not, write to the Free Software
      16              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      17              :  */
      18              : #pragma once
      19              : 
      20              : #include "WebAudioClientBackendInterface.h"
      21              : #include <IWebAudioPlayer.h>
      22              : #include <IWebAudioPlayerClient.h>
      23              : #include <gst/gst.h>
      24              : #include <memory>
      25              : 
      26              : namespace firebolt::rialto::client
      27              : {
      28              : class WebAudioClientBackend final : public WebAudioClientBackendInterface
      29              : {
      30              : public:
      31           38 :     WebAudioClientBackend() : m_webAudioPlayerBackend(nullptr) {}
      32           64 :     ~WebAudioClientBackend() final { m_webAudioPlayerBackend.reset(); }
      33              : 
      34           30 :     bool createWebAudioBackend(std::weak_ptr<IWebAudioPlayerClient> client, const std::string &audioMimeType,
      35              :                                const uint32_t priority, std::weak_ptr<const WebAudioConfig> config) override
      36              :     {
      37              :         m_webAudioPlayerBackend =
      38           60 :             firebolt::rialto::IWebAudioPlayerFactory::createFactory()->createWebAudioPlayer(client, audioMimeType,
      39           30 :                                                                                             priority, config);
      40              : 
      41           30 :         if (!m_webAudioPlayerBackend)
      42              :         {
      43            1 :             GST_ERROR("Could not create web audio backend");
      44            1 :             return false;
      45              :         }
      46           29 :         return true;
      47              :     }
      48           20 :     void destroyWebAudioBackend() override { m_webAudioPlayerBackend.reset(); }
      49              : 
      50           10 :     bool play() override { return m_webAudioPlayerBackend->play(); }
      51           10 :     bool pause() override { return m_webAudioPlayerBackend->pause(); }
      52            2 :     bool setEos() override { return m_webAudioPlayerBackend->setEos(); }
      53            2 :     bool getBufferAvailable(uint32_t &availableFrames) override
      54              :     {
      55            2 :         std::shared_ptr<firebolt::rialto::WebAudioShmInfo> webAudioShmInfo;
      56            4 :         return m_webAudioPlayerBackend->getBufferAvailable(availableFrames, webAudioShmInfo);
      57            2 :     }
      58            1 :     bool getBufferDelay(uint32_t &delayFrames) override { return m_webAudioPlayerBackend->getBufferDelay(delayFrames); }
      59            1 :     bool writeBuffer(const uint32_t numberOfFrames, void *data) override
      60              :     {
      61            1 :         return m_webAudioPlayerBackend->writeBuffer(numberOfFrames, data);
      62              :     }
      63           19 :     bool getDeviceInfo(uint32_t &preferredFrames, uint32_t &maximumFrames, bool &supportDeferredPlay) override
      64              :     {
      65           19 :         return m_webAudioPlayerBackend->getDeviceInfo(preferredFrames, maximumFrames, supportDeferredPlay);
      66              :     }
      67            5 :     bool setVolume(double volume) override { return m_webAudioPlayerBackend->setVolume(volume); }
      68            4 :     bool getVolume(double &volume) override { return m_webAudioPlayerBackend->getVolume(volume); }
      69              : 
      70              : private:
      71              :     std::unique_ptr<IWebAudioPlayer> m_webAudioPlayerBackend;
      72              : };
      73              : } // namespace firebolt::rialto::client
        

Generated by: LCOV version 2.0-1