Some coding style updates by Vasilis Kaoutsis - one step after the other :-)
Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20788 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
006e498fa9
commit
f37b1856a9
@ -13,67 +13,51 @@
|
||||
__USE_CORTEX_NAMESPACE
|
||||
using namespace addon_host;
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// *** implementation
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
App app;
|
||||
if(argc < 2 || strcmp(argv[1], "--addon-host") != 0)
|
||||
{
|
||||
int32 response = (new BAlert(
|
||||
"Cortex AddOnHost",
|
||||
"This program runs in the background, and is started automatically "
|
||||
"by Cortex when necessary. You probably don't want to start it manually.",
|
||||
"Continue", "Quit"))->Go();
|
||||
if(response == 1)
|
||||
return 0;
|
||||
}
|
||||
app.Run();
|
||||
return 0;
|
||||
App::App()
|
||||
: BApplication(g_appSignature)
|
||||
{
|
||||
}
|
||||
|
||||
App::~App() {}
|
||||
App::App() :
|
||||
BApplication(g_appSignature) {}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// *** BLooper
|
||||
// -------------------------------------------------------- //
|
||||
App::~App()
|
||||
{
|
||||
}
|
||||
|
||||
bool App::QuitRequested() {
|
||||
|
||||
bool
|
||||
App::QuitRequested()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// *** BHandler
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
void App::MessageReceived(
|
||||
BMessage* message) {
|
||||
|
||||
void
|
||||
App::MessageReceived(BMessage* message)
|
||||
{
|
||||
status_t err;
|
||||
|
||||
// message->PrintToStream();
|
||||
|
||||
switch(message->what) {
|
||||
case M_INSTANTIATE: {
|
||||
case M_INSTANTIATE:
|
||||
{
|
||||
// fetch node info
|
||||
dormant_node_info info;
|
||||
const void *data;
|
||||
ssize_t dataSize;
|
||||
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
||||
if(err < B_OK) {
|
||||
if (err < B_OK) {
|
||||
PRINT((
|
||||
"!!! App::MessageReceived(M_INSTANTIATE):\n"
|
||||
" missing 'info'\n"));
|
||||
break;
|
||||
}
|
||||
if(dataSize != sizeof(info)) {
|
||||
if (dataSize != sizeof(info)) {
|
||||
PRINT((
|
||||
"* App::MessageReceived(M_INSTANTIATE):\n"
|
||||
" warning: 'info' size mismatch\n"));
|
||||
if(dataSize > ssize_t(sizeof(info)))
|
||||
if (dataSize > ssize_t(sizeof(info)))
|
||||
dataSize = sizeof(info);
|
||||
}
|
||||
memcpy(reinterpret_cast<void *>(&info), data, dataSize);
|
||||
@ -81,16 +65,14 @@ void App::MessageReceived(
|
||||
// attempt to instantiate
|
||||
BMediaRoster* r = BMediaRoster::Roster();
|
||||
media_node node;
|
||||
err = r->InstantiateDormantNode(
|
||||
info,
|
||||
&node);
|
||||
err = r->InstantiateDormantNode(info, &node);
|
||||
|
||||
// if(err == B_OK)
|
||||
// // reference it
|
||||
// err = r->GetNodeFor(node.node, &node);
|
||||
|
||||
// send status
|
||||
if(err == B_OK) {
|
||||
if (err == B_OK) {
|
||||
BMessage m(M_INSTANTIATE_COMPLETE);
|
||||
m.AddInt32("node_id", node.node);
|
||||
message->SendReply(&m);
|
||||
@ -100,22 +82,24 @@ void App::MessageReceived(
|
||||
m.AddInt32("error", err);
|
||||
message->SendReply(&m);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case M_RELEASE: {
|
||||
break;
|
||||
}
|
||||
|
||||
case M_RELEASE:
|
||||
{
|
||||
// fetch node info
|
||||
live_node_info info;
|
||||
const void *data;
|
||||
ssize_t dataSize;
|
||||
err = message->FindData("info", B_RAW_TYPE, &data, &dataSize);
|
||||
if(err < B_OK) {
|
||||
if (err < B_OK) {
|
||||
PRINT((
|
||||
"!!! App::MessageReceived(M_RELEASE):\n"
|
||||
" missing 'info'\n"));
|
||||
break;
|
||||
}
|
||||
if(dataSize != sizeof(info)) {
|
||||
if (dataSize != sizeof(info)) {
|
||||
PRINT((
|
||||
"* App::MessageReceived(M_RELEASE):\n"
|
||||
" warning: 'info' size mismatch\n"));
|
||||
@ -130,7 +114,7 @@ void App::MessageReceived(
|
||||
err = r->ReleaseNode(info.node);
|
||||
|
||||
// send status
|
||||
if(err == B_OK) {
|
||||
if (err == B_OK) {
|
||||
BMessage m(M_RELEASE_COMPLETE);
|
||||
m.AddInt32("node_id", info.node.node);
|
||||
message->SendReply(&m);
|
||||
@ -140,13 +124,29 @@ void App::MessageReceived(
|
||||
m.AddInt32("error", err);
|
||||
message->SendReply(&m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
_inherited::MessageReceived(message);
|
||||
}
|
||||
}
|
||||
|
||||
// END -- AddOnHostApp.cpp --
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
App app;
|
||||
if (argc < 2 || strcmp(argv[1], "--addon-host") != 0) {
|
||||
int32 response = (new BAlert(
|
||||
"Cortex AddOnHost",
|
||||
"This program runs in the background, and is started automatically "
|
||||
"by Cortex when necessary. You probably don't want to start it manually.",
|
||||
"Continue", "Quit"))->Go();
|
||||
if(response == 1)
|
||||
return 0;
|
||||
}
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,38 +8,34 @@
|
||||
//
|
||||
// * HISTORY
|
||||
// e.moon 6nov99
|
||||
#ifndef NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||
#define NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||
|
||||
#ifndef __NodeManager_AddOnHostApp_H__
|
||||
#define __NodeManager_AddOnHostApp_H__
|
||||
|
||||
#include "cortex_defs.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <MediaAddOn.h>
|
||||
#include <MediaDefs.h>
|
||||
|
||||
#include "cortex_defs.h"
|
||||
|
||||
__BEGIN_CORTEX_NAMESPACE
|
||||
namespace addon_host {
|
||||
|
||||
class App :
|
||||
public BApplication {
|
||||
class App:public BApplication {
|
||||
typedef BApplication _inherited;
|
||||
|
||||
public: // *** implementation
|
||||
~App();
|
||||
App();
|
||||
public:
|
||||
~App();
|
||||
App();
|
||||
|
||||
public: // *** BLooper
|
||||
bool QuitRequested();
|
||||
|
||||
public: // *** BHandler
|
||||
void MessageReceived(
|
||||
BMessage* message);
|
||||
|
||||
private: // implementation
|
||||
public:
|
||||
bool QuitRequested();
|
||||
void MessageReceived(BMessage* message);
|
||||
|
||||
};
|
||||
|
||||
}; // addon_host
|
||||
} // addon_host
|
||||
__END_CORTEX_NAMESPACE
|
||||
#endif /*__NodeManager_AddOnHostApp_H__*/
|
||||
|
||||
#endif // NODE_MANAGER_ADD_ON_HOST_APP_H
|
||||
|
@ -8,43 +8,32 @@
|
||||
//
|
||||
// * HISTORY
|
||||
// e.moon 8sep99 Begun
|
||||
#ifndef AUDIO_ADAPTER_ADD_ON_H
|
||||
#define AUDIO_ADAPTER_ADD_ON_H
|
||||
|
||||
#ifndef __AudioAdapterAddOn_H__
|
||||
#define __AudioAdapterAddOn_H__
|
||||
|
||||
#include <MediaAddOn.h>
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
class AudioAdapterAddOn :
|
||||
public BMediaAddOn {
|
||||
typedef BMediaAddOn _inherited;
|
||||
|
||||
public: // ctor/dtor
|
||||
// virtual ~AudioAdapterAddOn();
|
||||
explicit AudioAdapterAddOn(image_id image);
|
||||
class AudioAdapterAddOn : public BMediaAddOn {
|
||||
typedef BMediaAddOn _inherited;
|
||||
|
||||
public: // BMediaAddOn impl
|
||||
virtual status_t InitCheck(
|
||||
const char** out_failure_text);
|
||||
virtual int32 CountFlavors();
|
||||
virtual status_t GetFlavorAt(
|
||||
int32 n,
|
||||
const flavor_info ** out_info);
|
||||
virtual BMediaNode * InstantiateNodeFor(
|
||||
const flavor_info * info,
|
||||
BMessage * config,
|
||||
status_t * out_error);
|
||||
virtual status_t GetConfigurationFor(
|
||||
BMediaNode * your_node,
|
||||
BMessage * into_message);
|
||||
public:
|
||||
//virtual ~AudioAdapterAddOn();
|
||||
explicit AudioAdapterAddOn(image_id image);
|
||||
|
||||
virtual bool WantsAutoStart() { return false; }
|
||||
virtual status_t AutoStart(
|
||||
int in_count,
|
||||
BMediaNode ** out_node,
|
||||
int32 * out_internal_id,
|
||||
bool * out_has_more) { return B_OK; }
|
||||
public: // BMediaAddOn impl
|
||||
virtual status_t InitCheck(const char** out_failure_text);
|
||||
virtual int32 CountFlavors();
|
||||
virtual status_t GetFlavorAt(int32 n, const flavor_info** out_info);
|
||||
virtual BMediaNode* InstantiateNodeFor(const flavor_info* info,
|
||||
BMessage* config, status_t* out_error);
|
||||
virtual status_t GetConfigurationFor(BMediaNode* your_node,
|
||||
BMessage* into_message);
|
||||
|
||||
virtual bool WantsAutoStart() { return false; }
|
||||
virtual status_t AutoStart(int in_count, BMediaNode** out_node,
|
||||
int32* out_internal_id, bool* out_has_more) { return B_OK; }
|
||||
};
|
||||
|
||||
#endif /*__AudioAdapterAddOn_H__*/
|
||||
#endif // AUDIO_ADAPTER_ADD_ON_H
|
||||
|
@ -1,75 +1,58 @@
|
||||
// AudioAdapterNode.h
|
||||
#ifndef AUDIO_ADAPTER_NODE_H
|
||||
#define AUDIO_ADAPTER_NODE_H
|
||||
|
||||
#ifndef __AudioAdapterNode_H__
|
||||
#define __AudioAdapterNode_H__
|
||||
|
||||
#include "AudioFilterNode.h"
|
||||
#include "AudioAdapterParams.h"
|
||||
|
||||
class _AudioAdapterNode :
|
||||
public AudioFilterNode
|
||||
{
|
||||
|
||||
class _AudioAdapterNode : public AudioFilterNode {
|
||||
typedef AudioFilterNode _inherited;
|
||||
|
||||
public: // ctor/dtor
|
||||
virtual ~_AudioAdapterNode();
|
||||
_AudioAdapterNode(
|
||||
const char* name,
|
||||
IAudioOpFactory* opFactory,
|
||||
BMediaAddOn* addOn=0);
|
||||
public: // ctor/dtor
|
||||
virtual ~_AudioAdapterNode();
|
||||
_AudioAdapterNode(const char* name, IAudioOpFactory* opFactory,
|
||||
BMediaAddOn* addOn = 0);
|
||||
|
||||
public: // AudioFilterNode
|
||||
status_t getRequiredInputFormat(
|
||||
media_format& ioFormat);
|
||||
status_t getPreferredInputFormat(
|
||||
media_format& ioFormat);
|
||||
|
||||
status_t getRequiredOutputFormat(
|
||||
media_format& ioFormat);
|
||||
|
||||
status_t getPreferredOutputFormat(
|
||||
media_format& ioFormat);
|
||||
|
||||
status_t validateProposedInputFormat(
|
||||
const media_format& preferredFormat,
|
||||
media_format& ioProposedFormat);
|
||||
public: // AudioFilterNode
|
||||
status_t getRequiredInputFormat(media_format& ioFormat);
|
||||
status_t getPreferredInputFormat(media_format& ioFormat);
|
||||
status_t getRequiredOutputFormat(media_format& ioFormat);
|
||||
|
||||
status_t validateProposedOutputFormat(
|
||||
const media_format& preferredFormat,
|
||||
media_format& ioProposedFormat);
|
||||
status_t getPreferredOutputFormat(media_format& ioFormat);
|
||||
|
||||
virtual void SetParameterValue(
|
||||
int32 id,
|
||||
bigtime_t changeTime,
|
||||
const void* value,
|
||||
size_t size); //nyi
|
||||
status_t validateProposedInputFormat(
|
||||
const media_format& preferredFormat,
|
||||
media_format& ioProposedFormat);
|
||||
|
||||
public: // BBufferProducer/Consumer
|
||||
status_t validateProposedOutputFormat(
|
||||
const media_format& preferredFormat,
|
||||
media_format& ioProposedFormat);
|
||||
|
||||
virtual status_t Connected(
|
||||
const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format& format,
|
||||
media_input* outInput);
|
||||
virtual void SetParameterValue(int32 id, bigtime_t changeTime,
|
||||
const void* value, size_t size); //nyi
|
||||
|
||||
virtual void Connect(
|
||||
status_t status,
|
||||
const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format& format,
|
||||
char* ioName);
|
||||
|
||||
private:
|
||||
void _attemptInputFormatChange(
|
||||
public: // BBufferProducer/Consumer
|
||||
virtual status_t Connected(const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format& format,
|
||||
media_input* outInput);
|
||||
|
||||
virtual void Connect(status_t status, const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format& format,
|
||||
char* ioName);
|
||||
|
||||
private:
|
||||
void _attemptInputFormatChange(
|
||||
const media_multi_audio_format& format); //nyi
|
||||
|
||||
void _attemptOutputFormatChange(
|
||||
const media_multi_audio_format& format); //nyi
|
||||
void _attemptOutputFormatChange(
|
||||
const media_multi_audio_format& format); //nyi
|
||||
|
||||
void _broadcastInputFormatParams();
|
||||
void _broadcastOutputFormatParams();
|
||||
void _broadcastInputFormatParams();
|
||||
void _broadcastOutputFormatParams();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /*__AudioAdapterNode_H__*/
|
||||
#endif // AUDIO_ADAPTER_NODE_H
|
||||
|
@ -5,17 +5,15 @@
|
||||
#include <Debug.h>
|
||||
#include <ParameterWeb.h>
|
||||
|
||||
status_t _AudioAdapterParams::store(
|
||||
int32 parameterID,
|
||||
const void* data,
|
||||
size_t size) {
|
||||
|
||||
if(size < sizeof(int32))
|
||||
status_t
|
||||
_AudioAdapterParams::store(parameterID, const void* data, size_t size)
|
||||
{
|
||||
if (size < sizeof(int32))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
|
||||
const uint32 d = *(uint32*)data;
|
||||
|
||||
switch(parameterID) {
|
||||
|
||||
switch (parameterID) {
|
||||
// input format restrictions (0='wildcard')
|
||||
case P_INPUT_FORMAT:
|
||||
inputFormat.format = d;
|
||||
|
@ -1,47 +1,39 @@
|
||||
// AudioAdapterParams.h
|
||||
#ifndef AUDIO_ADAPTER_PARAMS_H
|
||||
#define AUDIO_ADAPTER_PARAMS_H
|
||||
|
||||
#ifndef __AudioAdapterParams_H__
|
||||
#define __AudioAdapterParams_H__
|
||||
|
||||
#include <MediaDefs.h>
|
||||
|
||||
#include "IParameterSet.h"
|
||||
|
||||
class _AudioAdapterParams :
|
||||
public IParameterSet {
|
||||
public:
|
||||
enum parameter_id {
|
||||
// input format restrictions (0='wildcard')
|
||||
P_INPUT_FORMAT =101,
|
||||
P_INPUT_CHANNEL_COUNT,
|
||||
|
||||
// output format restrictions (0='wildcard')
|
||||
P_OUTPUT_FORMAT =201,
|
||||
P_OUTPUT_CHANNEL_COUNT
|
||||
};
|
||||
|
||||
public:
|
||||
_AudioAdapterParams() :
|
||||
inputFormat(media_raw_audio_format::wildcard),
|
||||
outputFormat(media_raw_audio_format::wildcard) {}
|
||||
|
||||
status_t store(
|
||||
int32 parameterID,
|
||||
const void* data,
|
||||
size_t size);
|
||||
#include <MediaDefs.h>
|
||||
|
||||
status_t retrieve(
|
||||
int32 parameterID,
|
||||
void* data,
|
||||
size_t* ioSize);
|
||||
|
||||
void populateGroup(
|
||||
BParameterGroup* group);
|
||||
|
||||
public: // accessible parameters
|
||||
class _AudioAdapterParams : public IParameterSet {
|
||||
public:
|
||||
enum parameter_id {
|
||||
// input format restrictions (0 = 'wildcard')
|
||||
P_INPUT_FORMAT = 101,
|
||||
P_INPUT_CHANNEL_COUNT,
|
||||
|
||||
media_multi_audio_format inputFormat;
|
||||
media_multi_audio_format outputFormat;
|
||||
// output format restrictions (0 = 'wildcard')
|
||||
P_OUTPUT_FORMAT = 201,
|
||||
P_OUTPUT_CHANNEL_COUNT
|
||||
};
|
||||
|
||||
public:
|
||||
_AudioAdapterParams()
|
||||
:
|
||||
inputFormat(media_raw_audio_format::wildcard),
|
||||
outputFormat(media_raw_audio_format::wildcard)
|
||||
{}
|
||||
|
||||
status_t store(int32 parameterID, const void* data, size_t size);
|
||||
status_t retrieve(int32 parameterID, void* data, size_t* ioSize);
|
||||
void populateGroup(BParameterGroup* group);
|
||||
|
||||
public: // accessible parameters
|
||||
media_multi_audio_format inputFormat;
|
||||
media_multi_audio_format outputFormat;
|
||||
};
|
||||
|
||||
#endif /*__AudioAdapterParams_H__*/
|
||||
#endif // AUDIO_ADAPTER_PARAMS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user