added experimental preloading of default nodes
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2997 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
#include <OS.h>
|
||||
#include <MediaNode.h>
|
||||
#include <MediaRoster.h>
|
||||
#include <string.h>
|
||||
#include "DefaultManager.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -11,7 +13,9 @@
|
||||
*/
|
||||
|
||||
DefaultManager::DefaultManager()
|
||||
: fSystemTimeSource(-1)
|
||||
: fSystemTimeSource(-1),
|
||||
fDefaultVideoOut(-1),
|
||||
fDefaultVideoIn(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,6 +23,7 @@ DefaultManager::~DefaultManager()
|
||||
{
|
||||
}
|
||||
|
||||
// this is called by the media_server *before* any add-ons have been loaded
|
||||
status_t
|
||||
DefaultManager::LoadState()
|
||||
{
|
||||
@@ -64,12 +69,21 @@ status_t
|
||||
DefaultManager::Get(media_node_id *nodeid, char *input_name, int32 *input_id, node_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case VIDEO_INPUT:
|
||||
case AUDIO_INPUT:
|
||||
case VIDEO_OUTPUT:
|
||||
case AUDIO_MIXER:
|
||||
case AUDIO_OUTPUT:
|
||||
case AUDIO_OUTPUT_EX:
|
||||
case VIDEO_INPUT: // output: nodeid
|
||||
*nodeid = fDefaultVideoOut;
|
||||
return *nodeid > 0 ? B_OK : B_ERROR;
|
||||
|
||||
case AUDIO_INPUT: // output: nodeid
|
||||
*nodeid = -999;
|
||||
return B_ERROR;
|
||||
|
||||
case VIDEO_OUTPUT: // output: nodeid
|
||||
*nodeid = fDefaultVideoIn;
|
||||
return *nodeid > 0 ? B_OK : B_ERROR;
|
||||
|
||||
case AUDIO_MIXER: // output: nodeid
|
||||
case AUDIO_OUTPUT: // output: nodeid
|
||||
case AUDIO_OUTPUT_EX: // output: nodeid, input_name, input_id
|
||||
*nodeid = -999;
|
||||
return B_ERROR;
|
||||
|
||||
@@ -86,12 +100,77 @@ DefaultManager::Get(media_node_id *nodeid, char *input_name, int32 *input_id, no
|
||||
}
|
||||
}
|
||||
|
||||
// this is called by the media_server *after* the initial add-on loading has been done
|
||||
status_t
|
||||
DefaultManager::Rescan()
|
||||
{
|
||||
thread_id fThreadId = spawn_thread(rescan_thread, "rescan defaults", 8, this);
|
||||
resume_thread(fThreadId);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
int32
|
||||
DefaultManager::rescan_thread(void *arg)
|
||||
{
|
||||
reinterpret_cast<DefaultManager *>(arg)->RescanThread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
DefaultManager::RescanThread()
|
||||
{
|
||||
dormant_node_info info;
|
||||
media_format output;
|
||||
media_format input;
|
||||
int32 count;
|
||||
status_t rv;
|
||||
|
||||
printf("DefaultManager::RescanThread() enter\n");
|
||||
|
||||
memset(&output, 0, sizeof(output));
|
||||
output.type = B_MEDIA_RAW_VIDEO;
|
||||
count = 1;
|
||||
rv = BMediaRoster::Roster()->GetDormantNodes(&info, &count, NULL, &output);
|
||||
if (rv != B_OK || count != 1) {
|
||||
printf("Couldn't find default video output node\n");
|
||||
fDefaultVideoOut = -1;
|
||||
} else {
|
||||
media_node node;
|
||||
rv = BMediaRoster::Roster()->InstantiateDormantNode(info, &node);
|
||||
if (rv != B_OK) {
|
||||
printf("Couldn't instantiate default video output node\n");
|
||||
fDefaultVideoOut = -1;
|
||||
} else {
|
||||
printf("Default video output created!\n");
|
||||
fDefaultVideoOut = node.node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
memset(&input, 0, sizeof(input));
|
||||
input.type = B_MEDIA_RAW_VIDEO;
|
||||
count = 1;
|
||||
rv = BMediaRoster::Roster()->GetDormantNodes(&info, &count, &input);
|
||||
if (rv != B_OK || count != 1) {
|
||||
printf("Couldn't find default video input node\n");
|
||||
fDefaultVideoIn = -1;
|
||||
} else {
|
||||
media_node node;
|
||||
rv = BMediaRoster::Roster()->InstantiateDormantNode(info, &node);
|
||||
if (rv != B_OK) {
|
||||
printf("Couldn't instantiate default video input node\n");
|
||||
fDefaultVideoIn = -1;
|
||||
} else {
|
||||
printf("Default video input created!\n");
|
||||
fDefaultVideoIn = node.node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("DefaultManager::RescanThread() leave\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DefaultManager::Dump()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,12 @@ public:
|
||||
|
||||
void CleanupTeam(team_id team);
|
||||
|
||||
static int32 rescan_thread(void *arg);
|
||||
void RescanThread();
|
||||
|
||||
private:
|
||||
media_node_id fSystemTimeSource;
|
||||
media_node_id fDefaultVideoOut;
|
||||
media_node_id fDefaultVideoIn;
|
||||
|
||||
};
|
||||
|
||||
@@ -265,7 +265,7 @@ NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_
|
||||
status_t status;
|
||||
media_node_id id;
|
||||
|
||||
FATAL("NodeManager::GetClone enter: team %ld, type %d (%s)\n", team, type, get_node_type(type));
|
||||
TRACE("NodeManager::GetClone enter: team %ld, type %d (%s)\n", team, type, get_node_type(type));
|
||||
|
||||
status = GetDefaultNode(&id, input_name, input_id, type);
|
||||
if (status != B_OK) {
|
||||
@@ -283,7 +283,7 @@ NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_
|
||||
}
|
||||
ASSERT(id == node->node);
|
||||
|
||||
FATAL("NodeManager::GetClone leave: node id %ld, node port %ld, node kind %#lx\n", node->node, node->port, node->kind);
|
||||
TRACE("NodeManager::GetClone leave: node id %ld, node port %ld, node kind %#lx\n", node->node, node->port, node->kind);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "BufferManager.h"
|
||||
#include "NodeManager.h"
|
||||
#include "AppManager.h"
|
||||
#include "MediaMisc.h"
|
||||
#include "media_server.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -158,7 +159,7 @@ ServerApp::StartSystemTimeSource()
|
||||
|
||||
// register a dummy node
|
||||
media_node node;
|
||||
rv = gNodeManager->RegisterNode(&node.node, -1, 0, "System Clock", B_TIME_SOURCE, -1, BPrivate::media::team);
|
||||
rv = gNodeManager->RegisterNode(&node.node, -1, 0, "System Clock", B_TIME_SOURCE, SYSTEM_TIMESOURCE_CONTROL_PORT, BPrivate::media::team);
|
||||
ASSERT(rv == B_OK);
|
||||
|
||||
printf("StartSystemTimeSource setting as default\n");
|
||||
|
||||
Reference in New Issue
Block a user