blob: dfe39e9d844285ac76ad5e8d9d5f88d2680c24f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/IntrusiveList.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <Kernel/Bus/PCI/Access.h>
#include <Kernel/Bus/PCI/Device.h>
#include <Kernel/Devices/Audio/Channel.h>
#include <Kernel/Devices/Device.h>
#include <Kernel/Library/LockWeakable.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Memory/PhysicalPage.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/Random.h>
namespace Kernel {
class AudioManagement;
class AudioController
: public AtomicRefCounted<AudioController>
, public LockWeakable<AudioController> {
friend class AudioManagement;
public:
virtual ~AudioController() = default;
virtual RefPtr<AudioChannel> audio_channel(u32 index) const = 0;
virtual ErrorOr<size_t> write(size_t channel_index, UserOrKernelBuffer const& data, size_t length) = 0;
virtual ErrorOr<void> initialize(Badge<AudioManagement>) = 0;
virtual ErrorOr<void> set_pcm_output_sample_rate(size_t channel_index, u32 samples_per_second_rate) = 0;
// Note: The return value is rate of samples per second
virtual ErrorOr<u32> get_pcm_output_sample_rate(size_t channel_index) = 0;
private:
IntrusiveListNode<AudioController, NonnullRefPtr<AudioController>> m_node;
};
}
|