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