VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h@ 71735

Last change on this file since 71735 was 71733, checked in by vboxsync, 7 years ago

HDAStreamPeriod.cpp: No point in hdaStreamPeriodCreate returning VINF_SUCCESS even when RTCritSectInit fails (if that is intentional, please change it to a void function). The HDASTREAMPERIOD::Dbg.tsStartNs member is used in log statements but was incorrectly guarded by DEBUG rather than LOG_ENABLED (this would create build problems if enabling logging in say a release build).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: HDAStreamPeriod.h 71733 2018-04-07 14:35:47Z vboxsync $ */
2/** @file
3 * HDAStreamPeriod.h - Stream period functions for HD Audio.
4 */
5
6/*
7 * Copyright (C) 2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef HDA_STREAMPERIOD_H
19#define HDA_STREAMPERIOD_H
20
21#include <iprt/critsect.h>
22#ifdef DEBUG
23# include <iprt/time.h>
24#endif
25#include <VBox/log.h> /* LOG_ENABLED */
26
27struct HDASTREAM;
28typedef HDASTREAM *PHDASTREAM;
29
30#ifdef LOG_ENABLED
31/**
32 * Structure for debug information of an HDA stream's period.
33 */
34typedef struct HDASTREAMPERIODDBGINFO
35{
36 /** Host start time (in ns) of the period. */
37 uint64_t tsStartNs;
38} HDASTREAMPERIODDBGINFO, *PHDASTREAMPERIODDBGINFO;
39#endif
40
41/** No flags set. */
42#define HDASTREAMPERIOD_FLAG_NONE 0
43/** The stream period has been initialized and is in a valid state. */
44#define HDASTREAMPERIOD_FLAG_VALID RT_BIT(0)
45/** The stream period is active. */
46#define HDASTREAMPERIOD_FLAG_ACTIVE RT_BIT(1)
47
48/**
49 * Structure for keeping an HDA stream's (time) period.
50 * This is needed in order to keep track of stream timing and interrupt delivery.
51 */
52typedef struct HDASTREAMPERIOD
53{
54 /** Associated HDA stream descriptor (SD) number. */
55 uint8_t u8SD;
56 /** The period's status flags. */
57 uint8_t fStatus;
58 uint8_t Padding1[6];
59 /** Critical section for serializing access. */
60 RTCRITSECT CritSect;
61 uint32_t Padding2[1];
62 /** Hertz (Hz) rate this period runs with. */
63 uint32_t u32Hz;
64 /** Period start time (in wall clock counts). */
65 uint64_t u64StartWalClk;
66 /** Period duration (in wall clock counts). */
67 uint64_t u64DurationWalClk;
68 /** The period's (relative) elapsed time (in wall clock counts). */
69 uint64_t u64ElapsedWalClk;
70 /** Delay (in wall clock counts) for tweaking the period timing. Optional. */
71 int64_t i64DelayWalClk;
72 /** Number of audio frames to transfer for this period. */
73 uint32_t framesToTransfer;
74 /** Number of audio frames already transfered. */
75 uint32_t framesTransferred;
76 /** Number of pending interrupts required for this period. */
77 uint8_t cIntPending;
78 uint8_t Padding3[7];
79#ifdef LOG_ENABLED
80 /** Debugging information. */
81 HDASTREAMPERIODDBGINFO Dbg;
82#endif
83} HDASTREAMPERIOD, *PHDASTREAMPERIOD;
84
85#ifdef IN_RING3
86int hdaStreamPeriodCreate(PHDASTREAMPERIOD pPeriod);
87void hdaStreamPeriodDestroy(PHDASTREAMPERIOD pPeriod);
88int hdaStreamPeriodInit(PHDASTREAMPERIOD pPeriod, uint8_t u8SD, uint16_t u16LVI, uint32_t u32CBL, PPDMAUDIOSTREAMCFG pStreamCfg);
89void hdaStreamPeriodReset(PHDASTREAMPERIOD pPeriod);
90int hdaStreamPeriodBegin(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);
91void hdaStreamPeriodEnd(PHDASTREAMPERIOD pPeriod);
92void hdaStreamPeriodPause(PHDASTREAMPERIOD pPeriod);
93void hdaStreamPeriodResume(PHDASTREAMPERIOD pPeriod);
94bool hdaStreamPeriodLock(PHDASTREAMPERIOD pPeriod);
95void hdaStreamPeriodUnlock(PHDASTREAMPERIOD pPeriod);
96uint64_t hdaStreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);
97uint64_t hdaStreamPeriodGetAbsEndWalClk(PHDASTREAMPERIOD pPeriod);
98uint64_t hdaStreamPeriodGetAbsElapsedWalClk(PHDASTREAMPERIOD pPeriod);
99uint32_t hdaStreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod);
100bool hdaStreamPeriodHasElapsed(PHDASTREAMPERIOD pPeriod);
101bool hdaStreamPeriodHasPassedAbsWalClk(PHDASTREAMPERIOD pPeriod, uint64_t u64WalClk);
102bool hdaStreamPeriodNeedsInterrupt(PHDASTREAMPERIOD pPeriod);
103void hdaStreamPeriodAcquireInterrupt(PHDASTREAMPERIOD pPeriod);
104void hdaStreamPeriodReleaseInterrupt(PHDASTREAMPERIOD pPeriod);
105void hdaStreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc);
106bool hdaStreamPeriodIsComplete(PHDASTREAMPERIOD pPeriod);
107#endif /* IN_RING3 */
108
109#endif /* !HDA_STREAMPERIOD_H */
110
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette