Cleanup.
* Sort methods like they are declared in the header. * Fixed a number of coding style violations and other oddities.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2010, Haiku, Inc.
|
* Copyright 2003-2012, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -148,7 +148,9 @@ MediaWindow::SmartNode::_FreeNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MediaWindow - Constructor
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
MediaWindow::MediaWindow(BRect frame)
|
MediaWindow::MediaWindow(BRect frame)
|
||||||
:
|
:
|
||||||
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Media"), B_TITLED_WINDOW,
|
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Media"), B_TITLED_WINDOW,
|
||||||
@@ -162,14 +164,7 @@ MediaWindow::MediaWindow(BRect frame)
|
|||||||
fAlert(NULL),
|
fAlert(NULL),
|
||||||
fInitCheck(B_OK)
|
fInitCheck(B_OK)
|
||||||
{
|
{
|
||||||
InitWindow();
|
_InitWindow();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
MediaWindow::InitCheck()
|
|
||||||
{
|
|
||||||
return fInitCheck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,14 +182,20 @@ MediaWindow::~MediaWindow()
|
|||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
path.Append(SETTINGS_FILE);
|
path.Append(SETTINGS_FILE);
|
||||||
BFile file(path.Path(), B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE);
|
BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
if (file.InitCheck()==B_OK) {
|
if (file.InitCheck() == B_OK)
|
||||||
file.Write(buffer, strlen(buffer));
|
file.Write(buffer, strlen(buffer));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWindow::InitCheck()
|
||||||
|
{
|
||||||
|
return fInitCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaWindow::SelectNode(const dormant_node_info* node)
|
MediaWindow::SelectNode(const dormant_node_info* node)
|
||||||
{
|
{
|
||||||
@@ -260,123 +261,91 @@ MediaWindow::UpdateOutputListItem(MediaListItem::media_type type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
bool
|
||||||
MediaWindow::_FindNodes()
|
MediaWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
_FindNodes(B_MEDIA_RAW_AUDIO, B_PHYSICAL_OUTPUT, fAudioOutputs);
|
// stop watching the MediaRoster
|
||||||
_FindNodes(B_MEDIA_RAW_AUDIO, B_PHYSICAL_INPUT, fAudioInputs);
|
fCurrentNode.SetTo(NULL);
|
||||||
_FindNodes(B_MEDIA_ENCODED_AUDIO, B_PHYSICAL_OUTPUT, fAudioOutputs);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
_FindNodes(B_MEDIA_ENCODED_AUDIO, B_PHYSICAL_INPUT, fAudioInputs);
|
return true;
|
||||||
_FindNodes(B_MEDIA_RAW_VIDEO, B_PHYSICAL_OUTPUT, fVideoOutputs);
|
|
||||||
_FindNodes(B_MEDIA_RAW_VIDEO, B_PHYSICAL_INPUT, fVideoInputs);
|
|
||||||
_FindNodes(B_MEDIA_ENCODED_VIDEO, B_PHYSICAL_OUTPUT, fVideoOutputs);
|
|
||||||
_FindNodes(B_MEDIA_ENCODED_VIDEO, B_PHYSICAL_INPUT, fVideoInputs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaWindow::_FindNodes(media_type type, uint64 kind, NodeList& into)
|
MediaWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
dormant_node_info node_info[64];
|
switch (message->what) {
|
||||||
int32 node_info_count = 64;
|
case ML_INIT_MEDIA:
|
||||||
|
_InitMedia(false);
|
||||||
|
break;
|
||||||
|
case ML_RESTART_MEDIA_SERVER:
|
||||||
|
{
|
||||||
|
thread_id thread = spawn_thread(&MediaWindow::_RestartMediaServices,
|
||||||
|
"restart_thread", B_NORMAL_PRIORITY, this);
|
||||||
|
if (thread < 0)
|
||||||
|
fprintf(stderr, "couldn't create restart thread\n");
|
||||||
|
else
|
||||||
|
resume_thread(thread);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_MEDIA_WEB_CHANGED:
|
||||||
|
case ML_SELECTED_NODE:
|
||||||
|
{
|
||||||
|
PRINT_OBJECT(*message);
|
||||||
|
|
||||||
media_format format;
|
MediaListItem* item = static_cast<MediaListItem*>(
|
||||||
media_format* nodeInputFormat = NULL, *nodeOutputFormat = NULL;
|
fListView->ItemAt(fListView->CurrentSelection()));
|
||||||
format.type = type;
|
if (item == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
// output nodes must be BBufferConsumers => they have an input format
|
fCurrentNode.SetTo(NULL);
|
||||||
// input nodes must be BBufferProducers => they have an output format
|
_ClearParamView();
|
||||||
if (kind & B_PHYSICAL_OUTPUT)
|
item->AlterWindow(this);
|
||||||
nodeInputFormat = &format;
|
break;
|
||||||
else if (kind & B_PHYSICAL_INPUT)
|
}
|
||||||
nodeOutputFormat = &format;
|
case B_SOME_APP_LAUNCHED:
|
||||||
else
|
{
|
||||||
return;
|
PRINT_OBJECT(*message);
|
||||||
|
if (fAlert == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
BMediaRoster* roster = BMediaRoster::Roster();
|
BString mimeSig;
|
||||||
|
if (message->FindString("be:signature", &mimeSig) == B_OK
|
||||||
if (roster->GetDormantNodes(node_info, &node_info_count, nodeInputFormat,
|
&& (mimeSig == "application/x-vnd.Be.addon-host"
|
||||||
nodeOutputFormat, NULL, kind) != B_OK) {
|
|| mimeSig == "application/x-vnd.Be.media-server")) {
|
||||||
// TODO: better error reporting!
|
fAlert->Lock();
|
||||||
fprintf(stderr, "error\n");
|
fAlert->TextView()->SetText(
|
||||||
return;
|
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
||||||
}
|
fAlert->Unlock();
|
||||||
|
}
|
||||||
for (int32 i = 0; i < node_info_count; i++) {
|
break;
|
||||||
PRINT(("node : %s, media_addon %i, flavor_id %i\n",
|
}
|
||||||
node_info[i].name, (int)node_info[i].addon,
|
case B_SOME_APP_QUIT:
|
||||||
(int)node_info[i].flavor_id));
|
{
|
||||||
|
PRINT_OBJECT(*message);
|
||||||
dormant_node_info* info = new dormant_node_info();
|
BString mimeSig;
|
||||||
strncpy(info->name, node_info[i].name, B_MEDIA_NAME_LENGTH);
|
if (message->FindString("be:signature", &mimeSig) == B_OK) {
|
||||||
info->flavor_id = node_info[i].flavor_id;
|
if (mimeSig == "application/x-vnd.Be.addon-host"
|
||||||
info->addon = node_info[i].addon;
|
|| mimeSig == "application/x-vnd.Be.media-server") {
|
||||||
into.AddItem(info);
|
BMediaRoster* roster = BMediaRoster::CurrentRoster();
|
||||||
|
if (roster != NULL && roster->Lock())
|
||||||
|
roster->Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NodeListItem*
|
// #pragma mark - private
|
||||||
MediaWindow::_FindNodeListItem(dormant_node_info* info)
|
|
||||||
{
|
|
||||||
NodeListItem audioItem(info, MediaListItem::AUDIO_TYPE);
|
|
||||||
NodeListItem videoItem(info, MediaListItem::VIDEO_TYPE);
|
|
||||||
|
|
||||||
NodeListItem::Comparator audioComparator(&audioItem);
|
|
||||||
NodeListItem::Comparator videoComparator(&videoItem);
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
|
||||||
MediaListItem* item
|
|
||||||
= static_cast<MediaListItem*>(fListView->ItemAt(i));
|
|
||||||
item->Accept(audioComparator);
|
|
||||||
if (audioComparator.result == 0)
|
|
||||||
return static_cast<NodeListItem*>(item);
|
|
||||||
|
|
||||||
item->Accept(videoComparator);
|
|
||||||
if (videoComparator.result == 0)
|
|
||||||
return static_cast<NodeListItem*>(item);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaWindow::_UpdateListViewMinWidth()
|
MediaWindow::_InitWindow()
|
||||||
{
|
|
||||||
float width = 0;
|
|
||||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
|
||||||
BListItem* item = fListView->ItemAt(i);
|
|
||||||
width = max_c(width, item->Width());
|
|
||||||
}
|
|
||||||
fListView->SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
|
||||||
fListView->InvalidateLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MediaWindow::_AddNodeItems(NodeList &list, MediaListItem::media_type type)
|
|
||||||
{
|
|
||||||
int32 count = list.CountItems();
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
|
||||||
dormant_node_info* info = list.ItemAt(i);
|
|
||||||
if (!_FindNodeListItem(info))
|
|
||||||
fListView->AddItem(new NodeListItem(info, type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MediaWindow::_EmptyNodeLists()
|
|
||||||
{
|
|
||||||
fAudioOutputs.MakeEmpty();
|
|
||||||
fAudioInputs.MakeEmpty();
|
|
||||||
fVideoOutputs.MakeEmpty();
|
|
||||||
fVideoInputs.MakeEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MediaWindow::InitWindow()
|
|
||||||
{
|
{
|
||||||
fListView = new BListView("media_list_view");
|
fListView = new BListView("media_list_view");
|
||||||
fListView->SetSelectionMessage(new BMessage(ML_SELECTED_NODE));
|
fListView->SetSelectionMessage(new BMessage(ML_SELECTED_NODE));
|
||||||
@@ -400,7 +369,6 @@ MediaWindow::InitWindow()
|
|||||||
fVideoView = new VideoSettingsView();
|
fVideoView = new VideoSettingsView();
|
||||||
fContentLayout->AddView(fVideoView);
|
fContentLayout->AddView(fVideoView);
|
||||||
|
|
||||||
|
|
||||||
// Layout all views
|
// Layout all views
|
||||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL)
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
@@ -412,19 +380,16 @@ MediaWindow::InitWindow()
|
|||||||
.Add(fContentLayout);
|
.Add(fContentLayout);
|
||||||
|
|
||||||
// Start the window
|
// Start the window
|
||||||
fInitCheck = InitMedia(true);
|
fInitCheck = _InitMedia(true);
|
||||||
if (fInitCheck != B_OK)
|
if (fInitCheck != B_OK)
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
else if (IsHidden())
|
else if (IsHidden())
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MediaWindow::InitMedia(bool first)
|
MediaWindow::_InitMedia(bool first)
|
||||||
{
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
BMediaRoster* roster = BMediaRoster::Roster(&err);
|
BMediaRoster* roster = BMediaRoster::Roster(&err);
|
||||||
@@ -432,7 +397,7 @@ MediaWindow::InitMedia(bool first)
|
|||||||
if (first && err != B_OK) {
|
if (first && err != B_OK) {
|
||||||
BAlert* alert = new BAlert("start_media_server",
|
BAlert* alert = new BAlert("start_media_server",
|
||||||
B_TRANSLATE("Could not connect to the media server.\n"
|
B_TRANSLATE("Could not connect to the media server.\n"
|
||||||
"Would you like to start it ?"),
|
"Would you like to start it ?"),
|
||||||
B_TRANSLATE("Quit"),
|
B_TRANSLATE("Quit"),
|
||||||
B_TRANSLATE("Start media server"), NULL,
|
B_TRANSLATE("Start media server"), NULL,
|
||||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||||
@@ -440,9 +405,8 @@ MediaWindow::InitMedia(bool first)
|
|||||||
if (alert->Go() == 0)
|
if (alert->Go() == 0)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fAlert = new MediaAlert(BRect(0, 0, 300, 60),
|
fAlert = new MediaAlert(BRect(0, 0, 300, 60), "restart_alert",
|
||||||
"restart_alert", B_TRANSLATE(
|
B_TRANSLATE("Restarting media services\nStarting media server"
|
||||||
"Restarting media services\nStarting media server"
|
|
||||||
B_UTF8_ELLIPSIS "\n"));
|
B_UTF8_ELLIPSIS "\n"));
|
||||||
fAlert->Show();
|
fAlert->Show();
|
||||||
|
|
||||||
@@ -454,7 +418,8 @@ MediaWindow::InitMedia(bool first)
|
|||||||
Lock();
|
Lock();
|
||||||
|
|
||||||
bool isVideoSelected = true;
|
bool isVideoSelected = true;
|
||||||
if (!first && fListView->ItemAt(0) && fListView->ItemAt(0)->IsSelected())
|
if (!first && fListView->ItemAt(0) != NULL
|
||||||
|
&& fListView->ItemAt(0)->IsSelected())
|
||||||
isVideoSelected = false;
|
isVideoSelected = false;
|
||||||
|
|
||||||
if ((!first || (first && err) ) && fAlert) {
|
if ((!first || (first && err) ) && fAlert) {
|
||||||
@@ -499,46 +464,44 @@ MediaWindow::InitMedia(bool first)
|
|||||||
_UpdateListViewMinWidth();
|
_UpdateListViewMinWidth();
|
||||||
|
|
||||||
// Set default nodes for our setting views
|
// Set default nodes for our setting views
|
||||||
media_node default_node;
|
media_node defaultNode;
|
||||||
dormant_node_info node_info;
|
dormant_node_info nodeInfo;
|
||||||
int32 outputID;
|
int32 outputID;
|
||||||
BString outputName;
|
BString outputName;
|
||||||
|
|
||||||
if (roster->GetAudioInput(&default_node) == B_OK) {
|
if (roster->GetAudioInput(&defaultNode) == B_OK) {
|
||||||
roster->GetDormantNodeFor(default_node, &node_info);
|
roster->GetDormantNodeFor(defaultNode, &nodeInfo);
|
||||||
fAudioView->SetDefaultInput(&node_info);
|
fAudioView->SetDefaultInput(&nodeInfo);
|
||||||
// this causes our listview to be updated as well
|
// this causes our listview to be updated as well
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roster->GetAudioOutput(&default_node, &outputID, &outputName)==B_OK) {
|
if (roster->GetAudioOutput(&defaultNode, &outputID, &outputName) == B_OK) {
|
||||||
roster->GetDormantNodeFor(default_node, &node_info);
|
roster->GetDormantNodeFor(defaultNode, &nodeInfo);
|
||||||
fAudioView->SetDefaultOutput(&node_info);
|
fAudioView->SetDefaultOutput(&nodeInfo);
|
||||||
fAudioView->SetDefaultChannel(outputID);
|
fAudioView->SetDefaultChannel(outputID);
|
||||||
// this causes our listview to be updated as well
|
// this causes our listview to be updated as well
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roster->GetVideoInput(&default_node)==B_OK) {
|
if (roster->GetVideoInput(&defaultNode) == B_OK) {
|
||||||
roster->GetDormantNodeFor(default_node, &node_info);
|
roster->GetDormantNodeFor(defaultNode, &nodeInfo);
|
||||||
fVideoView->SetDefaultInput(&node_info);
|
fVideoView->SetDefaultInput(&nodeInfo);
|
||||||
// this causes our listview to be updated as well
|
// this causes our listview to be updated as well
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roster->GetVideoOutput(&default_node)==B_OK) {
|
if (roster->GetVideoOutput(&defaultNode) == B_OK) {
|
||||||
roster->GetDormantNodeFor(default_node, &node_info);
|
roster->GetDormantNodeFor(defaultNode, &nodeInfo);
|
||||||
fVideoView->SetDefaultOutput(&node_info);
|
fVideoView->SetDefaultOutput(&nodeInfo);
|
||||||
// this causes our listview to be updated as well
|
// this causes our listview to be updated as well
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first) {
|
if (first)
|
||||||
fListView->Select(fListView->IndexOf(mixer));
|
fListView->Select(fListView->IndexOf(mixer));
|
||||||
} else {
|
else if (isVideoSelected)
|
||||||
if (isVideoSelected)
|
fListView->Select(fListView->IndexOf(video));
|
||||||
fListView->Select(fListView->IndexOf(video));
|
else
|
||||||
else
|
fListView->Select(fListView->IndexOf(audio));
|
||||||
fListView->Select(fListView->IndexOf(audio));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fAlert) {
|
if (fAlert != NULL) {
|
||||||
snooze(800000);
|
snooze(800000);
|
||||||
fAlert->PostMessage(B_QUIT_REQUESTED);
|
fAlert->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
@@ -550,101 +513,123 @@ MediaWindow::InitMedia(bool first)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
MediaWindow::QuitRequested()
|
|
||||||
{
|
|
||||||
// stop watching the MediaRoster
|
|
||||||
fCurrentNode.SetTo(NULL);
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ErrorAlert -- Displays a BAlert Box with a Custom Error or Debug Message
|
|
||||||
void
|
void
|
||||||
ErrorAlert(char* errorMessage) {
|
MediaWindow::_FindNodes()
|
||||||
printf("%s\n", errorMessage);
|
{
|
||||||
BAlert* alert = new BAlert("BAlert", errorMessage, B_TRANSLATE("OK"),
|
_FindNodes(B_MEDIA_RAW_AUDIO, B_PHYSICAL_OUTPUT, fAudioOutputs);
|
||||||
NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
_FindNodes(B_MEDIA_RAW_AUDIO, B_PHYSICAL_INPUT, fAudioInputs);
|
||||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
_FindNodes(B_MEDIA_ENCODED_AUDIO, B_PHYSICAL_OUTPUT, fAudioOutputs);
|
||||||
alert->Go();
|
_FindNodes(B_MEDIA_ENCODED_AUDIO, B_PHYSICAL_INPUT, fAudioInputs);
|
||||||
exit(1);
|
_FindNodes(B_MEDIA_RAW_VIDEO, B_PHYSICAL_OUTPUT, fVideoOutputs);
|
||||||
|
_FindNodes(B_MEDIA_RAW_VIDEO, B_PHYSICAL_INPUT, fVideoInputs);
|
||||||
|
_FindNodes(B_MEDIA_ENCODED_VIDEO, B_PHYSICAL_OUTPUT, fVideoOutputs);
|
||||||
|
_FindNodes(B_MEDIA_ENCODED_VIDEO, B_PHYSICAL_INPUT, fVideoInputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaWindow::MessageReceived(BMessage* message)
|
MediaWindow::_FindNodes(media_type type, uint64 kind, NodeList& into)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
dormant_node_info nodeInfo[64];
|
||||||
{
|
int32 nodeInfoCount = 64;
|
||||||
case ML_INIT_MEDIA:
|
|
||||||
InitMedia(false);
|
|
||||||
break;
|
|
||||||
case ML_RESTART_MEDIA_SERVER:
|
|
||||||
{
|
|
||||||
thread_id thread = spawn_thread(&MediaWindow::RestartMediaServices,
|
|
||||||
"restart_thread", B_NORMAL_PRIORITY, this);
|
|
||||||
if (thread < B_OK)
|
|
||||||
fprintf(stderr, "couldn't create restart thread\n");
|
|
||||||
else
|
|
||||||
resume_thread(thread);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_MEDIA_WEB_CHANGED:
|
|
||||||
case ML_SELECTED_NODE:
|
|
||||||
{
|
|
||||||
PRINT_OBJECT(*message);
|
|
||||||
|
|
||||||
MediaListItem* item = static_cast<MediaListItem*>(
|
media_format format;
|
||||||
fListView->ItemAt(fListView->CurrentSelection()));
|
media_format* nodeInputFormat = NULL;
|
||||||
if (!item)
|
media_format* nodeOutputFormat = NULL;
|
||||||
break;
|
format.type = type;
|
||||||
|
|
||||||
fCurrentNode.SetTo(NULL);
|
// output nodes must be BBufferConsumers => they have an input format
|
||||||
_ClearParamView();
|
// input nodes must be BBufferProducers => they have an output format
|
||||||
item->AlterWindow(this);
|
if ((kind & B_PHYSICAL_OUTPUT) != 0)
|
||||||
break;
|
nodeInputFormat = &format;
|
||||||
}
|
else if ((kind & B_PHYSICAL_INPUT) != 0)
|
||||||
case B_SOME_APP_LAUNCHED:
|
nodeOutputFormat = &format;
|
||||||
{
|
else
|
||||||
PRINT_OBJECT(*message);
|
return;
|
||||||
if (!fAlert)
|
|
||||||
break;
|
|
||||||
|
|
||||||
BString mimeSig;
|
BMediaRoster* roster = BMediaRoster::Roster();
|
||||||
if (message->FindString("be:signature", &mimeSig) == B_OK
|
|
||||||
&& (mimeSig == "application/x-vnd.Be.addon-host"
|
|
||||||
|| mimeSig == "application/x-vnd.Be.media-server")) {
|
|
||||||
fAlert->Lock();
|
|
||||||
fAlert->TextView()->SetText(
|
|
||||||
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
|
|
||||||
fAlert->Unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case B_SOME_APP_QUIT:
|
|
||||||
{
|
|
||||||
PRINT_OBJECT(*message);
|
|
||||||
BString mimeSig;
|
|
||||||
if (message->FindString("be:signature", &mimeSig) == B_OK) {
|
|
||||||
if (mimeSig == "application/x-vnd.Be.addon-host"
|
|
||||||
|| mimeSig == "application/x-vnd.Be.media-server") {
|
|
||||||
BMediaRoster* roster = BMediaRoster::CurrentRoster();
|
|
||||||
if (roster && roster->Lock())
|
|
||||||
roster->Quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (roster->GetDormantNodes(nodeInfo, &nodeInfoCount, nodeInputFormat,
|
||||||
break;
|
nodeOutputFormat, NULL, kind) != B_OK) {
|
||||||
default:
|
// TODO: better error reporting!
|
||||||
BWindow::MessageReceived(message);
|
fprintf(stderr, "error\n");
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32 i = 0; i < nodeInfoCount; i++) {
|
||||||
|
PRINT(("node : %s, media_addon %i, flavor_id %i\n",
|
||||||
|
nodeInfo[i].name, (int)nodeInfo[i].addon,
|
||||||
|
(int)nodeInfo[i].flavor_id));
|
||||||
|
|
||||||
|
dormant_node_info* info = new dormant_node_info();
|
||||||
|
strncpy(info->name, nodeInfo[i].name, B_MEDIA_NAME_LENGTH);
|
||||||
|
info->flavor_id = nodeInfo[i].flavor_id;
|
||||||
|
info->addon = nodeInfo[i].addon;
|
||||||
|
into.AddItem(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaWindow::_AddNodeItems(NodeList& list, MediaListItem::media_type type)
|
||||||
|
{
|
||||||
|
int32 count = list.CountItems();
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
dormant_node_info* info = list.ItemAt(i);
|
||||||
|
if (_FindNodeListItem(info) == NULL)
|
||||||
|
fListView->AddItem(new NodeListItem(info, type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaWindow::_EmptyNodeLists()
|
||||||
|
{
|
||||||
|
fAudioOutputs.MakeEmpty();
|
||||||
|
fAudioInputs.MakeEmpty();
|
||||||
|
fVideoOutputs.MakeEmpty();
|
||||||
|
fVideoInputs.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NodeListItem*
|
||||||
|
MediaWindow::_FindNodeListItem(dormant_node_info* info)
|
||||||
|
{
|
||||||
|
NodeListItem audioItem(info, MediaListItem::AUDIO_TYPE);
|
||||||
|
NodeListItem videoItem(info, MediaListItem::VIDEO_TYPE);
|
||||||
|
|
||||||
|
NodeListItem::Comparator audioComparator(&audioItem);
|
||||||
|
NodeListItem::Comparator videoComparator(&videoItem);
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||||
|
MediaListItem* item = static_cast<MediaListItem*>(fListView->ItemAt(i));
|
||||||
|
item->Accept(audioComparator);
|
||||||
|
if (audioComparator.result == 0)
|
||||||
|
return static_cast<NodeListItem*>(item);
|
||||||
|
|
||||||
|
item->Accept(videoComparator);
|
||||||
|
if (videoComparator.result == 0)
|
||||||
|
return static_cast<NodeListItem*>(item);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaWindow::_UpdateListViewMinWidth()
|
||||||
|
{
|
||||||
|
float width = 0;
|
||||||
|
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||||
|
BListItem* item = fListView->ItemAt(i);
|
||||||
|
width = max_c(width, item->Width());
|
||||||
|
}
|
||||||
|
fListView->SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
|
||||||
|
fListView->InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MediaWindow::RestartMediaServices(void* data)
|
MediaWindow::_RestartMediaServices(void* data)
|
||||||
{
|
{
|
||||||
MediaWindow* window = (MediaWindow*)data;
|
MediaWindow* window = (MediaWindow*)data;
|
||||||
window->fAlert = new MediaAlert(BRect(0, 0, 300, 60),
|
window->fAlert = new MediaAlert(BRect(0, 0, 300, 60),
|
||||||
@@ -653,7 +638,7 @@ MediaWindow::RestartMediaServices(void* data)
|
|||||||
|
|
||||||
window->fAlert->Show();
|
window->fAlert->Show();
|
||||||
|
|
||||||
shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::UpdateProgress,
|
shutdown_media_server(B_INFINITE_TIMEOUT, MediaWindow::_UpdateProgress,
|
||||||
window->fAlert);
|
window->fAlert);
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -669,7 +654,7 @@ MediaWindow::RestartMediaServices(void* data)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MediaWindow::UpdateProgress(int stage, const char * message, void * cookie)
|
MediaWindow::_UpdateProgress(int stage, const char* message, void* cookie)
|
||||||
{
|
{
|
||||||
MediaAlert* alert = static_cast<MediaAlert*>(cookie);
|
MediaAlert* alert = static_cast<MediaAlert*>(cookie);
|
||||||
PRINT(("stage : %i\n", stage));
|
PRINT(("stage : %i\n", stage));
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
/*
|
||||||
//
|
* Copyright 2003-2012, Haiku, Inc.
|
||||||
// Copyright (c) 2003, OpenBeOS
|
* Distributed under the terms of the MIT license.
|
||||||
//
|
*
|
||||||
// This software is part of the OpenBeOS distribution and is covered
|
* Authors:
|
||||||
// by the OpenBeOS license.
|
* Sikosis, Jérôme Duval
|
||||||
//
|
* yourpalal, Alex Wilson
|
||||||
//
|
*/
|
||||||
// File: MediaWindow.h
|
#ifndef MEDIA_WINDOW_H
|
||||||
// Author: Sikosis, Jérôme Duval
|
#define MEDIA_WINDOW_H
|
||||||
// Description: Media Preferences
|
|
||||||
// Created : June 25, 2003
|
|
||||||
//
|
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
|
||||||
#ifndef __MEDIAWINDOWS_H__
|
|
||||||
#define __MEDIAWINDOWS_H__
|
|
||||||
|
|
||||||
|
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
@@ -35,14 +29,13 @@
|
|||||||
|
|
||||||
class BCardLayout;
|
class BCardLayout;
|
||||||
class BSeparatorView;
|
class BSeparatorView;
|
||||||
// struct dormant_node_info;
|
|
||||||
|
|
||||||
|
|
||||||
class MediaWindow : public BWindow
|
class MediaWindow : public BWindow {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MediaWindow(BRect frame);
|
MediaWindow(BRect frame);
|
||||||
~MediaWindow();
|
~MediaWindow();
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
|
|
||||||
// methods to be called by MediaListItems...
|
// methods to be called by MediaListItems...
|
||||||
@@ -63,11 +56,11 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef BObjectList<dormant_node_info> NodeList;
|
typedef BObjectList<dormant_node_info> NodeList;
|
||||||
|
|
||||||
|
void _InitWindow();
|
||||||
|
status_t _InitMedia(bool first);
|
||||||
|
|
||||||
status_t InitMedia(bool first);
|
|
||||||
void _FindNodes();
|
void _FindNodes();
|
||||||
void _FindNodes(media_type type, uint64 kind,
|
void _FindNodes(media_type type, uint64 kind,
|
||||||
NodeList& into);
|
NodeList& into);
|
||||||
@@ -77,10 +70,9 @@ private:
|
|||||||
void _UpdateListViewMinWidth();
|
void _UpdateListViewMinWidth();
|
||||||
|
|
||||||
NodeListItem* _FindNodeListItem(dormant_node_info* info);
|
NodeListItem* _FindNodeListItem(dormant_node_info* info);
|
||||||
void InitWindow();
|
|
||||||
|
|
||||||
static status_t RestartMediaServices(void* data);
|
static status_t _RestartMediaServices(void* data);
|
||||||
static bool UpdateProgress(int stage, const char * message,
|
static bool _UpdateProgress(int stage, const char * message,
|
||||||
void * cookie);
|
void * cookie);
|
||||||
|
|
||||||
void _ClearParamView();
|
void _ClearParamView();
|
||||||
@@ -90,6 +82,7 @@ private:
|
|||||||
struct SmartNode {
|
struct SmartNode {
|
||||||
SmartNode(const BMessenger& notifyHandler);
|
SmartNode(const BMessenger& notifyHandler);
|
||||||
~SmartNode();
|
~SmartNode();
|
||||||
|
|
||||||
void SetTo(const dormant_node_info* node);
|
void SetTo(const dormant_node_info* node);
|
||||||
void SetTo(const media_node& node);
|
void SetTo(const media_node& node);
|
||||||
bool IsSet();
|
bool IsSet();
|
||||||
@@ -120,4 +113,5 @@ private:
|
|||||||
status_t fInitCheck;
|
status_t fInitCheck;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
#endif // MEDIA_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user