xref: /haiku/src/add-ons/media/media-add-ons/opensound/OpenSoundDeviceEngine.h (revision 1b8f7f13a3dc70e0e903cb94248220b40b732204)
1 /*
2  * OpenSound media addon for BeOS and Haiku
3  *
4  * Copyright (c) 2007, François Revol (revol@free.fr)
5  * Distributed under the terms of the MIT License.
6  */
7 
8 #ifndef _OPENSOUNDDEVICEENGINE_H
9 #define _OPENSOUNDDEVICEENGINE_H
10 
11 #include "OpenSoundDevice.h"
12 
13 class OpenSoundDeviceEngine
14 {
15 	public:
16 		OpenSoundDeviceEngine(oss_audioinfo *info);
17 		virtual ~OpenSoundDeviceEngine(void);
18 
19 		virtual status_t InitCheck(void) const;
20 		int			FD() const { return fFD; };
21 		const oss_audioinfo *Info() const { return &fAudioInfo; };
22 
23 		status_t	Open(int mode/* OPEN_* */);
24 		status_t	Close();
25 
26 		//BDadaIO...
27 virtual	ssize_t		Read(void *buffer, size_t size);
28 virtual	ssize_t		Write(const void *buffer, size_t size);
29 
30 
31 		/* chain of engines for the same physical in/out */
32 		OpenSoundDeviceEngine *NextPlay() const { return fNextPlay; };
33 		OpenSoundDeviceEngine *NextRec() const { return fNextRec; };
34 
35 		int			OpenMode() const { return fOpenMode; };
36 		bool		InUse() const { return (fOpenMode != 0); };
37 
38 		status_t	UpdateInfo();
39 		// shortcuts
40 		int			Caps() const { return fAudioInfo.caps; };
41 		int			Latency() const { return fAudioInfo.latency; };
42 
43 
44 		int			GetChannels(void);
45 		status_t	SetChannels(int chans);
46 
47 		int			GetFormat(void);
48 		status_t	SetFormat(int fmt);
49 
50 		int			GetSpeed(void);
51 		status_t	SetSpeed(int speed);
52 
53 		void		GetMediaFormat(media_format &format);
54 
55 		size_t		GetISpace(audio_buf_info *info=NULL);
56 		size_t		GetOSpace(audio_buf_info *info=NULL);
57 
58 		int			GetODelay(void);
59 
60 		status_t	StartRecording(void);
61 
62 		int64		PlayedFramesCount(void);
63 		bigtime_t	PlayedRealTime(void);
64 
65 		// suggest possibles
66 		status_t	WildcardFormatFor(int fmt, media_format &format, bool rec=false);
67 		// suggest best
68 		status_t	PreferredFormatFor(int fmt, media_format &format, bool rec=false);
69 		// try this format
70 		status_t	AcceptFormatFor(int fmt, media_format &format, bool rec=false);
71 		// apply this format
72 		status_t	SpecializeFormatFor(int fmt, media_format &format, bool rec=true);
73 
74 	private:
75 		status_t 				fInitCheckStatus;
76 		oss_audioinfo			fAudioInfo;
77 friend class OpenSoundAddOn;
78 		OpenSoundDeviceEngine	*fNextPlay;
79 		OpenSoundDeviceEngine	*fNextRec;
80 		int						fOpenMode; // OPEN_*
81 		int						fFD;
82 		media_format			fMediaFormat;
83 		int64					fPlayedFramesCount;
84 		bigtime_t				fPlayedRealTime;
85 };
86 
87 #endif
88