VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/HDAStreamChannel.cpp@ 82781

Last change on this file since 82781 was 82252, checked in by vboxsync, 5 years ago

vmm/pdmaudioifs.h: Style, docs and other nits. First, it's always _FLAGS_ never _FLAG_. Second, enums generally should start with _INVALID = 0 to ensure we don't mistake zero-initialized memory for valid data. Struct member names shall be indented on a tab (+4) boundrary. PDM is part of the VMM, so it follows the VMM coding guidelines strictly. Skip the 'Structure for keeping a ... around' fluff, the first sentence of a structure (or anything else for that matter) documentation shall be brief and to the point. It is automatically turned into a @brief. Furthermore, additional text should be a separate paragraph as it provides details the reader doesn't necessarily need to read. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: HDAStreamChannel.cpp 82252 2019-11-27 21:31:53Z vboxsync $ */
2/** @file
3 * HDAStreamChannel.cpp - Stream channel functions for HD Audio.
4 */
5
6/*
7 * Copyright (C) 2017-2019 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
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_DEV_HDA
23#include <VBox/log.h>
24
25#include <VBox/vmm/pdmdev.h>
26#include <VBox/vmm/pdmaudioifs.h>
27
28#include "HDAStreamChannel.h"
29
30/**
31 * Initializes a stream channel data structure.
32 *
33 * @returns IPRT status code.
34 * @param pChanData Channel data to initialize.
35 * @param fFlags
36 */
37int hdaR3StreamChannelDataInit(PPDMAUDIOSTREAMCHANNELDATA pChanData, uint32_t fFlags)
38{
39 int rc = RTCircBufCreate(&pChanData->pCircBuf, 256); /** @todo Make this configurable? */
40 if (RT_SUCCESS(rc))
41 {
42 pChanData->fFlags = fFlags;
43 }
44
45 return rc;
46}
47
48/**
49 * Destroys a stream channel data structure.
50 *
51 * @param pChanData Channel data to destroy.
52 */
53void hdaR3StreamChannelDataDestroy(PPDMAUDIOSTREAMCHANNELDATA pChanData)
54{
55 if (!pChanData)
56 return;
57
58 if (pChanData->pCircBuf)
59 {
60 RTCircBufDestroy(pChanData->pCircBuf);
61 pChanData->pCircBuf = NULL;
62 }
63
64 pChanData->fFlags = PDMAUDIOSTREAMCHANNELDATA_FLAGS_NONE;
65}
66
67/**
68 * Acquires (reads) audio channel data.
69 * Must be released when done with hdaR3StreamChannelReleaseData().
70 *
71 * @returns IPRT status code.
72 * @param pChanData Channel data to acquire audio channel data from.
73 * @param ppvData Where to store the pointer to the acquired data.
74 * @param pcbData Size (in bytes) of acquired data.
75 */
76int hdaR3StreamChannelAcquireData(PPDMAUDIOSTREAMCHANNELDATA pChanData, void **ppvData, size_t *pcbData)
77{
78 AssertPtrReturn(pChanData, VERR_INVALID_POINTER);
79 AssertPtrReturn(ppvData, VERR_INVALID_POINTER);
80 AssertPtrReturn(pcbData, VERR_INVALID_POINTER);
81
82 RTCircBufAcquireReadBlock(pChanData->pCircBuf, 256 /** @todo Make this configurarble? */, ppvData, &pChanData->cbAcq);
83
84 *pcbData = pChanData->cbAcq;
85 return VINF_SUCCESS;
86}
87
88/**
89 * Releases formerly acquired data by hdaR3StreamChannelAcquireData().
90 *
91 * @returns IPRT status code.
92 * @param pChanData Channel data to release formerly acquired data for.
93 */
94int hdaR3StreamChannelReleaseData(PPDMAUDIOSTREAMCHANNELDATA pChanData)
95{
96 AssertPtrReturn(pChanData, VERR_INVALID_POINTER);
97 RTCircBufReleaseReadBlock(pChanData->pCircBuf, pChanData->cbAcq);
98
99 return VINF_SUCCESS;
100}
101
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use