* 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

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,367 +27,327 @@ 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
// already. It is not thread safe if you call Roster() at the
// same time.
// Getting common instances of system nodes:
status_t GetVideoInput(media_node* _node);
status_t GetAudioInput(media_node* _node);
status_t GetVideoOutput(media_node* _node);
status_t GetAudioMixer(media_node* _node);
status_t GetAudioOutput(media_node* _node);
// The output should not be used directly in common use cases.
// Use the mixer node instead.
status_t GetAudioOutput(media_node* _node,
int32* _inputId, BString* _inputName);
status_t GetTimeSource(media_node* _node);
// Setting common system nodes:
status_t SetVideoInput(const media_node& producer);
status_t SetVideoInput( status_t SetVideoInput(
const dormant_node_info& producer); const dormant_node_info& producer);
status_t SetAudioInput(
const media_node & producer); status_t SetAudioInput(const media_node& producer);
status_t SetAudioInput( status_t SetAudioInput(
const dormant_node_info& producer); const dormant_node_info& producer);
status_t SetVideoOutput(
const media_node & consumer); status_t SetVideoOutput(const media_node& consumer);
status_t SetVideoOutput( status_t SetVideoOutput(
const dormant_node_info& consumer); const dormant_node_info& consumer);
status_t SetAudioOutput( status_t SetAudioOutput(
const media_node& consumer); const media_node& consumer);
status_t SetAudioOutput( status_t SetAudioOutput(
const media_input & input_to_output); const media_input& inputToOutput);
status_t SetAudioOutput( status_t SetAudioOutput(
const dormant_node_info& consumer); const dormant_node_info& consumer);
/* Get a media_node from a node ID -- this is how you reference your own nodes! */ // Get a media_node from a node ID -- this is how you reference your
status_t GetNodeFor( // own nodes!
media_node_id node, status_t GetNodeFor(media_node_id node,
media_node* clone); media_node* clone);
status_t GetSystemTimeSource( /* typically, you want to use GetTimeSource() */ status_t GetSystemTimeSource(media_node* clone);
media_node * clone); // Typically, you'll want to use GetTimeSource() instead.
status_t ReleaseNode( /* might shut down Node if you're last */ status_t ReleaseNode(const media_node& node);
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!
BTimeSource * MakeTimeSourceFor( /* Release() the object when done */ status_t Connect(const media_source& from,
const media_node & for_node);
/* note that the media_source and media_destination found in */
/* out_output and out_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 */
status_t Connect(
const media_source & from,
const media_destination& to, const media_destination& to,
media_format * io_format, media_format* _inOutFormat,
media_output * out_output, media_output* _output,
media_input * out_input); 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 { enum connect_flags {
B_CONNECT_MUTED = 0x1 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 * io_format, media_format* _inOutFormat,
media_output * out_output, media_output* _output,
media_input * out_input, media_input* _input,
uint32 in_flags, uint32 flags, void* _reserved = NULL);
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 destination_node, media_node_id destinationNode,
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,
bigtime_t at_performance_time,
bool immediate = false); /* immediate -> at_time is insignificant */
status_t SeekNode(
const media_node & node,
bigtime_t to_media_time,
bigtime_t at_performance_time = 0 /* if running */ );
status_t StartTimeSource(
const media_node & node,
bigtime_t at_real_time);
status_t StopTimeSource(
const media_node & node,
bigtime_t at_real_time,
bool immediate = false); bool immediate = false);
status_t SeekTimeSource( // If "immediate" is true, "atPerformanceTime" is ignored.
const media_node & node, status_t SeekNode(const media_node& node,
bigtime_t to_performance_time, bigtime_t toMediaTime,
bigtime_t at_real_time); bigtime_t atPerformanceTime = 0);
// NOTE: The node needs to be running.
status_t SyncToNode( status_t StartTimeSource(const media_node& node,
const media_node & node, bigtime_t atRealTime);
bigtime_t at_time, status_t StopTimeSource(const media_node& node,
bigtime_t atRealTime,
bool immediate = false);
status_t SeekTimeSource(const media_node& node,
bigtime_t toPerformanceTime,
bigtime_t atRealTime);
status_t SyncToNode(const media_node& node,
bigtime_t atTime,
bigtime_t timeout = B_INFINITE_TIMEOUT); bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t SetRunModeNode( status_t SetRunModeNode(const media_node& node,
const media_node & node,
BMediaNode::run_mode mode); BMediaNode::run_mode mode);
status_t PrerollNode( /* synchronous */ status_t PrerollNode(const media_node& node);
const media_node & node); // NOTE: This method is synchronous.
status_t RollNode(const media_node& node,
status_t RollNode(
const media_node & node,
bigtime_t startPerformance, bigtime_t startPerformance,
bigtime_t stopPerformance, bigtime_t stopPerformance,
bigtime_t atMediaTime = -B_INFINITE_TIMEOUT); bigtime_t atMediaTime
= -B_INFINITE_TIMEOUT);
status_t SetProducerRunModeDelay( /* should only be used with B_RECORDING */ status_t SetProducerRunModeDelay(const media_node& node,
const media_node & node,
bigtime_t delay, bigtime_t delay,
BMediaNode::run_mode mode = BMediaNode::B_RECORDING); BMediaNode::run_mode mode
status_t SetProducerRate( /* not necessarily supported by node */ = BMediaNode::B_RECORDING);
const media_node & producer, // NOTE: Should only be used with B_RECORDING
int32 numer, status_t SetProducerRate(const media_node& producer,
int32 denom); int32 numer, int32 denom);
// NOTE: This feature is not necessarily supported by the node.
/* Nodes will have available inputs/outputs as long as they are capable */ // Retrieving information about available inputs/outputs.
/* of accepting more connections. The node may create an additional */ // Nodes will have available inputs/outputs as long as they are capable
/* output or input as the currently available is taken into usage. */ // of accepting more connections. The node may create an additional
status_t GetLiveNodeInfo( // output or input as the currently available is taken into usage.
const media_node & node, status_t GetLiveNodeInfo(const media_node& node,
live_node_info * out_live_info); live_node_info* _liveInfo);
status_t GetLiveNodes( status_t GetLiveNodes(live_node_info* _liveNodes,
live_node_info * out_live_nodes, int32* inOutTotalCount,
int32 * io_total_count, const media_format* hasInput = NULL,
const media_format * has_input = NULL, const media_format* hasOutput = NULL,
const media_format * has_output = NULL,
const char* name = NULL, const char* name = NULL,
uint64 node_kinds = 0); /* B_BUFFER_PRODUCER etc */ uint64 nodeKinds = 0);
// B_BUFFER_PRODUCER etc.
status_t GetFreeInputsFor( status_t GetFreeInputsFor(const media_node& node,
const media_node & node, media_input* _freeInputsBuffer,
media_input * out_free_inputs, int32 bufferCapacity,
int32 buf_num_inputs, int32* _foundCount,
int32 * out_total_count, media_type filterType
media_type filter_type = B_MEDIA_UNKNOWN_TYPE); = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedInputsFor( status_t GetConnectedInputsFor(const media_node& node,
const media_node & node, media_input* _activeInputsBuffer,
media_input * out_active_inputs, int32 bufferCapacity,
int32 buf_num_inputs, int32* _foundCount);
int32 * out_total_count); status_t GetAllInputsFor(const media_node& node,
status_t GetAllInputsFor( media_input* _inputsBuffer,
const media_node & node, int32 bufferCapacity,
media_input * out_inputs, int32* _foundCount);
int32 buf_num_inputs, status_t GetFreeOutputsFor(const media_node& node,
int32 * out_total_count); media_output* _freeOutputsBuffer,
status_t GetFreeOutputsFor( int32 bufferCapacity,
const media_node & node, int32* _foundCount,
media_output * out_free_outputs, media_type filterType
int32 buf_num_outputs, = B_MEDIA_UNKNOWN_TYPE);
int32 * out_total_count, status_t GetConnectedOutputsFor(const media_node& node,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE); media_output* _activeOutputsBuffer,
status_t GetConnectedOutputsFor( int32 bufferCapacity,
const media_node & node, int32* _foundCount);
media_output * out_active_outputs, status_t GetAllOutputsFor(const media_node& node,
int32 buf_num_outputs, media_output* _outputsBuffer,
int32 * out_total_count); int32 bufferCapacity,
status_t GetAllOutputsFor( int32* _foundCount);
const media_node & node,
media_output * out_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t StartWatching( // Event notification support:
const BMessenger & where); status_t StartWatching(const BMessenger& target);
status_t StartWatching( status_t StartWatching(const BMessenger& target,
const BMessenger & where,
int32 notificationType); int32 notificationType);
status_t StartWatching( status_t StartWatching(const BMessenger& target,
const BMessenger & where,
const media_node& node, const media_node& node,
int32 notificationType); int32 notificationType);
status_t StopWatching( status_t StopWatching(const BMessenger& target);
const BMessenger & where); status_t StopWatching(const BMessenger& target,
status_t StopWatching(
const BMessenger & where,
int32 notificationType); int32 notificationType);
status_t StopWatching( status_t StopWatching(const BMessenger& target,
const BMessenger & where,
const media_node& node, const media_node& node,
int32 notificationType); int32 notificationType);
status_t RegisterNode( status_t RegisterNode(BMediaNode* node);
BMediaNode * node); status_t UnregisterNode(BMediaNode* node);
status_t UnregisterNode(
BMediaNode * node);
static BMediaRoster * Roster( // will create if there isn't one status_t SetTimeSourceFor(media_node_id node,
status_t * out_error = NULL); // thread safe for multiple calls to Roster() media_node_id timeSource);
static BMediaRoster * CurrentRoster(); // won't create it if there isn't one
// not thread safe if you call Roster() at the same time
status_t SetTimeSourceFor(
media_node_id node,
media_node_id time_source);
status_t GetParameterWebFor( // Building a control GUI for a node:
const media_node & node, status_t GetParameterWebFor(const media_node& node,
BParameterWeb ** out_web); BParameterWeb** _web);
status_t StartControlPanel( status_t StartControlPanel(const media_node& node,
const media_node & node, BMessenger* _messenger = NULL);
BMessenger * out_messenger = NULL);
status_t GetDormantNodes( // Information about nodes which are not running, but could
dormant_node_info * out_info, // be instantiated from add-ons:
int32 * io_count, status_t GetDormantNodes(dormant_node_info* _info,
const media_format * has_input = NULL, int32* _inOutCount,
const media_format * has_output = NULL, const media_format* _hasInput = NULL,
const media_format* _hasOutput = NULL,
const char* name = NULL, const char* name = NULL,
uint64 require_kinds = 0, uint64 requireKinds = 0,
uint64 deny_kinds = 0); uint64 denyKinds = 0);
status_t InstantiateDormantNode( status_t InstantiateDormantNode(
const dormant_node_info & in_info, const dormant_node_info& info,
media_node * out_node, media_node* _node,
uint32 flags /* currently B_FLAVOR_IS_GLOBAL or B_FLAVOR_IS_LOCAL */ ); uint32 flags);
// NOTE: Supported flags are currently B_FLAVOR_IS_GLOBAL
// or B_FLAVOR_IS_LOCAL
status_t InstantiateDormantNode( status_t InstantiateDormantNode(
const dormant_node_info & in_info, const dormant_node_info& info,
media_node * out_node); media_node* _node);
status_t GetDormantNodeFor( status_t GetDormantNodeFor(const media_node& node,
const media_node & node, dormant_node_info* _info);
dormant_node_info * out_info);
status_t GetDormantFlavorInfoFor( status_t GetDormantFlavorInfoFor(
const dormant_node_info & in_dormant, const dormant_node_info& info,
dormant_flavor_info * out_flavor); dormant_flavor_info* _flavor);
status_t GetLatencyFor( // Latency information:
const media_node & producer, status_t GetLatencyFor(const media_node& producer,
bigtime_t * out_latency); bigtime_t* _latency);
status_t GetInitialLatencyFor( status_t GetInitialLatencyFor(
const media_node& producer, const media_node& producer,
bigtime_t * out_latency, bigtime_t* _latency,
uint32 * out_flags = 0); uint32* _flags = NULL);
status_t GetStartLatencyFor( status_t GetStartLatencyFor(
const media_node & time_source, const media_node& timeSource,
bigtime_t * out_latency); bigtime_t* _latency);
// Finding a suitable node to playback a file:
status_t GetFileFormatsFor( status_t GetFileFormatsFor(
const media_node & file_interface, const media_node& fileInterface,
media_file_format * out_formats, media_file_format* _formatsBuffer,
int32 * io_num_infos); int32* _inOutNumInfos);
status_t SetRefFor( status_t SetRefFor(const media_node& fileInterface,
const media_node & file_interface,
const entry_ref& file, const entry_ref& file,
bool create_and_truncate, bool createAndTruncate,
bigtime_t * out_length); /* if create is false */ bigtime_t* _length);
status_t GetRefFor( // if create is false
const media_node & node, status_t GetRefFor(const media_node& node,
entry_ref * out_file, entry_ref* _ref,
BMimeType * mime_type = NULL); BMimeType* mimeType = NULL);
status_t SniffRefFor( status_t SniffRefFor(const media_node& fileInterface,
const media_node & file_interface, const entry_ref& ref, BMimeType* _mimeType,
const entry_ref & file, float* _capability);
BMimeType * mime_type, // This is the generic "here's a file, now can someone please play it"
float * out_capability); // interface:
/* This is the generic "here's a file, now can someone please play it" interface */ status_t SniffRef(const entry_ref& ref,
status_t SniffRef( uint64 requireNodeKinds,
const entry_ref & file, // if you need an EntityInterface
uint64 require_node_kinds, /* if you need an EntityInterface or BufferConsumer or something */ // or BufferConsumer or something
dormant_node_info * out_node, dormant_node_info* _node,
BMimeType * mime_type = NULL); BMimeType* _mimeType = NULL);
status_t GetDormantNodeForType( status_t GetDormantNodeForType(const BMimeType& type,
const BMimeType & type, uint64 requireNodeKinds,
uint64 require_node_kinds, dormant_node_info* _info);
dormant_node_info * out_node);
status_t GetReadFileFormatsFor( status_t GetReadFileFormatsFor(
const dormant_node_info & in_node, const dormant_node_info& node,
media_file_format * out_read_formats, media_file_format* _readFormatsBuffer,
int32 in_read_count, int32 bufferCapacity, int32* _foundCount);
int32 * out_read_count);
status_t GetWriteFileFormatsFor( status_t GetWriteFileFormatsFor(
const dormant_node_info & in_node, const dormant_node_info& node,
media_file_format * out_write_formats, media_file_format* _writeFormatsBuffer,
int32 in_write_count, int32 bufferCapacity, int32* _foundCount);
int32 * out_write_count);
status_t GetFormatFor( status_t GetFormatFor(const media_output& output,
const media_output & output, media_format* _inOutFormat,
media_format * io_format,
uint32 flags = 0); uint32 flags = 0);
status_t GetFormatFor( status_t GetFormatFor(const media_input& input,
const media_input & input, media_format* _inOutFormat,
media_format * io_format,
uint32 flags = 0); uint32 flags = 0);
status_t GetFormatFor( status_t GetFormatFor(const media_node& node,
const media_node & node, media_format* _inOutFormat,
media_format * io_format,
float quality = B_MEDIA_ANY_QUALITY); float quality = B_MEDIA_ANY_QUALITY);
ssize_t GetNodeAttributesFor( ssize_t GetNodeAttributesFor(const media_node& node,
const media_node & node,
media_node_attribute* outArray, media_node_attribute* outArray,
size_t inMaxCount); size_t inMaxCount);
media_node_id NodeIDFor( media_node_id NodeIDFor(port_id sourceOrDestinationPort);
port_id source_or_destination_port); status_t GetInstancesFor(media_addon_id addon,
status_t GetInstancesFor( int32 flavor,media_node_id* _id,
media_addon_id addon, int32* _inOutCount = NULL);
int32 flavor, // _inOutCount defaults to 1
media_node_id * out_id, // if unspecified (NULL).
int32 * io_count = 0); // default to 1
// General MediaKit configuration:
status_t SetRealtimeFlags(uint32 enabledFlags);
status_t GetRealtimeFlags(uint32* _enabledFlags);
ssize_t AudioBufferSizeFor(int32 channelCount,
uint32 sampleFormat, float frameRate,
bus_type busType = B_UNKNOWN_BUS);
status_t SetRealtimeFlags( // Use MediaFlags to inquire about specific features of the Media Kit.
uint32 in_enabled); // Returns < 0 for "not present", positive size for output data size.
status_t GetRealtimeFlags( // 0 means that the capability is present, but no data about it.
uint32 * out_enabled); static ssize_t MediaFlags(media_flags cap, void* buffer,
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. */
/* 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 * buf,
size_t maxSize); size_t maxSize);
/* BLooper overrides */ // BLooper overrides
virtual void MessageReceived( virtual void MessageReceived(BMessage* message);
BMessage * message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual BHandler * ResolveSpecifier( virtual BHandler* ResolveSpecifier(BMessage* message,
BMessage *msg, int32 index, BMessage* specifier,
int32 index, int32 form, const char* property);
BMessage *specifier, virtual status_t GetSupportedSuites(BMessage* data);
int32 form,
const char *property);
virtual status_t GetSupportedSuites(
BMessage *data);
~BMediaRoster(); virtual ~BMediaRoster();
private: private:
// This method is deprecated:
// deprecated call status_t SetOutputBuffersFor(const media_source& output,
status_t SetOutputBuffersFor(
const media_source & output,
BBufferGroup* group, BBufferGroup* group,
bool will_reclaim = false); bool willReclaim = false);
/* FBC stuffing (Mmmh, Stuffing!) */ // Reserving virtual function slots.
virtual status_t _Reserved_MediaRoster_0(void*); virtual status_t _Reserved_MediaRoster_0(void*);
virtual status_t _Reserved_MediaRoster_1(void*); virtual status_t _Reserved_MediaRoster_1(void*);
virtual status_t _Reserved_MediaRoster_2(void*); virtual status_t _Reserved_MediaRoster_2(void*);
@ -401,36 +360,24 @@ virtual status_t _Reserved_MediaRoster_7(void *);
friend class BPrivate::media::DefaultDeleter; friend class BPrivate::media::DefaultDeleter;
friend class BPrivate::media::BMediaRosterEx; friend class BPrivate::media::BMediaRosterEx;
static bool _isMediaServer; // Constructor is private, since you are supposed to use
// Roster() or CurrentRoster().
BMediaRoster(); BMediaRoster();
static port_id _mReplyPort; // TODO: Looks like these can be safely removed:
static int32 _mReplyPortRes; static status_t ParseCommand(BMessage& reply);
static int32 _mReplyPortUnavailCount;
uint32 _reserved_media_roster_[67]; status_t GetDefaultInfo(media_node_id forDefault,
BMessage& _config);
status_t SetRunningDefault(media_node_id forDefault,
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); const media_node& node);
static port_id checkout_reply_port( private:
const char * name = NULL); uint32 _reserved_media_roster_[67];
static void checkin_reply_port(
port_id port);
static BMediaRoster* sDefaultInstance;
}; };
#endif /* _MEDIA_ROSTER_H */ #endif // _MEDIA_ROSTER_H

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;