2 * OpenSound media addon for BeOS and Haiku
4 * Copyright (c) 2007, François Revol (revol@free.fr)
5 * Distributed under the terms of the MIT License.
8 #include "OpenSoundDeviceMixer.h"
10 #include "driver_io.h"
11 #include <MediaDefs.h>
16 OpenSoundDeviceMixer::~OpenSoundDeviceMixer()
24 OpenSoundDeviceMixer::OpenSoundDeviceMixer(oss_mixerinfo
*info
)
27 fInitCheckStatus
= B_NO_INIT
;
28 memcpy(&fMixerInfo
, info
, sizeof(oss_mixerinfo
));
29 fFD
= open(info
->devnode
, O_RDWR
);
31 fInitCheckStatus
= errno
;
34 fInitCheckStatus
= B_OK
;
38 status_t
OpenSoundDeviceMixer::InitCheck(void) const
41 return fInitCheckStatus
;
44 int OpenSoundDeviceMixer::CountExtInfos()
52 // -1 doesn't work here (!?)
54 if (ioctl(fFD
, SNDCTL_MIX_NREXT
, &n
, sizeof(int)) < 0) {
55 PRINT(("OpenSoundDeviceMixer::CountExtInfos: SNDCTL_MIX_NREXT: %s\n", strerror(errno
)));
64 status_t
OpenSoundDeviceMixer::GetExtInfo(int index
, oss_mixext
*info
)
71 // XXX: we should probably cache them as they might change on the fly
73 info
->dev
= Info()->dev
; // this mixer
75 if (ioctl(fFD
, SNDCTL_MIX_EXTINFO
, info
, sizeof(*info
)) < 0) {
76 PRINT(("OpenSoundDeviceMixer::%s: SNDCTL_MIX_EXTINFO(%d): %s\n", __FUNCTION__
, index
, strerror(errno
)));
84 status_t
OpenSoundDeviceMixer::GetMixerValue(oss_mixer_value
*value
)
91 value
->dev
= Info()->dev
; // this mixer
92 // should be set before calling
93 //value->ctrl = index;
95 if (ioctl(fFD
, SNDCTL_MIX_READ
, value
, sizeof(*value
)) < 0) {
96 PRINT(("OpenSoundDeviceMixer::%s: SNDCTL_MIX_READ(%d): %s\n", __FUNCTION__
, value
->ctrl
, strerror(errno
)));
104 status_t
OpenSoundDeviceMixer::SetMixerValue(oss_mixer_value
*value
)
111 value
->dev
= Info()->dev
; // this mixer
112 // should be set before calling
113 //value->ctrl = index;
115 if (ioctl(fFD
, SNDCTL_MIX_WRITE
, value
, sizeof(*value
)) < 0) {
116 PRINT(("OpenSoundDeviceMixer::%s: SNDCTL_MIX_WRITE(%d): %s\n", __FUNCTION__
, value
->ctrl
, strerror(errno
)));
124 status_t
OpenSoundDeviceMixer::GetEnumInfo(int index
, oss_mixer_enuminfo
*info
)
131 info
->dev
= Info()->dev
; // this mixer
133 if (ioctl(fFD
, SNDCTL_MIX_ENUMINFO
, info
, sizeof(*info
)) < 0) {
134 PRINT(("OpenSoundDeviceMixer::%s: SNDCTL_MIX_ENUMINFO(%d): %s\n", __FUNCTION__
, index
, strerror(errno
)));