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 #ifndef _OPENSOUNDDEVICEENGINE_H
9 #define _OPENSOUNDDEVICEENGINE_H
11 #include "OpenSoundDevice.h"
13 class OpenSoundDeviceEngine
16 OpenSoundDeviceEngine(oss_audioinfo
*info
);
17 virtual ~OpenSoundDeviceEngine(void);
19 virtual status_t
InitCheck(void) const;
20 int FD() const { return fFD
; };
21 const oss_audioinfo
*Info() const { return &fAudioInfo
; };
23 status_t
Open(int mode
/* OPEN_* */);
27 virtual ssize_t
Read(void *buffer
, size_t size
);
28 virtual ssize_t
Write(const void *buffer
, size_t size
);
31 /* chain of engines for the same physical in/out */
32 OpenSoundDeviceEngine
*NextPlay() const { return fNextPlay
; };
33 OpenSoundDeviceEngine
*NextRec() const { return fNextRec
; };
35 int OpenMode() const { return fOpenMode
; };
36 bool InUse() const { return (fOpenMode
!= 0); };
38 status_t
UpdateInfo();
40 int Caps() const { return fAudioInfo
.caps
; };
41 bigtime_t
CardLatency(void) const { return (fAudioInfo
.latency
< 0) ? 0 : fAudioInfo
.latency
; };
42 bigtime_t
PlaybackLatency(void);
43 bigtime_t
RecordingLatency(void);
46 int GetChannels(void);
47 status_t
SetChannels(int chans
);
50 status_t
SetFormat(int fmt
);
53 status_t
SetSpeed(int speed
);
55 void GetMediaFormat(media_format
&format
);
57 size_t GetISpace(audio_buf_info
*info
=NULL
);
58 size_t GetOSpace(audio_buf_info
*info
=NULL
);
60 int64
GetCurrentIPtr(int32
* fifoed
= NULL
,
61 oss_count_t
* info
= NULL
);
62 int64
GetCurrentOPtr(int32
* fifoed
= NULL
,
63 size_t* fragmentPos
= NULL
);
66 int32
GetOUnderruns();
68 size_t DriverBufferSize() const;
70 status_t
StartRecording(void);
73 status_t
WildcardFormatFor(int fmt
, media_format
&format
, bool rec
=false);
75 status_t
PreferredFormatFor(int fmt
, media_format
&format
, bool rec
=false);
77 status_t
AcceptFormatFor(int fmt
, media_format
&format
, bool rec
=false);
79 status_t
SpecializeFormatFor(int fmt
, media_format
&format
, bool rec
=true);
82 status_t fInitCheckStatus
;
83 oss_audioinfo fAudioInfo
;
84 friend class OpenSoundAddOn
;
85 OpenSoundDeviceEngine
*fNextPlay
;
86 OpenSoundDeviceEngine
*fNextRec
;
87 int fOpenMode
; // OPEN_*
89 media_format fMediaFormat
;
90 int64 fPlayedFramesCount
;
91 bigtime_t fPlayedRealTime
;
92 size_t fDriverBufferSize
;