xref: /haiku/src/apps/cortex/addons/AudioAdapter/AudioAdapterAddOn.cpp (revision 579f1dbca962a2a03df54f69fdc6e9423f91f20e)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // AudioAdapterAddOn.cpp
33 
34 #include "AudioAdapterAddOn.h"
35 
36 #include "AudioAdapterNode.h"
37 //#include "AudioFilterNode.h"
38 #include "AudioAdapterOp.h"
39 
40 #include <Entry.h>
41 #include <Debug.h>
42 #include <cstring>
43 #include <cstdlib>
44 #include <cstdio>
45 
46 // -------------------------------------------------------- //
47 // instantiation function
48 // -------------------------------------------------------- //
49 
50 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
51 	return new AudioAdapterAddOn(image);
52 }
53 
54 // -------------------------------------------------------- //
55 // main() stub
56 // -------------------------------------------------------- //
57 
58 int main() {
59 	fputs("[AudioAdapter.media_addon]", stderr);
60 	return 1;
61 }
62 
63 // -------------------------------------------------------- //
64 // ctor/dtor
65 // -------------------------------------------------------- //
66 
67 //AudioAdapterAddOn::~AudioAdapterAddOn() {}
68 AudioAdapterAddOn::AudioAdapterAddOn(image_id id) :
69 	BMediaAddOn(id) {}
70 
71 // -------------------------------------------------------- //
72 // BMediaAddOn impl
73 // -------------------------------------------------------- //
74 
75 status_t AudioAdapterAddOn::InitCheck(
76 	const char** out_failure_text) {
77 	return B_OK;
78 }
79 
80 int32 AudioAdapterAddOn::CountFlavors() {
81 	return 1;
82 }
83 
84 status_t AudioAdapterAddOn::GetFlavorAt(
85 	int32 n,
86 	const flavor_info** out_info) {
87 	if(n)
88 		return B_ERROR;
89 
90 	flavor_info* pInfo = new flavor_info;
91 	pInfo->internal_id = n;
92 	pInfo->name = (char *)"AudioAdapter";
93 	pInfo->info = (char *)
94 		"AudioAdapter (generic raw-audio format conversion).\n"
95 		"by Eric Moon (8 September 1999)";
96 	pInfo->kinds = B_BUFFER_CONSUMER | B_BUFFER_PRODUCER | B_CONTROLLABLE;
97 	pInfo->flavor_flags = 0;
98 	pInfo->possible_count = 0;
99 
100 	pInfo->in_format_count = 1;
101 	media_format* pFormat = new media_format;
102 	pFormat->type = B_MEDIA_RAW_AUDIO;
103 	pFormat->u.raw_audio = media_raw_audio_format::wildcard;
104 	pInfo->in_formats = pFormat;
105 
106 	pInfo->out_format_count = 1;
107 	pFormat = new media_format;
108 	pFormat->type = B_MEDIA_RAW_AUDIO;
109 	pFormat->u.raw_audio = media_raw_audio_format::wildcard;
110 	pInfo->out_formats = pFormat;
111 
112 	*out_info = pInfo;
113 	return B_OK;
114 }
115 
116 BMediaNode* AudioAdapterAddOn::InstantiateNodeFor(
117 	const flavor_info* info,
118 	BMessage* config,
119 	status_t* out_error) {
120 
121 	return new _AudioAdapterNode(
122 		"AudioAdapter",
123 		new AudioAdapterOpFactory(),
124 		this);
125 }
126 
127 status_t AudioAdapterAddOn::GetConfigurationFor(
128 	BMediaNode* your_node,
129 	BMessage* into_message) {
130 
131 	// no config yet
132 	return B_OK;
133 }
134 
135 
136 // END -- AudioAdapterAddOn.cpp --
137