本文整理汇总了C++中BMediaRoster类的典型用法代码示例。如果您正苦于以下问题:C++ BMediaRoster类的具体用法?C++ BMediaRoster怎么用?C++ BMediaRoster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BMediaRoster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
AudioSettingsView::MessageReceived(BMessage* message)
{
switch (message->what) {
case ML_DEFAULT_CHANNEL_CHANGED:
{
int32 index;
if (message->FindInt32("index", &index) != B_OK)
break;
ChannelMenuItem* item = _ChannelMenuItemAt(index);
if (item) {
BMediaRoster* roster = BMediaRoster::Roster();
roster->SetAudioOutput(*item->Input());
} else
fprintf(stderr, "ChannelMenuItem not found\n");
}
break;
case MEDIA_SHOW_HIDE_VOLUME_CONTROL:
{
if (fVolumeCheckBox->Value() == B_CONTROL_ON)
_ShowDeskbarVolumeControl();
else
_HideDeskbarVolumeControl();
break;
}
default:
SettingsView::MessageReceived(message);
}
}
示例2: _EmptyNodeLists
MediaWindow::~MediaWindow()
{
_EmptyNodeLists();
_ClearParamView();
char buffer[512];
BRect rect = Frame();
PRINT_OBJECT(rect);
snprintf(buffer, 512, "# MediaPrefs Settings\n rect = %i,%i,%i,%i\n",
int(rect.left), int(rect.top), int(rect.right), int(rect.bottom));
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(SETTINGS_FILE);
BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
if (file.InitCheck() == B_OK)
file.Write(buffer, strlen(buffer));
}
BMediaRoster* roster = BMediaRoster::CurrentRoster();
roster->StopWatching(BMessenger(this, this),
B_MEDIA_SERVER_STARTED);
roster->StartWatching(BMessenger(this, this),
B_MEDIA_SERVER_QUIT);
}
示例3: malloc
live_node_info*
JackClient::_LiveNodes(int32* live_count)
{
BMediaRoster* roster = BMediaRoster::Roster();
// TODO set autodeleter to live_nodes
live_node_info* live_nodes = (live_node_info*) malloc(100);
int32 count;
media_format outFormat;
memset(&outFormat, 0, sizeof(outFormat));
outFormat.type = B_MEDIA_RAW_AUDIO;
media_format inFormat;
memset(&inFormat, 0, sizeof(inFormat));
inFormat.type = B_MEDIA_RAW_AUDIO;
status_t err = roster->GetLiveNodes(live_nodes, &count,
&inFormat, &outFormat, NULL, 0);
if (err != B_OK)
return NULL;
*live_count = count;
return live_nodes;
}
示例4: D_INTERNAL
status_t ParameterWindow::_startControlPanel() {
D_INTERNAL(("ParameterWindow::_startControlPanel()\n"));
// get roster instance
BMediaRoster *roster = BMediaRoster::CurrentRoster();
if (!roster) {
D_INTERNAL((" -> MediaRoster not available\n"));
return B_ERROR;
}
// try to StartControlPanel()
BMessenger messenger;
status_t error = roster->StartControlPanel(m_node, &messenger);
if (error) {
D_INTERNAL((" -> StartControlPanel() failed (%s)\n", strerror(error)));
return error;
}
// notify the notification target, if any
if (m_notifyTarget) {
BMessage message(M_CONTROL_PANEL_STARTED);
message.AddInt32("nodeID", m_node.node);
message.AddMessenger("messenger", messenger);
error = m_notifyTarget->SendMessage(&message);
if (error) {
D_INTERNAL((" -> failed to notify target\n"));
}
}
return B_OK;
}
示例5: BWindow
// --------------------
// NodeHarnessWin implementation
NodeHarnessWin::NodeHarnessWin(BRect frame, const char *title)
: BWindow(frame, title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
mToneNode(NULL), mIsConnected(false), mIsRunning(false)
{
// build the UI
BRect r(10, 10, 100, 40);
mConnectButton = new BButton(r, "Connect", "Connect", new BMessage(BUTTON_CONNECT));
mConnectButton->SetEnabled(true);
AddChild(mConnectButton);
r.OffsetBy(0, 40);
mStartButton = new BButton(r, "Start", "Start", new BMessage(BUTTON_START));
mStartButton->SetEnabled(false);
AddChild(mStartButton);
r.OffsetBy(0, 40);
mStopButton = new BButton(r, "Stop", "Stop", new BMessage(BUTTON_STOP));
mStopButton->SetEnabled(false);
AddChild(mStopButton);
// e.moon 2jun99: create the node
BMediaRoster* roster = BMediaRoster::Roster();
mToneNode = new ToneProducer();
status_t err = roster->RegisterNode(mToneNode);
ErrorCheck(err, "unable to register ToneProducer node!\n");
// make sure the Media Roster knows that we're using the node
roster->GetNodeFor(mToneNode->Node().node, &mConnection.producer);
}
示例6: fprintf
NodeHarnessWin::~NodeHarnessWin()
{
BMediaRoster* r = BMediaRoster::Roster();
// tear down the node network
if (mIsRunning) StopNodes();
if (mIsConnected)
{
status_t err;
// Ordinarily we'd stop *all* of the nodes in the chain at this point. However,
// one of the nodes is the System Mixer, and stopping the Mixer is a Bad Idea (tm).
// So, we just disconnect from it, and release our references to the nodes that
// we're using. We *are* supposed to do that even for global nodes like the Mixer.
err = r->Disconnect(mConnection.producer.node, mConnection.source,
mConnection.consumer.node, mConnection.destination);
if (err)
{
fprintf(stderr, "* Error disconnecting nodes: %ld (%s)\n", err, strerror(err));
}
r->ReleaseNode(mConnection.producer);
r->ReleaseNode(mConnection.consumer);
}
}
示例7: _DisconnectVolume
void
VolumeControl::_ConnectVolume()
{
_DisconnectVolume();
const char* errorString = NULL;
float volume = 0.0;
fMixerControl->Connect(fMixerControl->VolumeWhich(), &volume, &errorString);
if (errorString != NULL) {
SetLabel(errorString);
SetLimits(-60, 18);
} else {
SetLabel(B_TRANSLATE("Volume"));
SetLimits((int32)floorf(fMixerControl->Minimum()),
(int32)ceilf(fMixerControl->Maximum()));
BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL && fMixerControl->GainNode() != media_node::null) {
roster->StartWatching(this, fMixerControl->GainNode(),
B_MEDIA_NEW_PARAMETER_VALUE);
}
}
SetEnabled(errorString == NULL);
fOriginalValue = (int32)volume;
SetValue((int32)volume);
}
示例8: D_INTERNAL
void DormantNodeView::_populateList() {
D_INTERNAL(("DormantNodeView::_populateList()\n"));
// init the resizable node-info buffer
BMediaRoster *roster = BMediaRoster::CurrentRoster();
const int32 bufferInc = 64;
int32 bufferSize = bufferInc;
dormant_node_info *infoBuffer = new dormant_node_info[bufferSize];
int32 numNodes;
// fill the buffer
while (true) {
numNodes = bufferSize;
status_t error = roster->GetDormantNodes(infoBuffer, &numNodes);
if (error) {
return;
}
if (numNodes < bufferSize) {
break;
}
// reallocate buffer & try again
delete [] infoBuffer;
bufferSize += bufferInc;
infoBuffer = new dormant_node_info[bufferSize];
}
// populate the list
for (int32 i = 0; i < numNodes; i++) {
DormantNodeListItem *item = new DormantNodeListItem(infoBuffer[i]);
AddItem(item);
}
SortItems(compareName);
}
示例9: _FreeNode
void
MediaWindow::SmartNode::SetTo(const dormant_node_info* info)
{
_FreeNode();
if (!info)
return;
fNode = new media_node();
BMediaRoster* roster = BMediaRoster::Roster();
status_t status = B_OK;
media_node_id node_id;
if (roster->GetInstancesFor(info->addon, info->flavor_id, &node_id) == B_OK)
status = roster->GetNodeFor(node_id, fNode);
else
status = roster->InstantiateDormantNode(*info, fNode, B_FLAVOR_IS_GLOBAL);
if (status != B_OK) {
fprintf(stderr, "SmartNode::SetTo error with node %" B_PRId32
": %s\n", fNode->node, strerror(status));
}
status = roster->StartWatching(fMessenger, *fNode, B_MEDIA_WILDCARD);
if (status != B_OK) {
fprintf(stderr, "SmartNode::SetTo can't start watching for"
" node %" B_PRId32 "\n", fNode->node);
}
}
示例10: D_METHOD
NodeRef::~NodeRef() {
D_METHOD(("~NodeRef[%s]\n", name()));
Autolock _l(m_manager);
// remove from NodeManager
m_manager->_removeRef(id());
// [14oct99 e.moon] kill position-report thread if necessary
if(m_positionThread)
_stopPositionThread();
if(m_addonHint) {
delete m_addonHint;
m_addonHint = 0;
}
// close Media Roster connection [e.moon 11oct99]
BMediaRoster* r = BMediaRoster::Roster();
if(m_watching) {
r->StopWatching(
BMessenger(this),
node(),
B_MEDIA_WILDCARD);
}
}
示例11: _DisconnectVolume
void
VolumeControl::DetachedFromWindow()
{
_DisconnectVolume();
BMediaRoster* roster = BMediaRoster::CurrentRoster();
roster->StopWatching(BMessenger(this), B_MEDIA_SERVER_STARTED);
roster->StopWatching(BMessenger(this), B_MEDIA_SERVER_QUIT);
}
示例12:
void
VolumeControl::_DisconnectVolume()
{
BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL && fMixerControl->GainNode() != media_node::null) {
roster->StopWatching(this, fMixerControl->GainNode(),
B_MEDIA_NEW_PARAMETER_VALUE);
}
}
示例13: CALLED
void
BMediaClient::_Init()
{
CALLED();
BMediaRoster* roster = BMediaRoster::Roster(&fInitErr);
if (fInitErr == B_OK && roster != NULL)
fInitErr = roster->RegisterNode(fNode);
}
示例14: _EmptyMenu
void
AudioSettingsView::_FillChannelMenu(const dormant_node_info* nodeInfo)
{
_EmptyMenu(fChannelMenu);
BMediaRoster* roster = BMediaRoster::Roster();
media_node node;
media_node_id node_id;
status_t err = roster->GetInstancesFor(nodeInfo->addon,
nodeInfo->flavor_id, &node_id);
if (err != B_OK) {
err = roster->InstantiateDormantNode(*nodeInfo, &node,
B_FLAVOR_IS_GLOBAL);
} else {
err = roster->GetNodeFor(node_id, &node);
}
if (err == B_OK) {
int32 inputCount = 4;
media_input* inputs = new media_input[inputCount];
BPrivate::ArrayDeleter<media_input> inputDeleter(inputs);
while (true) {
int32 realInputCount = 0;
err = roster->GetAllInputsFor(node, inputs,
inputCount, &realInputCount);
if (realInputCount > inputCount) {
inputCount *= 2;
inputs = new media_input[inputCount];
inputDeleter.SetTo(inputs);
} else {
inputCount = realInputCount;
break;
}
}
if (err == B_OK) {
BMessage message(ML_DEFAULT_CHANNEL_CHANGED);
for (int32 i = 0; i < inputCount; i++) {
media_input* input = new media_input();
memcpy(input, &inputs[i], sizeof(*input));
ChannelMenuItem* channelItem = new ChannelMenuItem(input,
new BMessage(message));
fChannelMenu->AddItem(channelItem);
if (channelItem->DestinationID() == 0)
channelItem->SetMarked(true);
}
}
}
if (Window())
fChannelMenu->SetTargetForItems(BMessenger(this));
}
示例15: BApplication
MediaNodeControlApp::MediaNodeControlApp(
const char* pAppSignature,
media_node_id nodeID) :
BApplication(pAppSignature) {
BMediaRoster* r = BMediaRoster::Roster();
// get the node
status_t err = r->GetNodeFor(nodeID, &m_node);
if(err < B_OK) {
char buffer[512];
sprintf(buffer,
"MediaNodeControlApp: couldn't find node (%ld):\n%s\n",
nodeID, strerror(err));
(new BAlert("error", buffer, "OK"))->Go();
return;
}
// fetch info (name)
live_node_info nInfo;
err = r->GetLiveNodeInfo(m_node, &nInfo);
if(err < B_OK) {
char buffer[512];
sprintf(buffer,
"MediaNodeControlApp: couldn't get node info (%ld):\n%s\n",
nodeID, strerror(err));
(new BAlert("error", buffer, "OK"))->Go();
return;
}
BString windowTitle;
windowTitle << nInfo.name << '(' << nodeID << ") controls";
// get parameter web
BParameterWeb* pWeb;
err = r->GetParameterWebFor(m_node, &pWeb);
if(err < B_OK) {
char buffer[512];
sprintf(buffer,
"MediaNodeControlApp: no parameters for node (%ld):\n%s\n",
nodeID, strerror(err));
(new BAlert("error", buffer, "OK"))->Go();
return;
}
// build & show control window
BView* pView = BMediaTheme::ViewFor(pWeb);
BWindow* pWnd = new PanelWindow();
pWnd->AddChild(pView);
pWnd->ResizeTo(pView->Bounds().Width(), pView->Bounds().Height());
pWnd->SetTitle(windowTitle.String());
pWnd->Show();
// release the node
//r->ReleaseNode(m_node);
}