implement a recursive scanning of /dev/audio/old/ to find devices. Untested yet.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20359 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2007-03-08 19:28:17 +00:00
parent fd87740ca0
commit 07005d6f95
3 changed files with 48 additions and 3 deletions

View File

@ -8,5 +8,5 @@ Addon legacy.media_addon : media :
LegacyAudioProducer.cpp
LegacyMediaAddOn.cpp
: false
: media
: be media
;

View File

@ -7,11 +7,17 @@
#include <media/MediaAddOn.h>
#include <Directory.h>
#include <Entry.h>
#include <Path.h>
#include <String.h>
#include "LegacyMediaAddOn.h"
#include "LegacyAudioConsumer.h"
#include "LegacyAudioProducer.h"
#define LEGACY_DEVICE_PATH_BASE "/dev/audio/old"
LegacyMediaAddOn::LegacyMediaAddOn( image_id imid )
: BMediaAddOn( imid )
@ -59,6 +65,42 @@ LegacyMediaAddOn::InstantiateNodeFor( const flavor_info *info, BMessage *config,
return NULL;
}
status_t
LegacyMediaAddOn::RecursiveScanForDevices(const char *path)
{
BDirectory d(path ? path : LEGACY_DEVICE_PATH_BASE);
if (d.InitCheck() < B_OK)
return d.InitCheck();
BEntry ent;
while (d.GetNextEntry(&ent) == B_OK) {
struct stat st;
char name[B_FILE_NAME_LENGTH];
ent.GetName(name);
if (d.GetStatFor(name, &st) < 0)
continue;
BPath p(&ent);
// we're only interested in folders...
if (S_ISDIR(st.st_mode)) {
RecursiveScanForDevices(p.Path());
// discard error
continue;
}
// and (char) devices
if (!S_ISCHR(st.st_mode))
continue;
// we want relative path
BString s(p.Path());
s.RemoveFirst(LEGACY_DEVICE_PATH_BASE"/");
// XXX: should check first for consumer or producer...
// XXX: use a struct/class
fConsumers.AddItem((void *)s.String());
//XXX: only cons for now
//fProducers.AddItem(s.String());
}
return B_OK;
}
BMediaAddOn *
make_media_addon( image_id imid )

View File

@ -2,6 +2,7 @@
#define _LEGACY_MEDIA_ADDON_H
#include <media/MediaAddOn.h>
#include <List.h>
#include "LegacyAudioConsumer.h"
//#include "LegacyAudioProducer.h"
@ -29,14 +30,16 @@ class LegacyMediaAddOn : public BMediaAddOn
virtual status_t AutoStart( int in_count, BMediaNode **out_node, int32 *out_internal_id, bool *out_has_more )
{ return B_ERROR; }
status_t RecursiveScanForDevices(const char *path=NULL);
private:
status_t fInitStatus;
flavor_info fFlavorInfo;
media_format fMediaFormat;
//BList *consumers;
//BList *producers;
BList fConsumers;
BList fProducers;
LegacyAudioConsumer *consumer;
};