tone_producer_demo: automatic whitespace cleanup.

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