1 // MixerAddOn.cpp 2 // 3 // David Shipman, 2002 4 // Marcus Overhagen, 2003 5 // 6 // Allows AudioMixer to be used as an addon. 7 // The add-on will request to be auto-started. 8 9 #include <MediaRoster.h> 10 #include <MediaNode.h> 11 #include <cstring> 12 #include <cstdio> 13 14 #include "AudioMixer.h" 15 #include "MixerAddOn.h" 16 17 // instantiation function 18 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) { 19 return new AudioMixerAddon(image); 20 } 21 22 // ------------------------------------------------------- // 23 // ctor/dtor 24 // -------------------------------------------------------- // 25 26 AudioMixerAddon::AudioMixerAddon(image_id image) 27 : BMediaAddOn(image), 28 fFormat(new media_format), 29 fInfo(new flavor_info) 30 { 31 // Init media_format 32 memset(fFormat, 0, sizeof(*fFormat)); 33 fFormat->type = B_MEDIA_RAW_AUDIO; 34 fFormat->u.raw_audio = media_raw_audio_format::wildcard; 35 36 // Init flavor_info 37 fInfo->internal_id = 0; 38 fInfo->name = "Audio Mixer (OpenBeOS)"; 39 fInfo->info = "OpenBeOS Audio Mixer media addon"; 40 fInfo->kinds = B_BUFFER_PRODUCER | B_BUFFER_CONSUMER | B_SYSTEM_MIXER | B_CONTROLLABLE; 41 fInfo->flavor_flags = 0; // 0 = global or local instantiation allowed, no restrictions 42 fInfo->possible_count = 0; // 0 = infinite 43 fInfo->in_format_count = 1; 44 fInfo->in_formats = fFormat; 45 fInfo->out_format_count = 1; 46 fInfo->out_formats = fFormat; 47 } 48 49 AudioMixerAddon::~AudioMixerAddon() 50 { 51 delete fFormat; 52 delete fInfo; 53 } 54 55 // -------------------------------------------------------- // 56 // BMediaAddOn impl 57 // -------------------------------------------------------- // 58 59 status_t 60 AudioMixerAddon::InitCheck(const char** out_failure_text) 61 { 62 return B_OK; 63 } 64 65 int32 66 AudioMixerAddon::CountFlavors() 67 { 68 return 1; 69 } 70 71 status_t 72 AudioMixerAddon::GetFlavorAt(int32 n, const flavor_info** out_info) 73 { 74 // only the 0th flavor exists 75 if (n != 0) 76 return B_ERROR; 77 78 *out_info = fInfo; 79 return B_OK; 80 } 81 82 BMediaNode * 83 AudioMixerAddon::InstantiateNodeFor(const flavor_info* info, BMessage* config, 84 status_t* out_error) 85 { 86 return new AudioMixer(this, false); 87 } 88 89 status_t 90 AudioMixerAddon::GetConfigurationFor(BMediaNode* your_node, BMessage* into_message) 91 { 92 // no config yet 93 return B_ERROR; 94 } 95 96 bool 97 AudioMixerAddon::WantsAutoStart() 98 { 99 // yes, please kick me 100 return true; 101 } 102 103 status_t 104 AudioMixerAddon::AutoStart(int in_index, BMediaNode ** out_node, 105 int32 * out_internal_id, bool * out_has_more) 106 { 107 *out_has_more = false; 108 109 if (in_index != 0) 110 return B_ERROR; 111 112 *out_internal_id = 0; 113 AudioMixer *mixer = new AudioMixer(this, true); 114 *out_node = mixer; 115 116 return B_OK; 117 } 118