hydrogen 1.2.3
OssDriver.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
23#ifndef OSS_AUDIO_DRIVER_H
24#define OSS_AUDIO_DRIVER_H
25
26#include <core/IO/AudioOutput.h>
27#include <core/IO/NullDriver.h>
28
29// check if OSS support is enabled
30#if defined(H2CORE_HAVE_OSS) || _DOXYGEN_
31
32
33#ifdef __NetBSD__
34#include <soundcard.h>
35#else
36#include <sys/soundcard.h>
37#endif
38#include <sys/ioctl.h>
39#include <stdio.h>
40#include <sys/types.h>
41#include <sys/stat.h>
42#include <fcntl.h>
43#include <iostream>
44#include <unistd.h>
45#include <inttypes.h>
46
47#include <core/Globals.h>
48
49/*
50#ifdef __NetBSD__
51 #define AUDIO_DEVICE "/dev/audio"
52#else
53 #define AUDIO_DEVICE "/dev/dsp"
54#endif
55*/
56
57namespace H2Core
58{
59
63
64class OssDriver : public Object<OssDriver>, public AudioOutput
65{
67public:
69 ~OssDriver();
70
71 int init( unsigned bufferSize );
72 int connect();
73 void disconnect();
74
75 void write();
76 unsigned getBufferSize();
77 unsigned getSampleRate();
78 float* getOut_L();
79 float* getOut_R();
80
81private:
83 int fd;
84
86 float* out_L;
87 float* out_R;
88
90 int log2( int n );
91
92};
93
94#else
95
96namespace H2Core {
97
98class OssDriver : public Object<OssDriver>, public NullDriver
99{
101public:
103
104};
105
106
107
108#endif // OSS support
109
110};
111
112#endif
#define H2_OBJECT(name)
Definition Object.h:224
Base abstract class for audio output classes.
Definition AudioOutput.h:39
OSS Audio Driver.
Definition OssDriver.h:65
audioProcessCallback processCallback
Definition OssDriver.h:89
int connect()
Connect return 0: Ok return 1: Generic error.
int fd
file descriptor, for writing to /dev/dsp
Definition OssDriver.h:83
int init(unsigned bufferSize)
Definition OssDriver.cpp:90
unsigned getBufferSize()
OssDriver(audioProcessCallback processCallback)
Definition OssDriver.cpp:70
void write()
Write the audio data.
short * audioBuffer
Definition OssDriver.h:85
unsigned getSampleRate()
int(* audioProcessCallback)(uint32_t, void *)
Definition AudioOutput.h:32