* Rewrote MediaRoster.h

* Removed appearantly unused satic variables. Hope this does not break
  binary compatibility, going to test.
* There are three more private methods, which could probably be removed
  as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24558 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-03-24 15:42:58 +00:00
parent a715f908f2
commit 9def3bf783
2 changed files with 339 additions and 396 deletions
+322 -375
View File
@@ -1,14 +1,12 @@
/******************************************************************************* /*
/ * Copyright (c) 2008 Haiku, Inc. All rights reserved.
/ File: MediaRoster.h * Distributed under the terms of the the MIT licence.
/ *
/ Description: The BMediaRoster is the main application interface to the Media Kit */
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_ROSTER_H) //! The BMediaRoster is the main API to the Media Kit.
#ifndef _MEDIA_ROSTER_H
#define _MEDIA_ROSTER_H #define _MEDIA_ROSTER_H
#include <MediaDefs.h> #include <MediaDefs.h>
@@ -20,6 +18,7 @@ class BMediaAddOn;
class BMimeType; class BMimeType;
class BParameterWeb; class BParameterWeb;
class BString; class BString;
struct dormant_flavor_info; struct dormant_flavor_info;
struct entry_ref; struct entry_ref;
@@ -28,409 +27,357 @@ namespace BPrivate { namespace media {
class BMediaRosterEx; class BMediaRosterEx;
} } // BPrivate::media } } // BPrivate::media
class BMediaRoster : public BLooper
{ class BMediaRoster : public BLooper {
public: public:
status_t GetVideoInput( // Retrieving the global instance of the BMediaRoster:
media_node * out_node); static BMediaRoster* Roster(status_t* _error = NULL);
status_t GetAudioInput( // This version will create a roster instance if there isn't
media_node * out_node); // one already. Thread safe for multiple calls to Roster().
status_t GetVideoOutput(
media_node * out_node);
status_t GetAudioMixer(
media_node * out_node);
status_t GetAudioOutput(
media_node * out_node); /* Use the mixer rather than the output for most needs! */
status_t GetAudioOutput(
media_node * out_node,
int32 * out_input_id,
BString * out_input_name);
status_t GetTimeSource(
media_node * out_node);
status_t SetVideoInput( static BMediaRoster* CurrentRoster();
const media_node & producer); // This version won't create an instance if there isn't one
status_t SetVideoInput( // already. It is not thread safe if you call Roster() at the
const dormant_node_info & producer); // same time.
status_t SetAudioInput(
const media_node & producer);
status_t SetAudioInput(
const dormant_node_info & producer);
status_t SetVideoOutput(
const media_node & consumer);
status_t SetVideoOutput(
const dormant_node_info & consumer);
status_t SetAudioOutput(
const media_node & consumer);
status_t SetAudioOutput(
const media_input & input_to_output);
status_t SetAudioOutput(
const dormant_node_info & consumer);
/* Get a media_node from a node ID -- this is how you reference your own nodes! */ // Getting common instances of system nodes:
status_t GetNodeFor( status_t GetVideoInput(media_node* _node);
media_node_id node, status_t GetAudioInput(media_node* _node);
media_node * clone); status_t GetVideoOutput(media_node* _node);
status_t GetSystemTimeSource( /* typically, you want to use GetTimeSource() */ status_t GetAudioMixer(media_node* _node);
media_node * clone); status_t GetAudioOutput(media_node* _node);
status_t ReleaseNode( /* might shut down Node if you're last */ // The output should not be used directly in common use cases.
const media_node & node); // Use the mixer node instead.
status_t GetAudioOutput(media_node* _node,
int32* _inputId, BString* _inputName);
status_t GetTimeSource(media_node* _node);
BTimeSource * MakeTimeSourceFor( /* Release() the object when done */ // Setting common system nodes:
const media_node & for_node); status_t SetVideoInput(const media_node& producer);
status_t SetVideoInput(
const dormant_node_info& producer);
/* note that the media_source and media_destination found in */ status_t SetAudioInput(const media_node& producer);
/* out_output and out_input are the ones actually used; from and to */ status_t SetAudioInput(
/* are only "hints" that the app should not use once a real connection */ const dormant_node_info& producer);
/* has been established */
status_t Connect( status_t SetVideoOutput(const media_node& consumer);
const media_source & from, status_t SetVideoOutput(
const media_destination & to, const dormant_node_info& consumer);
media_format * io_format,
media_output * out_output, status_t SetAudioOutput(
media_input * out_input); const media_node& consumer);
enum connect_flags { status_t SetAudioOutput(
B_CONNECT_MUTED = 0x1 const media_input& inputToOutput);
}; status_t SetAudioOutput(
const dormant_node_info& consumer);
// Get a media_node from a node ID -- this is how you reference your
// own nodes!
status_t GetNodeFor(media_node_id node,
media_node* clone);
status_t GetSystemTimeSource(media_node* clone);
// Typically, you'll want to use GetTimeSource() instead.
status_t ReleaseNode(const media_node& node);
// This method might free the node if there are no
// more references.
BTimeSource* MakeTimeSourceFor(const media_node& for_node);
// Release() the returned object when done!
status_t Connect(const media_source& from,
const media_destination& to,
media_format* _inOutFormat,
media_output* _output,
media_input* _input);
// Note that the media_source and media_destination found in
// _output and _input are the ones actually used. From and to
// are only "hints" that the app should not use once a real
// connection has been established.
enum connect_flags {
B_CONNECT_MUTED = 0x1
};
status_t Connect( status_t Connect(const media_source& from,
const media_source & from, const media_destination& to,
const media_destination & to, media_format* _inOutFormat,
media_format * io_format, media_output* _output,
media_output * out_output, media_input* _input,
media_input * out_input, uint32 flags, void* _reserved = NULL);
uint32 in_flags,
void * _reserved = 0);
status_t Disconnect( status_t Disconnect(media_node_id sourceNode,
media_node_id source_node, const media_source& source,
const media_source & source, media_node_id destinationNode,
media_node_id destination_node, const media_destination& destination);
const media_destination & destination);
status_t Disconnect( /* Haiku extension, not in R5 */
const media_output &output, status_t Disconnect(const media_output& output,
const media_input &input); const media_input& input);
// NOTE: This is a Haiku extension.
status_t StartNode( status_t StartNode(const media_node& node,
const media_node & node, bigtime_t atPerformanceTime);
bigtime_t at_performance_time); status_t StopNode(const media_node& node,
status_t StopNode( bigtime_t atPerformanceTime,
const media_node & node, bool immediate = false);
bigtime_t at_performance_time, // If "immediate" is true, "atPerformanceTime" is ignored.
bool immediate = false); /* immediate -> at_time is insignificant */ status_t SeekNode(const media_node& node,
status_t SeekNode( bigtime_t toMediaTime,
const media_node & node, bigtime_t atPerformanceTime = 0);
bigtime_t to_media_time, // NOTE: The node needs to be running.
bigtime_t at_performance_time = 0 /* if running */ );
status_t StartTimeSource( status_t StartTimeSource(const media_node& node,
const media_node & node, bigtime_t atRealTime);
bigtime_t at_real_time); status_t StopTimeSource(const media_node& node,
status_t StopTimeSource( bigtime_t atRealTime,
const media_node & node, bool immediate = false);
bigtime_t at_real_time, status_t SeekTimeSource(const media_node& node,
bool immediate = false); bigtime_t toPerformanceTime,
status_t SeekTimeSource( bigtime_t atRealTime);
const media_node & node,
bigtime_t to_performance_time,
bigtime_t at_real_time);
status_t SyncToNode( status_t SyncToNode(const media_node& node,
const media_node & node, bigtime_t atTime,
bigtime_t at_time, bigtime_t timeout = B_INFINITE_TIMEOUT);
bigtime_t timeout = B_INFINITE_TIMEOUT); status_t SetRunModeNode(const media_node& node,
status_t SetRunModeNode( BMediaNode::run_mode mode);
const media_node & node, status_t PrerollNode(const media_node& node);
BMediaNode::run_mode mode); // NOTE: This method is synchronous.
status_t PrerollNode( /* synchronous */ status_t RollNode(const media_node& node,
const media_node & node); bigtime_t startPerformance,
bigtime_t stopPerformance,
bigtime_t atMediaTime
= -B_INFINITE_TIMEOUT);
status_t RollNode( status_t SetProducerRunModeDelay(const media_node& node,
const media_node & node, bigtime_t delay,
bigtime_t startPerformance, BMediaNode::run_mode mode
bigtime_t stopPerformance, = BMediaNode::B_RECORDING);
bigtime_t atMediaTime = -B_INFINITE_TIMEOUT); // NOTE: Should only be used with B_RECORDING
status_t SetProducerRate(const media_node& producer,
int32 numer, int32 denom);
// NOTE: This feature is not necessarily supported by the node.
status_t SetProducerRunModeDelay( /* should only be used with B_RECORDING */ // Retrieving information about available inputs/outputs.
const media_node & node, // Nodes will have available inputs/outputs as long as they are capable
bigtime_t delay, // of accepting more connections. The node may create an additional
BMediaNode::run_mode mode = BMediaNode::B_RECORDING); // output or input as the currently available is taken into usage.
status_t SetProducerRate( /* not necessarily supported by node */ status_t GetLiveNodeInfo(const media_node& node,
const media_node & producer, live_node_info* _liveInfo);
int32 numer, status_t GetLiveNodes(live_node_info* _liveNodes,
int32 denom); int32* inOutTotalCount,
const media_format* hasInput = NULL,
const media_format* hasOutput = NULL,
const char* name = NULL,
uint64 nodeKinds = 0);
// B_BUFFER_PRODUCER etc.
/* Nodes will have available inputs/outputs as long as they are capable */ status_t GetFreeInputsFor(const media_node& node,
/* of accepting more connections. The node may create an additional */ media_input* _freeInputsBuffer,
/* output or input as the currently available is taken into usage. */ int32 bufferCapacity,
status_t GetLiveNodeInfo( int32* _foundCount,
const media_node & node, media_type filterType
live_node_info * out_live_info); = B_MEDIA_UNKNOWN_TYPE);
status_t GetLiveNodes( status_t GetConnectedInputsFor(const media_node& node,
live_node_info * out_live_nodes, media_input* _activeInputsBuffer,
int32 * io_total_count, int32 bufferCapacity,
const media_format * has_input = NULL, int32* _foundCount);
const media_format * has_output = NULL, status_t GetAllInputsFor(const media_node& node,
const char * name = NULL, media_input* _inputsBuffer,
uint64 node_kinds = 0); /* B_BUFFER_PRODUCER etc */ int32 bufferCapacity,
int32* _foundCount);
status_t GetFreeOutputsFor(const media_node& node,
media_output* _freeOutputsBuffer,
int32 bufferCapacity,
int32* _foundCount,
media_type filterType
= B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedOutputsFor(const media_node& node,
media_output* _activeOutputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t GetAllOutputsFor(const media_node& node,
media_output* _outputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t GetFreeInputsFor( // Event notification support:
const media_node & node, status_t StartWatching(const BMessenger& target);
media_input * out_free_inputs, status_t StartWatching(const BMessenger& target,
int32 buf_num_inputs, int32 notificationType);
int32 * out_total_count, status_t StartWatching(const BMessenger& target,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE); const media_node& node,
status_t GetConnectedInputsFor( int32 notificationType);
const media_node & node, status_t StopWatching(const BMessenger& target);
media_input * out_active_inputs, status_t StopWatching(const BMessenger& target,
int32 buf_num_inputs, int32 notificationType);
int32 * out_total_count); status_t StopWatching(const BMessenger& target,
status_t GetAllInputsFor( const media_node& node,
const media_node & node, int32 notificationType);
media_input * out_inputs,
int32 buf_num_inputs,
int32 * out_total_count);
status_t GetFreeOutputsFor(
const media_node & node,
media_output * out_free_outputs,
int32 buf_num_outputs,
int32 * out_total_count,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedOutputsFor(
const media_node & node,
media_output * out_active_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t GetAllOutputsFor(
const media_node & node,
media_output * out_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t StartWatching( status_t RegisterNode(BMediaNode* node);
const BMessenger & where); status_t UnregisterNode(BMediaNode* node);
status_t StartWatching(
const BMessenger & where,
int32 notificationType);
status_t StartWatching(
const BMessenger & where,
const media_node & node,
int32 notificationType);
status_t StopWatching(
const BMessenger & where);
status_t StopWatching(
const BMessenger & where,
int32 notificationType);
status_t StopWatching(
const BMessenger & where,
const media_node & node,
int32 notificationType);
status_t RegisterNode( status_t SetTimeSourceFor(media_node_id node,
BMediaNode * node); media_node_id timeSource);
status_t UnregisterNode(
BMediaNode * node);
static BMediaRoster * Roster( // will create if there isn't one // Building a control GUI for a node:
status_t * out_error = NULL); // thread safe for multiple calls to Roster() status_t GetParameterWebFor(const media_node& node,
static BMediaRoster * CurrentRoster(); // won't create it if there isn't one BParameterWeb** _web);
// not thread safe if you call Roster() at the same time status_t StartControlPanel(const media_node& node,
status_t SetTimeSourceFor( BMessenger* _messenger = NULL);
media_node_id node,
media_node_id time_source);
status_t GetParameterWebFor( // Information about nodes which are not running, but could
const media_node & node, // be instantiated from add-ons:
BParameterWeb ** out_web); status_t GetDormantNodes(dormant_node_info* _info,
status_t StartControlPanel( int32* _inOutCount,
const media_node & node, const media_format* _hasInput = NULL,
BMessenger * out_messenger = NULL); const media_format* _hasOutput = NULL,
const char* name = NULL,
uint64 requireKinds = 0,
uint64 denyKinds = 0);
status_t InstantiateDormantNode(
const dormant_node_info& info,
media_node* _node,
uint32 flags);
// NOTE: Supported flags are currently B_FLAVOR_IS_GLOBAL
// or B_FLAVOR_IS_LOCAL
status_t InstantiateDormantNode(
const dormant_node_info& info,
media_node* _node);
status_t GetDormantNodeFor(const media_node& node,
dormant_node_info* _info);
status_t GetDormantFlavorInfoFor(
const dormant_node_info& info,
dormant_flavor_info* _flavor);
status_t GetDormantNodes( // Latency information:
dormant_node_info * out_info, status_t GetLatencyFor(const media_node& producer,
int32 * io_count, bigtime_t* _latency);
const media_format * has_input = NULL, status_t GetInitialLatencyFor(
const media_format * has_output = NULL, const media_node& producer,
const char * name = NULL, bigtime_t* _latency,
uint64 require_kinds = 0, uint32* _flags = NULL);
uint64 deny_kinds = 0); status_t GetStartLatencyFor(
status_t InstantiateDormantNode( const media_node& timeSource,
const dormant_node_info & in_info, bigtime_t* _latency);
media_node * out_node,
uint32 flags /* currently B_FLAVOR_IS_GLOBAL or B_FLAVOR_IS_LOCAL */ );
status_t InstantiateDormantNode(
const dormant_node_info & in_info,
media_node * out_node);
status_t GetDormantNodeFor(
const media_node & node,
dormant_node_info * out_info);
status_t GetDormantFlavorInfoFor(
const dormant_node_info & in_dormant,
dormant_flavor_info * out_flavor);
status_t GetLatencyFor( // Finding a suitable node to playback a file:
const media_node & producer, status_t GetFileFormatsFor(
bigtime_t * out_latency); const media_node& fileInterface,
status_t GetInitialLatencyFor( media_file_format* _formatsBuffer,
const media_node & producer, int32* _inOutNumInfos);
bigtime_t * out_latency, status_t SetRefFor(const media_node& fileInterface,
uint32 * out_flags = 0); const entry_ref& file,
status_t GetStartLatencyFor( bool createAndTruncate,
const media_node & time_source, bigtime_t* _length);
bigtime_t * out_latency); // if create is false
status_t GetRefFor(const media_node& node,
entry_ref* _ref,
BMimeType* mimeType = NULL);
status_t SniffRefFor(const media_node& fileInterface,
const entry_ref& ref, BMimeType* _mimeType,
float* _capability);
// This is the generic "here's a file, now can someone please play it"
// interface:
status_t SniffRef(const entry_ref& ref,
uint64 requireNodeKinds,
// if you need an EntityInterface
// or BufferConsumer or something
dormant_node_info* _node,
BMimeType* _mimeType = NULL);
status_t GetDormantNodeForType(const BMimeType& type,
uint64 requireNodeKinds,
dormant_node_info* _info);
status_t GetReadFileFormatsFor(
const dormant_node_info& node,
media_file_format* _readFormatsBuffer,
int32 bufferCapacity, int32* _foundCount);
status_t GetWriteFileFormatsFor(
const dormant_node_info& node,
media_file_format* _writeFormatsBuffer,
int32 bufferCapacity, int32* _foundCount);
status_t GetFileFormatsFor( status_t GetFormatFor(const media_output& output,
const media_node & file_interface, media_format* _inOutFormat,
media_file_format * out_formats, uint32 flags = 0);
int32 * io_num_infos); status_t GetFormatFor(const media_input& input,
status_t SetRefFor( media_format* _inOutFormat,
const media_node & file_interface, uint32 flags = 0);
const entry_ref & file, status_t GetFormatFor(const media_node& node,
bool create_and_truncate, media_format* _inOutFormat,
bigtime_t * out_length); /* if create is false */ float quality = B_MEDIA_ANY_QUALITY);
status_t GetRefFor( ssize_t GetNodeAttributesFor(const media_node& node,
const media_node & node, media_node_attribute* outArray,
entry_ref * out_file, size_t inMaxCount);
BMimeType * mime_type = NULL); media_node_id NodeIDFor(port_id sourceOrDestinationPort);
status_t SniffRefFor( status_t GetInstancesFor(media_addon_id addon,
const media_node & file_interface, int32 flavor,media_node_id* _id,
const entry_ref & file, int32* _inOutCount = NULL);
BMimeType * mime_type, // _inOutCount defaults to 1
float * out_capability); // if unspecified (NULL).
/* This is the generic "here's a file, now can someone please play it" interface */
status_t SniffRef(
const entry_ref & file,
uint64 require_node_kinds, /* if you need an EntityInterface or BufferConsumer or something */
dormant_node_info * out_node,
BMimeType * mime_type = NULL);
status_t GetDormantNodeForType(
const BMimeType & type,
uint64 require_node_kinds,
dormant_node_info * out_node);
status_t GetReadFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_read_formats,
int32 in_read_count,
int32 * out_read_count);
status_t GetWriteFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_write_formats,
int32 in_write_count,
int32 * out_write_count);
status_t GetFormatFor( // General MediaKit configuration:
const media_output & output, status_t SetRealtimeFlags(uint32 enabledFlags);
media_format * io_format, status_t GetRealtimeFlags(uint32* _enabledFlags);
uint32 flags = 0); ssize_t AudioBufferSizeFor(int32 channelCount,
status_t GetFormatFor( uint32 sampleFormat, float frameRate,
const media_input & input, bus_type busType = B_UNKNOWN_BUS);
media_format * io_format,
uint32 flags = 0);
status_t GetFormatFor(
const media_node & node,
media_format * io_format,
float quality = B_MEDIA_ANY_QUALITY);
ssize_t GetNodeAttributesFor(
const media_node & node,
media_node_attribute * outArray,
size_t inMaxCount);
media_node_id NodeIDFor(
port_id source_or_destination_port);
status_t GetInstancesFor(
media_addon_id addon,
int32 flavor,
media_node_id * out_id,
int32 * io_count = 0); // default to 1
// Use MediaFlags to inquire about specific features of the Media Kit.
// Returns < 0 for "not present", positive size for output data size.
// 0 means that the capability is present, but no data about it.
static ssize_t MediaFlags(media_flags cap, void* buffer,
size_t maxSize);
status_t SetRealtimeFlags( // BLooper overrides
uint32 in_enabled); virtual void MessageReceived(BMessage* message);
status_t GetRealtimeFlags( virtual bool QuitRequested();
uint32 * out_enabled);
ssize_t AudioBufferSizeFor(
int32 channel_count,
uint32 sample_format,
float frame_rate,
bus_type bus_kind = B_UNKNOWN_BUS);
/* Use MediaFlags to inquire about specific features of the Media Kit. */ virtual BHandler* ResolveSpecifier(BMessage* message,
/* Returns < 0 for "not present", positive size for output data size. */ int32 index, BMessage* specifier,
/* 0 means that the capability is present, but no data about it. */ int32 form, const char* property);
static ssize_t MediaFlags( virtual status_t GetSupportedSuites(BMessage* data);
media_flags cap,
void * buf,
size_t maxSize);
/* BLooper overrides */ virtual ~BMediaRoster();
virtual void MessageReceived(
BMessage * message);
virtual bool QuitRequested();
virtual BHandler * ResolveSpecifier(
BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(
BMessage *data);
~BMediaRoster();
private: private:
// This method is deprecated:
status_t SetOutputBuffersFor(const media_source& output,
BBufferGroup* group,
bool willReclaim = false);
// deprecated call // Reserving virtual function slots.
status_t SetOutputBuffersFor( virtual status_t _Reserved_MediaRoster_0(void*);
const media_source & output, virtual status_t _Reserved_MediaRoster_1(void*);
BBufferGroup * group, virtual status_t _Reserved_MediaRoster_2(void*);
bool will_reclaim = false); virtual status_t _Reserved_MediaRoster_3(void*);
virtual status_t _Reserved_MediaRoster_4(void*);
virtual status_t _Reserved_MediaRoster_5(void*);
virtual status_t _Reserved_MediaRoster_6(void*);
virtual status_t _Reserved_MediaRoster_7(void*);
/* FBC stuffing (Mmmh, Stuffing!) */ friend class BPrivate::media::DefaultDeleter;
virtual status_t _Reserved_MediaRoster_0(void *); friend class BPrivate::media::BMediaRosterEx;
virtual status_t _Reserved_MediaRoster_1(void *);
virtual status_t _Reserved_MediaRoster_2(void *);
virtual status_t _Reserved_MediaRoster_3(void *);
virtual status_t _Reserved_MediaRoster_4(void *);
virtual status_t _Reserved_MediaRoster_5(void *);
virtual status_t _Reserved_MediaRoster_6(void *);
virtual status_t _Reserved_MediaRoster_7(void *);
friend class BPrivate::media::DefaultDeleter; // Constructor is private, since you are supposed to use
friend class BPrivate::media::BMediaRosterEx; // Roster() or CurrentRoster().
BMediaRoster();
static bool _isMediaServer; // TODO: Looks like these can be safely removed:
static status_t ParseCommand(BMessage& reply);
BMediaRoster(); status_t GetDefaultInfo(media_node_id forDefault,
BMessage& _config);
status_t SetRunningDefault(media_node_id forDefault,
const media_node& node);
static port_id _mReplyPort; private:
static int32 _mReplyPortRes; uint32 _reserved_media_roster_[67];
static int32 _mReplyPortUnavailCount;
uint32 _reserved_media_roster_[67];
static BMediaRoster * _sDefault;
static status_t ParseCommand(
BMessage & reply);
status_t GetDefaultInfo(
media_node_id for_default,
BMessage & out_config);
status_t SetRunningDefault(
media_node_id for_default,
const media_node & node);
static port_id checkout_reply_port(
const char * name = NULL);
static void checkin_reply_port(
port_id port);
static BMediaRoster* sDefaultInstance;
}; };
#endif /* _MEDIA_ROSTER_H */ #endif // _MEDIA_ROSTER_H
+17 -21
View File
@@ -67,9 +67,9 @@ namespace BPrivate { namespace media {
public: public:
~DefaultDeleter() ~DefaultDeleter()
{ {
if (BMediaRoster::_sDefault) { if (BMediaRoster::sDefaultInstance) {
BMediaRoster::_sDefault->Lock(); BMediaRoster::sDefaultInstance->Lock();
BMediaRoster::_sDefault->Quit(); BMediaRoster::sDefaultInstance->Quit();
} }
} }
}; };
@@ -1951,23 +1951,23 @@ BMediaRoster::Roster(status_t *out_error)
locker.Lock(); locker.Lock();
if (out_error) if (out_error)
*out_error = B_OK; *out_error = B_OK;
if (_sDefault == NULL) { if (sDefaultInstance == NULL) {
status_t err; status_t err;
_sDefault = new (std::nothrow) BMediaRosterEx(&err); sDefaultInstance = new (std::nothrow) BMediaRosterEx(&err);
if (_sDefault == NULL) if (sDefaultInstance == NULL)
err = B_NO_MEMORY; err = B_NO_MEMORY;
else if (err != B_OK) { else if (err != B_OK) {
if (_sDefault) { if (sDefaultInstance) {
_sDefault->Lock(); sDefaultInstance->Lock();
_sDefault->Quit(); sDefaultInstance->Quit();
_sDefault = NULL; sDefaultInstance = NULL;
} }
if (out_error) if (out_error)
*out_error = err; *out_error = err;
} }
} }
locker.Unlock(); locker.Unlock();
return _sDefault; return sDefaultInstance;
} }
@@ -1976,7 +1976,7 @@ BMediaRoster::Roster(status_t *out_error)
/* static */ BMediaRoster * /* static */ BMediaRoster *
BMediaRoster::CurrentRoster() BMediaRoster::CurrentRoster()
{ {
return _sDefault; return sDefaultInstance;
} }
@@ -2927,7 +2927,7 @@ BMediaRoster::~BMediaRoster()
// Unset the global instance pointer, the destructor is also called // Unset the global instance pointer, the destructor is also called
// if a client app calls Lock(); and Quit(); directly. // if a client app calls Lock(); and Quit(); directly.
_sDefault = NULL; sDefaultInstance = NULL;
} }
@@ -2968,6 +2968,7 @@ BMediaRoster::BMediaRoster() :
} }
// TODO: Looks like these can be safely removed:
/* static */ status_t /* static */ status_t
BMediaRoster::ParseCommand(BMessage & reply) BMediaRoster::ParseCommand(BMessage & reply)
{ {
@@ -2995,13 +2996,8 @@ BMediaRoster::SetRunningDefault(media_node_id for_default,
} }
/************************************************************* // #pragma mark - static variables
* static BMediaRoster variables
*************************************************************/
bool BMediaRoster::_isMediaServer;
port_id BMediaRoster::_mReplyPort; BMediaRoster* BMediaRoster::sDefaultInstance = NULL;
int32 BMediaRoster::_mReplyPortRes;
int32 BMediaRoster::_mReplyPortUnavailCount;
BMediaRoster * BMediaRoster::_sDefault = NULL;