本文整理汇总了C++中BMediaRoster::GetAudioMixer方法的典型用法代码示例。如果您正苦于以下问题:C++ BMediaRoster::GetAudioMixer方法的具体用法?C++ BMediaRoster::GetAudioMixer怎么用?C++ BMediaRoster::GetAudioMixer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMediaRoster
的用法示例。
在下文中一共展示了BMediaRoster::GetAudioMixer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
MediaWindow::SelectAudioMixer(const char* title)
{
media_node mixerNode;
BMediaRoster* roster = BMediaRoster::Roster();
roster->GetAudioMixer(&mixerNode);
fCurrentNode.SetTo(mixerNode);
_MakeParamView();
fTitleView->SetLabel(title);
}
示例2: switch
void
NodeHarnessWin::MessageReceived(BMessage *msg)
{
status_t err;
switch (msg->what)
{
case BUTTON_CONNECT:
mIsConnected = true;
// set the button states appropriately
mConnectButton->SetEnabled(false);
mStartButton->SetEnabled(true);
// set up the node network
{
BMediaRoster* r = BMediaRoster::Roster();
// connect to the mixer
err = r->GetAudioMixer(&mConnection.consumer);
ErrorCheck(err, "unable to get the system mixer");
// fire off a window with the ToneProducer's controls in it
BParameterWeb* web;
r->GetParameterWebFor(mConnection.producer, &web);
BView* view = BMediaTheme::ViewFor(web);
BWindow* win = new BWindow(BRect(250, 200, 300, 300), "Controls",
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS);
win->AddChild(view);
win->ResizeTo(view->Bounds().Width(), view->Bounds().Height());
win->Show();
// set the producer's time source to be the "default" time source, which
// the Mixer uses too.
r->GetTimeSource(&mTimeSource);
r->SetTimeSourceFor(mConnection.producer.node, mTimeSource.node);
// got the nodes; now we find the endpoints of the connection
media_input mixerInput;
media_output soundOutput;
int32 count = 1;
err = r->GetFreeOutputsFor(mConnection.producer, &soundOutput, 1, &count);
ErrorCheck(err, "unable to get a free output from the producer node");
count = 1;
err = r->GetFreeInputsFor(mConnection.consumer, &mixerInput, 1, &count);
ErrorCheck(err, "unable to get a free input to the mixer");
// got the endpoints; now we connect it!
media_format format;
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_raw_audio_format::wildcard;
err = r->Connect(soundOutput.source, mixerInput.destination, &format, &soundOutput, &mixerInput);
ErrorCheck(err, "unable to connect nodes");
// the inputs and outputs might have been reassigned during the
// nodes' negotiation of the Connect(). That's why we wait until
// after Connect() finishes to save their contents.
mConnection.format = format;
mConnection.source = soundOutput.source;
mConnection.destination = mixerInput.destination;
// Set an appropriate run mode for the producer
r->SetRunModeNode(mConnection.producer, BMediaNode::B_INCREASE_LATENCY);
}
break;
case BUTTON_START:
mStartButton->SetEnabled(false);
mStopButton->SetEnabled(true);
// start the producer running
{
BMediaRoster* r = BMediaRoster::Roster();
BTimeSource* ts = r->MakeTimeSourceFor(mConnection.producer);
if (!ts)
{
fprintf(stderr, "* ERROR - MakeTimeSourceFor(producer) returned NULL!\n");
exit(1);
}
// make sure we give the producer enough time to run buffers through
// the node chain, otherwise it'll start up already late
bigtime_t latency = 0;
r->GetLatencyFor(mConnection.producer, &latency);
r->StartNode(mConnection.producer, ts->Now() + latency);
ts->Release();
mIsRunning = true;
}
break;
case BUTTON_STOP:
StopNodes();
break;
default:
BWindow::MessageReceived(msg);
break;
}
}