1bf7ab50dSStephan Aßmus /*
2bf7ab50dSStephan Aßmus * Copyright 2002 David Shipman,
3bf7ab50dSStephan Aßmus * Copyright 2003-2007 Marcus Overhagen
4bf7ab50dSStephan Aßmus * Copyright 2007 Haiku Inc. All rights reserved.
5bf7ab50dSStephan Aßmus * Distributed under the terms of the MIT License.
6bf7ab50dSStephan Aßmus */
7a9cf57cfSAxel Dörfler
8a9cf57cfSAxel Dörfler
9a9cf57cfSAxel Dörfler #include "MixerAddOn.h"
10a9cf57cfSAxel Dörfler
11a9cf57cfSAxel Dörfler #include <stdio.h>
12a9cf57cfSAxel Dörfler #include <string.h>
13a9cf57cfSAxel Dörfler
14c9c07d81Sbeveloper #include <MediaRoster.h>
15c9c07d81Sbeveloper #include <MediaNode.h>
1600cffa1cSbeveloper
1700cffa1cSbeveloper #include "AudioMixer.h"
18a9cf57cfSAxel Dörfler
1900cffa1cSbeveloper
2000cffa1cSbeveloper // instantiation function
make_media_addon(image_id image)2100cffa1cSbeveloper extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
2200cffa1cSbeveloper return new AudioMixerAddon(image);
2300cffa1cSbeveloper }
2400cffa1cSbeveloper
25a9cf57cfSAxel Dörfler
AudioMixerAddon(image_id image)26c9c07d81Sbeveloper AudioMixerAddon::AudioMixerAddon(image_id image)
27a9cf57cfSAxel Dörfler :
28a9cf57cfSAxel Dörfler BMediaAddOn(image),
29c9c07d81Sbeveloper fFormat(new media_format),
30c9c07d81Sbeveloper fInfo(new flavor_info)
31c9c07d81Sbeveloper {
32c9c07d81Sbeveloper fFormat->type = B_MEDIA_RAW_AUDIO;
33c9c07d81Sbeveloper fFormat->u.raw_audio = media_raw_audio_format::wildcard;
3400cffa1cSbeveloper
35c9c07d81Sbeveloper fInfo->internal_id = 0;
36*fb5c24d8SAdrien Destugues fInfo->name = "Audio Mixer";
37*fb5c24d8SAdrien Destugues fInfo->info = "Audio Mixer media addon";
38ea83877fSbeveloper fInfo->kinds = B_BUFFER_PRODUCER | B_BUFFER_CONSUMER | B_SYSTEM_MIXER | B_CONTROLLABLE;
3929625f76Sbeveloper fInfo->flavor_flags = 0; // 0 = global or local instantiation allowed, no restrictions
4029625f76Sbeveloper fInfo->possible_count = 0; // 0 = infinite
41ea83877fSbeveloper fInfo->in_format_count = 1;
42ea83877fSbeveloper fInfo->in_formats = fFormat;
43ea83877fSbeveloper fInfo->out_format_count = 1;
44ea83877fSbeveloper fInfo->out_formats = fFormat;
45c9c07d81Sbeveloper }
46c9c07d81Sbeveloper
47a9cf57cfSAxel Dörfler
~AudioMixerAddon()48c9c07d81Sbeveloper AudioMixerAddon::~AudioMixerAddon()
49c9c07d81Sbeveloper {
50c9c07d81Sbeveloper delete fFormat;
51c9c07d81Sbeveloper delete fInfo;
52c9c07d81Sbeveloper }
53c9c07d81Sbeveloper
54a9cf57cfSAxel Dörfler
55a9cf57cfSAxel Dörfler // #pragma mark - BMediaAddOn implementation
56a9cf57cfSAxel Dörfler
57c9c07d81Sbeveloper
58c9c07d81Sbeveloper status_t
InitCheck(const char ** out_failure_text)59c9c07d81Sbeveloper AudioMixerAddon::InitCheck(const char** out_failure_text)
60c9c07d81Sbeveloper {
61c9c07d81Sbeveloper return B_OK;
62c9c07d81Sbeveloper }
63c9c07d81Sbeveloper
64a9cf57cfSAxel Dörfler
65c9c07d81Sbeveloper int32
CountFlavors()66c9c07d81Sbeveloper AudioMixerAddon::CountFlavors()
67c9c07d81Sbeveloper {
68c9c07d81Sbeveloper return 1;
69c9c07d81Sbeveloper }
70c9c07d81Sbeveloper
71a9cf57cfSAxel Dörfler
72c9c07d81Sbeveloper status_t
GetFlavorAt(int32 n,const flavor_info ** out_info)73c9c07d81Sbeveloper AudioMixerAddon::GetFlavorAt(int32 n, const flavor_info** out_info)
74c9c07d81Sbeveloper {
75c9c07d81Sbeveloper // only the 0th flavor exists
76c9c07d81Sbeveloper if (n != 0)
77c9c07d81Sbeveloper return B_ERROR;
7800cffa1cSbeveloper
79ea83877fSbeveloper *out_info = fInfo;
8000cffa1cSbeveloper return B_OK;
8100cffa1cSbeveloper }
8200cffa1cSbeveloper
83a9cf57cfSAxel Dörfler
84c9c07d81Sbeveloper BMediaNode *
InstantiateNodeFor(const flavor_info * info,BMessage * config,status_t * out_error)85c9c07d81Sbeveloper AudioMixerAddon::InstantiateNodeFor(const flavor_info* info, BMessage* config,
86c9c07d81Sbeveloper status_t* out_error)
87c9c07d81Sbeveloper {
881165d5e1Sbeveloper return new AudioMixer(this, false);
8900cffa1cSbeveloper }
9000cffa1cSbeveloper
91a9cf57cfSAxel Dörfler
92c9c07d81Sbeveloper status_t
GetConfigurationFor(BMediaNode * your_node,BMessage * into_message)93a9cf57cfSAxel Dörfler AudioMixerAddon::GetConfigurationFor(BMediaNode* your_node,
94a9cf57cfSAxel Dörfler BMessage* into_message)
95c9c07d81Sbeveloper {
9600cffa1cSbeveloper // no config yet
97ea83877fSbeveloper return B_ERROR;
9800cffa1cSbeveloper }
9900cffa1cSbeveloper
100a9cf57cfSAxel Dörfler
101c9c07d81Sbeveloper bool
WantsAutoStart()102c9c07d81Sbeveloper AudioMixerAddon::WantsAutoStart()
103c9c07d81Sbeveloper {
104c9c07d81Sbeveloper return true;
105c9c07d81Sbeveloper }
106c9c07d81Sbeveloper
107a9cf57cfSAxel Dörfler
108c9c07d81Sbeveloper status_t
AutoStart(int in_index,BMediaNode ** out_node,int32 * out_internal_id,bool * out_has_more)109c9c07d81Sbeveloper AudioMixerAddon::AutoStart(int in_index, BMediaNode **out_node,
110c9c07d81Sbeveloper int32 *out_internal_id, bool *out_has_more)
111c9c07d81Sbeveloper {
112c9c07d81Sbeveloper *out_has_more = false;
113c9c07d81Sbeveloper
114c9c07d81Sbeveloper if (in_index != 0)
115c9c07d81Sbeveloper return B_ERROR;
116c9c07d81Sbeveloper
117c9c07d81Sbeveloper *out_internal_id = 0;
1181165d5e1Sbeveloper AudioMixer *mixer = new AudioMixer(this, true);
119545124e6Sbeveloper *out_node = mixer;
120545124e6Sbeveloper
121c9c07d81Sbeveloper return B_OK;
122c9c07d81Sbeveloper }
123