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 fFormat->type = B_MEDIA_RAW_AUDIO; 33 fFormat->u.raw_audio = media_raw_audio_format::wildcard; 34 35 fInfo->internal_id = 0; 36 fInfo->name = (char *)"Audio Mixer"; 37 fInfo->info = (char *)"Audio Mixer media addon"; 38 fInfo->kinds = B_BUFFER_PRODUCER | B_BUFFER_CONSUMER | B_SYSTEM_MIXER | B_CONTROLLABLE; 39 fInfo->flavor_flags = 0; // 0 = global or local instantiation allowed, no restrictions 40 fInfo->possible_count = 0; // 0 = infinite 41 fInfo->in_format_count = 1; 42 fInfo->in_formats = fFormat; 43 fInfo->out_format_count = 1; 44 fInfo->out_formats = fFormat; 45 } 46 47 48 AudioMixerAddon::~AudioMixerAddon() 49 { 50 delete fFormat; 51 delete fInfo; 52 } 53 54 55 // #pragma mark - BMediaAddOn implementation 56 57 58 status_t 59 AudioMixerAddon::InitCheck(const char** out_failure_text) 60 { 61 return B_OK; 62 } 63 64 65 int32 66 AudioMixerAddon::CountFlavors() 67 { 68 return 1; 69 } 70 71 72 status_t 73 AudioMixerAddon::GetFlavorAt(int32 n, const flavor_info** out_info) 74 { 75 // only the 0th flavor exists 76 if (n != 0) 77 return B_ERROR; 78 79 *out_info = fInfo; 80 return B_OK; 81 } 82 83 84 BMediaNode * 85 AudioMixerAddon::InstantiateNodeFor(const flavor_info* info, BMessage* config, 86 status_t* out_error) 87 { 88 return new AudioMixer(this, false); 89 } 90 91 92 status_t 93 AudioMixerAddon::GetConfigurationFor(BMediaNode* your_node, 94 BMessage* into_message) 95 { 96 // no config yet 97 return B_ERROR; 98 } 99 100 101 bool 102 AudioMixerAddon::WantsAutoStart() 103 { 104 return true; 105 } 106 107 108 status_t 109 AudioMixerAddon::AutoStart(int in_index, BMediaNode **out_node, 110 int32 *out_internal_id, bool *out_has_more) 111 { 112 *out_has_more = false; 113 114 if (in_index != 0) 115 return B_ERROR; 116 117 *out_internal_id = 0; 118 AudioMixer *mixer = new AudioMixer(this, true); 119 *out_node = mixer; 120 121 return B_OK; 122 } 123