xref: /haiku/src/add-ons/media/media-add-ons/tone_producer_demo/ToneProducerAddOn.cpp (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
1 /* Written by Eric Moon, from the Cortex Source code archive.
2  * Distributed under the terms of the Be Sample Code License
3  */
4 
5 // ToneProducerAddOn.cpp
6 // e.moon 4jun99
7 
8 #include "ToneProducer.h"
9 #include "ToneProducerAddOn.h"
10 #include <cstring>
11 #include <cstdlib>
12 
13 // instantiation function
14 extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
15 	return new ToneProducerAddOn(image);
16 }
17 
18 // -------------------------------------------------------- //
19 // ctor/dtor
20 // -------------------------------------------------------- //
21 
22 ToneProducerAddOn::~ToneProducerAddOn() {}
23 ToneProducerAddOn::ToneProducerAddOn(image_id image) :
24 	BMediaAddOn(image) {}
25 
26 // -------------------------------------------------------- //
27 // BMediaAddOn impl
28 // -------------------------------------------------------- //
29 
30 status_t ToneProducerAddOn::InitCheck(
31 	const char** out_failure_text) {
32 	return B_OK;
33 }
34 
35 int32 ToneProducerAddOn::CountFlavors() {
36 	return 1;
37 }
38 
39 status_t ToneProducerAddOn::GetFlavorAt(
40 	int32 n,
41 	const flavor_info** out_info) {
42 	if(n)
43 		return B_ERROR;
44 
45 	flavor_info* pInfo = new flavor_info;
46 	pInfo->internal_id = n;
47 	pInfo->name = "Demo Audio Producer";
48 	pInfo->info = "An add-on version of the ToneProducer node.\n"
49 		"See the Be Developer Newsletter: 2 June, 1999\n"
50 		"adapted by Eric Moon (4 June, 1999)";
51 	pInfo->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE;
52 	pInfo->flavor_flags = 0;
53 	pInfo->possible_count = 0;
54 
55 	pInfo->in_format_count = 0;
56 	pInfo->in_formats = 0;
57 
58 	pInfo->out_format_count = 1;
59 	media_format* pFormat = new media_format;
60 	pFormat->type = B_MEDIA_RAW_AUDIO;
61 	pFormat->u.raw_audio = media_raw_audio_format::wildcard;
62 	pInfo->out_formats = pFormat;
63 
64 	*out_info = pInfo;
65 	return B_OK;
66 }
67 
68 BMediaNode* ToneProducerAddOn::InstantiateNodeFor(
69 	const flavor_info* info,
70 	BMessage* config,
71 	status_t* out_error) {
72 
73 	return new ToneProducer(this);
74 }
75 
76 status_t ToneProducerAddOn::GetConfigurationFor(
77 	BMediaNode* your_node,
78 	BMessage* into_message) {
79 
80 	// no config yet
81 	return B_OK;
82 }
83 
84 // END -- ToneProducerAddOn.cpp
85