LCOV - code coverage report
Current view: directory - dom/ipc - AudioChild.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 40 0 0.0 %
Date: 2012-06-02 Functions: 13 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set sw=2 ts=2 et tw=80 : */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Audio IPC
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  *   The Mozilla Foundation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Doug Turner <dougt@mozilla.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "mozilla/dom/AudioChild.h"
      41                 : 
      42                 : namespace mozilla {
      43                 : namespace dom {
      44               0 : NS_IMPL_THREADSAFE_ADDREF(AudioChild);
      45               0 : NS_IMPL_THREADSAFE_RELEASE(AudioChild);
      46                 : 
      47               0 : AudioChild::AudioChild()
      48                 :   : mLastPosition(-1),
      49                 :     mLastPositionTimestamp(0),
      50                 :     mMinWriteSize(-2),// Initial value, -2, error on -1
      51                 :     mAudioReentrantMonitor("AudioChild.mReentrantMonitor"),
      52                 :     mIPCOpen(true),
      53               0 :     mDrained(false)
      54                 : {
      55               0 :   MOZ_COUNT_CTOR(AudioChild);
      56               0 : }
      57                 : 
      58               0 : AudioChild::~AudioChild()
      59                 : {
      60               0 :   MOZ_COUNT_DTOR(AudioChild);
      61               0 : }
      62                 : 
      63                 : void
      64               0 : AudioChild::ActorDestroy(ActorDestroyReason aWhy)
      65                 : {
      66               0 :   mIPCOpen = false;
      67               0 : }
      68                 : 
      69                 : bool
      70               0 : AudioChild::RecvPositionInFramesUpdate(const PRInt64& position,
      71                 :                                        const PRInt64& time)
      72                 : {
      73               0 :   mLastPosition = position;
      74               0 :   mLastPositionTimestamp = time;
      75               0 :   return true;
      76                 : }
      77                 : 
      78                 : bool
      79               0 : AudioChild::RecvDrainDone()
      80                 : {
      81               0 :   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
      82               0 :   mDrained = true;
      83               0 :   mAudioReentrantMonitor.NotifyAll();
      84               0 :   return true;
      85                 : }
      86                 : 
      87                 : PRInt32
      88               0 : AudioChild::WaitForMinWriteSize()
      89                 : {
      90               0 :   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
      91                 :   // -2 : initial value
      92               0 :   while (mMinWriteSize == -2 && mIPCOpen) {
      93               0 :     mAudioReentrantMonitor.Wait();
      94                 :   }
      95               0 :   return mMinWriteSize;
      96                 : }
      97                 : 
      98                 : bool
      99               0 : AudioChild::RecvMinWriteSizeDone(const PRInt32& minFrames)
     100                 : {
     101               0 :   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
     102               0 :   mMinWriteSize = minFrames;
     103               0 :   mAudioReentrantMonitor.NotifyAll();
     104               0 :   return true;
     105                 : }
     106                 : 
     107                 : void
     108               0 : AudioChild::WaitForDrain()
     109                 : {
     110               0 :   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
     111               0 :   while (!mDrained && mIPCOpen) {
     112               0 :     mAudioReentrantMonitor.Wait();
     113                 :   }
     114               0 : }
     115                 : 
     116                 : PRInt64
     117               0 : AudioChild::GetLastKnownPosition()
     118                 : {
     119               0 :   return mLastPosition;
     120                 : }
     121                 : 
     122                 : PRInt64
     123               0 : AudioChild::GetLastKnownPositionTimestamp()
     124                 : {
     125               0 :   return mLastPositionTimestamp;
     126                 : }
     127                 : 
     128                 : } // namespace dom
     129                 : } // namespace mozilla

Generated by: LCOV version 1.7