tone_producer_demo: automatic whitespace cleanup.
This commit is contained in:
parent
a478bc0582
commit
7729bad4bd
@ -119,7 +119,7 @@ ToneProducer::AddOn(int32 *internal_id) const
|
||||
//#pragma mark -
|
||||
|
||||
// BControllable methods
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::GetParameterValue(int32 id, bigtime_t* last_change, void* value, size_t* ioSize)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::GetParameterValue\n");
|
||||
@ -161,7 +161,7 @@ ToneProducer::GetParameterValue(int32 id, bigtime_t* last_change, void* value, s
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::SetParameterValue(int32 id, bigtime_t performance_time, const void* value, size_t size)
|
||||
{
|
||||
switch (id)
|
||||
@ -194,14 +194,14 @@ status_t ToneProducer::StartControlPanel(
|
||||
if(pMessenger && pMessenger->IsValid()) {
|
||||
PRINT(("\tgot valid control panel\n"));
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
//#pragma mark -
|
||||
|
||||
// BBufferProducer methods
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::FormatSuggestionRequested(media_type type, int32 /*quality*/, media_format* format)
|
||||
{
|
||||
// FormatSuggestionRequested() is not necessarily part of the format negotiation
|
||||
@ -226,7 +226,7 @@ ToneProducer::FormatSuggestionRequested(media_type type, int32 /*quality*/, medi
|
||||
else return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::FormatProposal(const media_source& output, media_format* format)
|
||||
{
|
||||
// FormatProposal() is the first stage in the BMediaRoster::Connect() process. We hand
|
||||
@ -242,7 +242,7 @@ ToneProducer::FormatProposal(const media_source& output, media_format* format)
|
||||
|
||||
// we only support floating-point raw audio, so we always return that, but we
|
||||
// supply an error code depending on whether we found the proposal acceptable.
|
||||
|
||||
|
||||
media_type requestedType = format->type;
|
||||
*format = mPreferredFormat;
|
||||
if ((requestedType != B_MEDIA_UNKNOWN_TYPE) && (requestedType != B_MEDIA_RAW_AUDIO))
|
||||
@ -253,7 +253,7 @@ ToneProducer::FormatProposal(const media_source& output, media_format* format)
|
||||
else return B_OK; // raw audio or wildcard type, either is okay by us
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::FormatChangeRequested(const media_source& source, const media_destination& destination, media_format* io_format, int32* _deprecated_)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::FormatChangeRequested\n");
|
||||
@ -262,7 +262,7 @@ ToneProducer::FormatChangeRequested(const media_source& source, const media_dest
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::GetNextOutput(int32* cookie, media_output* out_output)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::GetNextOutput\n");
|
||||
@ -279,7 +279,7 @@ ToneProducer::GetNextOutput(int32* cookie, media_output* out_output)
|
||||
else return B_BAD_INDEX;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::DisposeOutputCookie(int32 cookie)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::DisposeOutputCookie\n");
|
||||
@ -288,7 +288,7 @@ ToneProducer::DisposeOutputCookie(int32 cookie)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::SetBufferGroup(const media_source& for_source, BBufferGroup* newGroup)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::SetBufferGroup\n");
|
||||
@ -323,7 +323,7 @@ ToneProducer::SetBufferGroup(const media_source& for_source, BBufferGroup* newGr
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::GetLatency(bigtime_t* out_latency)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::GetLatency\n");
|
||||
@ -333,7 +333,7 @@ ToneProducer::GetLatency(bigtime_t* out_latency)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::PrepareToConnect(const media_source& what, const media_destination& where, media_format* format, media_source* out_source, char* out_name)
|
||||
{
|
||||
// PrepareToConnect() is the second stage of format negotiations that happens
|
||||
@ -366,7 +366,7 @@ ToneProducer::PrepareToConnect(const media_source& what, const media_destination
|
||||
format->u.raw_audio.channel_count = 2;
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !!! validate all other fields except for buffer_size here, because the consumer might have
|
||||
// supplied different values from AcceptFormat()?
|
||||
@ -399,13 +399,13 @@ ToneProducer::PrepareToConnect(const media_source& what, const media_destination
|
||||
{
|
||||
FPRINTF(stderr, "\tconsumer suggested buffer_size %lu\n", format->u.raw_audio.buffer_size);
|
||||
}
|
||||
|
||||
|
||||
// Now reserve the connection, and return information about it
|
||||
mOutput.destination = where;
|
||||
mOutput.format = *format;
|
||||
*out_source = mOutput.source;
|
||||
strncpy(out_name, mOutput.name, B_MEDIA_NAME_LENGTH);
|
||||
|
||||
|
||||
char formatStr[256];
|
||||
string_for_format(*format, formatStr, 255);
|
||||
FPRINTF(stderr, "\treturning format: %s\n", formatStr);
|
||||
@ -413,7 +413,7 @@ ToneProducer::PrepareToConnect(const media_source& what, const media_destination
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::Connect(status_t error, const media_source& source, const media_destination& destination, const media_format& format, char* io_name)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::Connect\n");
|
||||
@ -440,7 +440,7 @@ ToneProducer::Connect(status_t error, const media_source& source, const media_de
|
||||
// FPRINTF(stderr, "\tcorrupted format; falling back to last suggested format\n");
|
||||
// format = mOutput.format;
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
// Okay, the connection has been confirmed. Record the destination and format
|
||||
// that we agreed on, and report our connection name again.
|
||||
@ -476,7 +476,7 @@ ToneProducer::Connect(status_t error, const media_source& source, const media_de
|
||||
// reset our buffer duration, etc. to avoid later calculations
|
||||
// +++++ e.moon 11jun99: crashes w/ divide-by-zero when connecting to LoggingConsumer
|
||||
ASSERT(mOutput.format.u.raw_audio.frame_rate);
|
||||
|
||||
|
||||
bigtime_t duration = bigtime_t(1000000) * samplesPerBuffer / bigtime_t(mOutput.format.u.raw_audio.frame_rate);
|
||||
SetBufferDuration(duration);
|
||||
|
||||
@ -487,7 +487,7 @@ ToneProducer::Connect(status_t error, const media_source& source, const media_de
|
||||
if (!mBufferGroup) AllocateBuffers();
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::Disconnect(const media_source& what, const media_destination& where)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::Disconnect\n");
|
||||
@ -508,7 +508,7 @@ ToneProducer::Disconnect(const media_source& what, const media_destination& wher
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much, bigtime_t performance_time)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::LateNoticeReceived\n");
|
||||
@ -552,7 +552,7 @@ ToneProducer::LateNoticeReceived(const media_source& what, bigtime_t how_much, b
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::EnableOutput(const media_source& what, bool enabled, int32* _deprecated_)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::EnableOutput\n");
|
||||
@ -567,7 +567,7 @@ ToneProducer::EnableOutput(const media_source& what, bool enabled, int32* _depre
|
||||
}
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::SetPlayRate(int32 numer, int32 denom)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::SetPlayRate\n");
|
||||
@ -577,7 +577,7 @@ ToneProducer::SetPlayRate(int32 numer, int32 denom)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
status_t
|
||||
ToneProducer::HandleMessage(int32 message, const void* data, size_t size)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::HandleMessage(%" B_PRId32 " = 0x%" B_PRIx32
|
||||
@ -591,7 +591,7 @@ ToneProducer::HandleMessage(int32 message, const void* data, size_t size)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::AdditionalBufferRequested(const media_source& source, media_buffer_id prev_buffer, bigtime_t prev_time, const media_seek_tag* prev_tag)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::AdditionalBufferRequested\n");
|
||||
@ -600,7 +600,7 @@ ToneProducer::AdditionalBufferRequested(const media_source& source, media_buffer
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::LatencyChanged(
|
||||
const media_source& source,
|
||||
const media_destination& destination,
|
||||
@ -624,7 +624,7 @@ ToneProducer::LatencyChanged(
|
||||
//#pragma mark -
|
||||
|
||||
// BMediaEventLooper methods
|
||||
void
|
||||
void
|
||||
ToneProducer::NodeRegistered()
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::NodeRegistered\n");
|
||||
@ -641,7 +641,7 @@ ToneProducer::NodeRegistered()
|
||||
SetParameterWeb(mWeb);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::Start(bigtime_t performance_time)
|
||||
{
|
||||
PRINT(("ToneProducer::Start(%" B_PRIdBIGTIME "): now %" B_PRIdBIGTIME "\n",
|
||||
@ -656,7 +656,7 @@ ToneProducer::Start(bigtime_t performance_time)
|
||||
BMediaEventLooper::Start(performance_time);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::Stop(bigtime_t performance_time, bool immediate)
|
||||
{
|
||||
// send 'data not available' message
|
||||
@ -671,7 +671,7 @@ ToneProducer::Stop(bigtime_t performance_time, bool immediate)
|
||||
BMediaEventLooper::Stop(performance_time, immediate);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::SetRunMode(run_mode mode)
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::SetRunMode\n");
|
||||
@ -684,7 +684,7 @@ ToneProducer::SetRunMode(run_mode mode)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent)
|
||||
{
|
||||
// FPRINTF(stderr, "ToneProducer::HandleEvent\n");
|
||||
@ -813,11 +813,11 @@ ToneProducer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bo
|
||||
|
||||
//#pragma mark -
|
||||
|
||||
void
|
||||
void
|
||||
ToneProducer::AllocateBuffers()
|
||||
{
|
||||
FPRINTF(stderr, "ToneProducer::AllocateBuffers\n");
|
||||
|
||||
|
||||
// allocate enough buffers to span our downstream latency, plus one
|
||||
size_t size = mOutput.format.u.raw_audio.buffer_size;
|
||||
int32 count = int32(mLatency / BufferDuration() + 1 + 1);
|
||||
@ -844,7 +844,7 @@ ToneProducer::FillNextBuffer(bigtime_t event_time)
|
||||
|
||||
// now fill it with data, continuing where the last buffer left off
|
||||
// 20sep99: multichannel support
|
||||
|
||||
|
||||
size_t numFrames =
|
||||
mOutput.format.u.raw_audio.buffer_size /
|
||||
(sizeof(float)*mOutput.format.u.raw_audio.channel_count);
|
||||
@ -904,7 +904,7 @@ ToneProducer::FillNextBuffer(bigtime_t event_time)
|
||||
void
|
||||
ToneProducer::FillSineBuffer(float *data, size_t numFrames, bool stereo)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// cover 2pi radians in one period
|
||||
double dTheta = 2*M_PI * double(mFrequency) / mOutput.format.u.raw_audio.frame_rate;
|
||||
@ -918,7 +918,7 @@ ToneProducer::FillSineBuffer(float *data, size_t numFrames, bool stereo)
|
||||
++data;
|
||||
*data = val;
|
||||
}
|
||||
|
||||
|
||||
mTheta += dTheta;
|
||||
if (mTheta > 2*M_PI)
|
||||
{
|
||||
@ -943,7 +943,7 @@ ToneProducer::FillTriangleBuffer(float *data, size_t numFrames, bool stereo)
|
||||
++data;
|
||||
*data = val;
|
||||
}
|
||||
|
||||
|
||||
mTheta += dTheta;
|
||||
if (mTheta >= 1)
|
||||
{
|
||||
|
@ -3,16 +3,16 @@
|
||||
|
||||
Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||
This file may be used under the terms of the Be Sample Code License.
|
||||
|
||||
|
||||
NOTES eamoon@meadgroup.com 11june99
|
||||
- this node has some holes in it, but it's pretty useful starting
|
||||
point for writing producers.
|
||||
- I've tried to clean up the format negotiation a bit, which didn't
|
||||
fare too well when faced with an apathetic downstream node
|
||||
(LoggingConsumer.)
|
||||
|
||||
|
||||
KNOWN BUGS
|
||||
eamoon 17jun99
|
||||
eamoon 17jun99
|
||||
* Can't handle 2 channels, but is too polite to refuse.
|
||||
How embarrassing.
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
bigtime_t when,
|
||||
const void* value,
|
||||
size_t size);
|
||||
|
||||
|
||||
status_t StartControlPanel(
|
||||
BMessenger* pMessenger);
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
char* out_name);
|
||||
|
||||
void Connect(
|
||||
status_t error,
|
||||
status_t error,
|
||||
const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format& format,
|
||||
@ -196,7 +196,7 @@ private:
|
||||
bigtime_t mGainLastChanged;
|
||||
bigtime_t mFreqLastChanged;
|
||||
bigtime_t mWaveLastChanged;
|
||||
|
||||
|
||||
// host addon
|
||||
// [8jun99] e.moon
|
||||
BMediaAddOn* m_pAddOn;
|
||||
|
@ -22,7 +22,7 @@ extern "C" _EXPORT BMediaAddOn* make_media_addon(image_id image) {
|
||||
ToneProducerAddOn::~ToneProducerAddOn() {}
|
||||
ToneProducerAddOn::ToneProducerAddOn(image_id image) :
|
||||
BMediaAddOn(image) {}
|
||||
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// BMediaAddOn impl
|
||||
// -------------------------------------------------------- //
|
||||
@ -31,7 +31,7 @@ status_t ToneProducerAddOn::InitCheck(
|
||||
const char** out_failure_text) {
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
int32 ToneProducerAddOn::CountFlavors() {
|
||||
return 1;
|
||||
}
|
||||
@ -41,7 +41,7 @@ status_t ToneProducerAddOn::GetFlavorAt(
|
||||
const flavor_info** out_info) {
|
||||
if(n)
|
||||
return B_ERROR;
|
||||
|
||||
|
||||
flavor_info* pInfo = new flavor_info;
|
||||
pInfo->internal_id = n;
|
||||
pInfo->name = (char *)"Demo Audio Producer";
|
||||
@ -52,16 +52,16 @@ status_t ToneProducerAddOn::GetFlavorAt(
|
||||
pInfo->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE;
|
||||
pInfo->flavor_flags = 0;
|
||||
pInfo->possible_count = 0;
|
||||
|
||||
|
||||
pInfo->in_format_count = 0;
|
||||
pInfo->in_formats = 0;
|
||||
|
||||
|
||||
pInfo->out_format_count = 1;
|
||||
media_format* pFormat = new media_format;
|
||||
pFormat->type = B_MEDIA_RAW_AUDIO;
|
||||
pFormat->u.raw_audio = media_raw_audio_format::wildcard;
|
||||
pInfo->out_formats = pFormat;
|
||||
|
||||
|
||||
*out_info = pInfo;
|
||||
return B_OK;
|
||||
}
|
||||
@ -71,13 +71,13 @@ BMediaNode* ToneProducerAddOn::InstantiateNodeFor(
|
||||
BMessage* config,
|
||||
status_t* out_error) {
|
||||
|
||||
return new ToneProducer(this);
|
||||
return new ToneProducer(this);
|
||||
}
|
||||
|
||||
status_t ToneProducerAddOn::GetConfigurationFor(
|
||||
BMediaNode* your_node,
|
||||
BMessage* into_message) {
|
||||
|
||||
|
||||
// no config yet
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
class ToneProducerAddOn :
|
||||
public BMediaAddOn {
|
||||
typedef BMediaAddOn _inherited;
|
||||
|
||||
|
||||
public: // ctor/dtor
|
||||
virtual ~ToneProducerAddOn();
|
||||
explicit ToneProducerAddOn(image_id image);
|
||||
|
||||
|
||||
public: // BMediaAddOn impl
|
||||
virtual status_t InitCheck(
|
||||
const char** out_failure_text);
|
||||
|
Loading…
Reference in New Issue
Block a user