1 /* 2 * Copyright 2002 David Shipman, 3 * Copyright 2003-2007 Marcus Overhagen 4 * Copyright 2007 Haiku Inc. All rights reserved. 5 * Distributed under the terms of the MIT License. 6 */ 7 8 9 #include "MixerAddOn.h" 10 11 #include <stdio.h> 12 #include <string.h> 13 14 #include <MediaRoster.h> 15 #include <MediaNode.h> 16 17 #include "AudioMixer.h" 18 19 20 // instantiation function 21 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) { 22 return new AudioMixerAddon(image); 23 } 24 25 26 AudioMixerAddon::AudioMixerAddon(image_id image) 27 : 28 BMediaAddOn(image), 29 fFormat(new media_format), 30 fInfo(new flavor_info) 31 { 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 fInfo->internal_id = 0; 37 fInfo->name = "Audio Mixer (Haiku)"; 38 fInfo->info = "Haiku Audio Mixer media addon"; 39 fInfo->kinds = B_BUFFER_PRODUCER | B_BUFFER_CONSUMER | B_SYSTEM_MIXER | B_CONTROLLABLE; 40 fInfo->flavor_flags = 0; // 0 = global or local instantiation allowed, no restrictions 41 fInfo->possible_count = 0; // 0 = infinite 42 fInfo->in_format_count = 1; 43 fInfo->in_formats = fFormat; 44 fInfo->out_format_count = 1; 45 fInfo->out_formats = fFormat; 46 } 47 48 49 AudioMixerAddon::~AudioMixerAddon() 50 { 51 delete fFormat; 52 delete fInfo; 53 } 54 55 56 // #pragma mark - BMediaAddOn implementation 57 58 59 status_t 60 AudioMixerAddon::InitCheck(const char** out_failure_text) 61 { 62 return B_OK; 63 } 64 65 66 int32 67 AudioMixerAddon::CountFlavors() 68 { 69 return 1; 70 } 71 72 73 status_t 74 AudioMixerAddon::GetFlavorAt(int32 n, const flavor_info** out_info) 75 { 76 // only the 0th flavor exists 77 if (n != 0) 78 return B_ERROR; 79 80 *out_info = fInfo; 81 return B_OK; 82 } 83 84 85 BMediaNode * 86 AudioMixerAddon::InstantiateNodeFor(const flavor_info* info, BMessage* config, 87 status_t* out_error) 88 { 89 return new AudioMixer(this, false); 90 } 91 92 93 status_t 94 AudioMixerAddon::GetConfigurationFor(BMediaNode* your_node, 95 BMessage* into_message) 96 { 97 // no config yet 98 return B_ERROR; 99 } 100 101 102 bool 103 AudioMixerAddon::WantsAutoStart() 104 { 105 return true; 106 } 107 108 109 status_t 110 AudioMixerAddon::AutoStart(int in_index, BMediaNode **out_node, 111 int32 *out_internal_id, bool *out_has_more) 112 { 113 *out_has_more = false; 114 115 if (in_index != 0) 116 return B_ERROR; 117 118 *out_internal_id = 0; 119 AudioMixer *mixer = new AudioMixer(this, true); 120 *out_node = mixer; 121 122 return B_OK; 123 } 124