hydrogen 1.2.3
AlsaAudioDriver.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22#ifndef ALSA_AUDIO_DRIVER_H
23#define ALSA_AUDIO_DRIVER_H
24
25#include <core/IO/AudioOutput.h>
26#include <core/IO/NullDriver.h>
27
28#if defined(H2CORE_HAVE_ALSA) || _DOXYGEN_
29
30#include <inttypes.h>
31#include <alsa/asoundlib.h>
32
33namespace H2Core
34{
35
37class AlsaAudioDriver : public Object<AlsaAudioDriver>, public AudioOutput
38{
40public:
43 unsigned long m_nBufferSize;
44 float* m_pOut_L;
45 float* m_pOut_R;
49
50 AlsaAudioDriver( audioProcessCallback processCallback );
52
53 virtual int init( unsigned nBufferSize ) override;
54 virtual int connect() override;
55 virtual void disconnect() override;
56 virtual unsigned getBufferSize() override;
57 virtual unsigned getSampleRate() override;
58 virtual float* getOut_L() override;
59 virtual float* getOut_R() override;
60 static QStringList getDevices();
61
62 virtual int getXRuns() const override { return m_nXRuns; }
63
64private:
65
66 unsigned int m_nSampleRate;
67};
68
69#else
70
71namespace H2Core {
72
74class AlsaAudioDriver : public NullDriver
75{
77public:
78 AlsaAudioDriver( audioProcessCallback processCallback ) : NullDriver( processCallback ) {}
79
80};
81
82#endif // H2CORE_HAVE_ALSA
83
84};
85
86#endif
#define H2_OBJECT(name)
Definition Object.h:224
virtual void disconnect() override
virtual float * getOut_L() override
virtual int init(unsigned nBufferSize) override
virtual float * getOut_R() override
virtual unsigned getBufferSize() override
virtual int connect() override
virtual int getXRuns() const override
Get the number of XRuns that occurred since the audio driver has started.
static QStringList getDevices()
Use the name hints to build a list of potential device names.
AlsaAudioDriver(audioProcessCallback processCallback)
audioProcessCallback m_processCallback
virtual unsigned getSampleRate() override
Base abstract class for audio output classes.
Definition AudioOutput.h:39
int(* audioProcessCallback)(uint32_t, void *)
Definition AudioOutput.h:32