diff --git a/src/add-ons/media/media-add-ons/legacy/Jamfile b/src/add-ons/media/media-add-ons/legacy/Jamfile index 8e93c91ecb..5454543b8f 100644 --- a/src/add-ons/media/media-add-ons/legacy/Jamfile +++ b/src/add-ons/media/media-add-ons/legacy/Jamfile @@ -8,5 +8,5 @@ Addon legacy.media_addon : media : LegacyAudioProducer.cpp LegacyMediaAddOn.cpp : false - : media + : be media ; diff --git a/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.cpp b/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.cpp index 5a25573fd7..f0f4af4878 100644 --- a/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.cpp +++ b/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.cpp @@ -7,11 +7,17 @@ #include +#include +#include +#include +#include + #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 ) diff --git a/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.h b/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.h index b63787cb56..6b655cede2 100644 --- a/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.h +++ b/src/add-ons/media/media-add-ons/legacy/LegacyMediaAddOn.h @@ -2,6 +2,7 @@ #define _LEGACY_MEDIA_ADDON_H #include +#include #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; };