vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / media-add-ons / radeon / RadeonAddOn.h
blobbb5a18591cadd1ae61e927f948ab9723846fb527
1 /******************************************************************************
3 / File: RadeonAddOn.h
5 / Description: ATI Radeon Video Capture Media AddOn for BeOS.
7 / Copyright 2001, Carlos Hasan
9 *******************************************************************************/
11 #ifndef __RADEON_ADDON_H__
12 #define __RADEON_ADDON_H__
14 #include <media/MediaAddOn.h>
15 #include <Path.h>
16 #include "benaphore.h"
18 #define TOUCH(x) ((void)(x))
20 extern "C" _EXPORT BMediaAddOn *make_media_addon(image_id you);
22 class CRadeonAddOn;
24 // descriptor of a possible Radeon node
25 class CRadeonPlug {
26 public:
27 CRadeonPlug( CRadeonAddOn *addon, const BPath &dev_path, int id );
28 ~CRadeonPlug() {}
30 const char *getName() { return fFlavorInfo.name; }
31 const char *getDeviceName() { return dev_path.Path(); }
32 const char *getDeviceShortName() { return dev_path.Leaf(); }
33 flavor_info *getFlavorInfo() { return &fFlavorInfo; }
34 BMediaNode *getNode() { return node; }
35 void setNode( BMediaNode *anode ) { node = anode; }
36 BMessage *getSettings() { return &settings; }
38 void writeSettings( BMessage *new_settings );
40 private:
41 CRadeonAddOn *addon; // (global) addon (only needed for GetConfiguration())
42 BPath dev_path; // path of device driver
43 int id; // id of plug
44 flavor_info fFlavorInfo; // flavor of plug (contains unique id)
45 BMediaNode *node; // active node (or NULL)
46 BMessage settings; // settings for this node
47 media_format fMediaFormat[4];
49 void readSettings();
50 BPath getSettingsPath();
53 class CRadeonAddOn : public BMediaAddOn
55 public:
56 CRadeonAddOn(image_id imid);
57 virtual ~CRadeonAddOn();
59 virtual status_t InitCheck(const char **out_failure_text);
61 virtual int32 CountFlavors();
62 virtual status_t GetFlavorAt(int32 n, const flavor_info ** out_info);
63 virtual BMediaNode *InstantiateNodeFor(
64 const flavor_info * info,
65 BMessage * config,
66 status_t * out_error);
68 virtual status_t SaveConfigInfo(BMediaNode *node, BMessage *message)
69 { TOUCH(node); TOUCH(message); return B_OK; }
71 virtual bool WantsAutoStart() { return false; }
72 virtual status_t AutoStart(int in_count, BMediaNode **out_node,
73 int32 *out_internal_id, bool *out_has_more)
74 { TOUCH(in_count); TOUCH(out_node);
75 TOUCH(out_internal_id); TOUCH(out_has_more);
76 return B_ERROR; }
78 virtual status_t GetConfigurationFor(
79 BMediaNode *your_node,
80 BMessage *into_message );
82 // private methods
83 void UnregisterNode( BMediaNode *node, BMessage *settings );
85 private:
86 status_t fInitStatus;
87 BList fDevices; // list of BPath of found devices
88 thread_id settings_thread;
89 sem_id settings_thread_sem;
90 benaphore plug_lock;
91 BMessage settings;
93 status_t RecursiveScan( const char* rootPath, BEntry *rootEntry = NULL );
94 static int32 settings_writer( void *param );
95 void settingsWriter();
96 void writeSettings();
99 #endif