* Should have been part of r34554.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34555 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -80,11 +80,13 @@ find_media_addon_server_port()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
request_data::SendReply(status_t result, reply_data *reply, int replysize) const
|
request_data::SendReply(status_t result, reply_data *reply,
|
||||||
|
size_t replySize) const
|
||||||
{
|
{
|
||||||
reply->result = result;
|
reply->result = result;
|
||||||
// we cheat and use the (command_data *) version of SendToPort
|
// we cheat and use the (command_data *) version of SendToPort
|
||||||
return SendToPort(reply_port, 0, reinterpret_cast<command_data *>(reply), replysize);
|
return SendToPort(reply_port, 0, reinterpret_cast<command_data *>(reply),
|
||||||
|
replySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+122
-143
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2008, Haiku, Inc. All rights reserved.
|
* Copyright 2002-2009, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <MediaFiles.h>
|
#include <MediaFiles.h>
|
||||||
#include "DataExchange.h"
|
|
||||||
#include "debug.h"
|
#include <AppMisc.h>
|
||||||
|
#include <DataExchange.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
const char BMediaFiles::B_SOUNDS[] = "Sounds";
|
const char BMediaFiles::B_SOUNDS[] = "Sounds";
|
||||||
@@ -19,7 +21,6 @@ const char BMediaFiles::B_SOUNDS[] = "Sounds";
|
|||||||
BMediaFiles::BMediaFiles()
|
BMediaFiles::BMediaFiles()
|
||||||
:
|
:
|
||||||
fTypeIndex(-1),
|
fTypeIndex(-1),
|
||||||
fCurrentType(""),
|
|
||||||
fItemIndex(-1)
|
fItemIndex(-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -28,7 +29,8 @@ BMediaFiles::BMediaFiles()
|
|||||||
|
|
||||||
BMediaFiles::~BMediaFiles()
|
BMediaFiles::~BMediaFiles()
|
||||||
{
|
{
|
||||||
// TODO: Cleanup!
|
_ClearTypes();
|
||||||
|
_ClearItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,50 +38,34 @@ status_t
|
|||||||
BMediaFiles::RewindTypes()
|
BMediaFiles::RewindTypes()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t rv;
|
|
||||||
server_rewindtypes_request request;
|
|
||||||
server_rewindtypes_reply reply;
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fTypes.CountItems(); i++)
|
_ClearTypes();
|
||||||
delete (BString*)fTypes.ItemAt(i);
|
|
||||||
|
|
||||||
fTypes.MakeEmpty();
|
server_get_media_types_request request;
|
||||||
|
request.team = BPrivate::current_team();
|
||||||
|
|
||||||
TRACE("BMediaFiles::RewindTypes: sending SERVER_REWINDTYPES\n");
|
server_get_media_types_reply reply;
|
||||||
|
status_t status = QueryServer(SERVER_GET_MEDIA_FILE_TYPES, &request,
|
||||||
rv = QueryServer(SERVER_REWINDTYPES, &request, sizeof(request), &reply,
|
sizeof(request), &reply, sizeof(reply));
|
||||||
sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv != B_OK) {
|
ERROR("BMediaFiles::RewindTypes: failed to rewind types: %s\n",
|
||||||
ERROR("BMediaFiles::RewindTypes: failed to rewindtypes "
|
strerror(status));
|
||||||
"(error %#lx)\n", rv);
|
return status;
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *types;
|
|
||||||
area_id clone;
|
|
||||||
|
|
||||||
clone = clone_area("rewind types clone", reinterpret_cast<void **>(&types),
|
|
||||||
B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, reply.area);
|
|
||||||
if (clone < B_OK) {
|
|
||||||
ERROR("BMediaFiles::RewindTypes failed to clone area, %#lx\n", clone);
|
|
||||||
delete_area(reply.area);
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* types = (const char*)reply.address;
|
||||||
for (int32 i = 0; i < reply.count; i++)
|
for (int32 i = 0; i < reply.count; i++)
|
||||||
fTypes.AddItem(new BString(types + i * B_MEDIA_NAME_LENGTH));
|
fTypes.AddItem(new BString(types + i * B_MEDIA_NAME_LENGTH));
|
||||||
|
|
||||||
delete_area(clone);
|
|
||||||
delete_area(reply.area);
|
delete_area(reply.area);
|
||||||
|
|
||||||
fTypeIndex = 0;
|
fTypeIndex = 0;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::GetNextType(BString *out_type)
|
BMediaFiles::GetNextType(BString* _type)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fTypeIndex < 0 || fTypeIndex >= fTypes.CountItems()) {
|
if (fTypeIndex < 0 || fTypeIndex >= fTypes.CountItems()) {
|
||||||
@@ -87,7 +73,7 @@ BMediaFiles::GetNextType(BString *out_type)
|
|||||||
return B_BAD_INDEX;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_type = *(BString*)fTypes.ItemAt(fTypeIndex);
|
*_type = *(BString*)fTypes.ItemAt(fTypeIndex);
|
||||||
fTypeIndex++;
|
fTypeIndex++;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -95,61 +81,44 @@ BMediaFiles::GetNextType(BString *out_type)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::RewindRefs(const char *type)
|
BMediaFiles::RewindRefs(const char* type)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t rv;
|
|
||||||
server_rewindrefs_request request;
|
|
||||||
server_rewindrefs_reply reply;
|
|
||||||
|
|
||||||
for (int32 i = 0; i < fItems.CountItems(); i++)
|
_ClearItems();
|
||||||
delete (BString*)fItems.ItemAt(i);
|
|
||||||
|
|
||||||
fItems.MakeEmpty();
|
TRACE("BMediaFiles::RewindRefs: sending SERVER_GET_MEDIA_FILE_ITEMS for "
|
||||||
|
"type %s\n", type);
|
||||||
|
|
||||||
TRACE("BMediaFiles::RewindRefs: sending SERVER_REWINDREFS for type %s\n",
|
server_get_media_items_request request;
|
||||||
type);
|
request.team = BPrivate::current_team();
|
||||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||||
|
|
||||||
rv = QueryServer(SERVER_REWINDREFS, &request, sizeof(request), &reply,
|
server_get_media_items_reply reply;
|
||||||
sizeof(reply));
|
status_t status = QueryServer(SERVER_GET_MEDIA_FILE_ITEMS, &request,
|
||||||
if (rv != B_OK) {
|
sizeof(request), &reply, sizeof(reply));
|
||||||
ERROR("BMediaFiles::RewindRefs: failed to rewindrefs (error %#lx)\n",
|
if (status != B_OK) {
|
||||||
rv);
|
ERROR("BMediaFiles::RewindRefs: failed to rewind refs: %s\n",
|
||||||
return rv;
|
strerror(status));
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply.count>0) {
|
const char* items = (const char*)reply.address;
|
||||||
char *items;
|
for (int32 i = 0; i < reply.count; i++) {
|
||||||
area_id clone;
|
fItems.AddItem(new BString(items + i * B_MEDIA_NAME_LENGTH,
|
||||||
|
B_MEDIA_NAME_LENGTH));
|
||||||
clone = clone_area("rewind refs clone",
|
|
||||||
reinterpret_cast<void **>(&items), B_ANY_ADDRESS, B_READ_AREA
|
|
||||||
| B_WRITE_AREA, reply.area);
|
|
||||||
if (clone < B_OK) {
|
|
||||||
ERROR("BMediaFiles::RewindRefs failed to clone area, %#lx\n",
|
|
||||||
clone);
|
|
||||||
delete_area(reply.area);
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; i < reply.count; i++) {
|
|
||||||
fItems.AddItem(new BString(items + i * B_MEDIA_NAME_LENGTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
delete_area(clone);
|
|
||||||
delete_area(reply.area);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fCurrentType = BString(type);
|
delete_area(reply.area);
|
||||||
|
|
||||||
|
fCurrentType = type;
|
||||||
fItemIndex = 0;
|
fItemIndex = 0;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::GetNextRef(BString *out_type, entry_ref *out_ref)
|
BMediaFiles::GetNextRef(BString* _type, entry_ref* _ref)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fItemIndex < 0 || fItemIndex >= fItems.CountItems()) {
|
if (fItemIndex < 0 || fItemIndex >= fItems.CountItems()) {
|
||||||
@@ -157,75 +126,66 @@ BMediaFiles::GetNextRef(BString *out_type, entry_ref *out_ref)
|
|||||||
return B_BAD_INDEX;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_type = *(BString*)fItems.ItemAt(fItemIndex);
|
*_type = *(BString*)fItems.ItemAt(fItemIndex);
|
||||||
|
GetRefFor(fCurrentType.String(), _type->String(), _ref);
|
||||||
|
|
||||||
fItemIndex++;
|
fItemIndex++;
|
||||||
|
|
||||||
GetRefFor(fCurrentType.String(), out_type->String(), out_ref);
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::GetRefFor(const char *type, const char *item, entry_ref *out_ref)
|
BMediaFiles::GetRefFor(const char* type, const char* item, entry_ref* _ref)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t rv;
|
|
||||||
server_getreffor_request request;
|
|
||||||
server_getreffor_reply reply;
|
|
||||||
|
|
||||||
|
if (type == NULL || item == NULL || _ref == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
server_get_ref_for_request request;
|
||||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||||
|
|
||||||
TRACE("BMediaFiles::GetRefFor: sending SERVER_GETREFFOR\n");
|
server_get_ref_for_reply reply;
|
||||||
|
status_t status = QueryServer(SERVER_GET_REF_FOR, &request, sizeof(request),
|
||||||
rv = QueryServer(SERVER_GETREFFOR, &request, sizeof(request), &reply,
|
&reply, sizeof(reply));
|
||||||
sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv != B_OK) {
|
ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status));
|
||||||
entry_ref ref;
|
return status;
|
||||||
*out_ref = ref;
|
|
||||||
ERROR("BMediaFiles::GetRefFor: failed to getreffor (error %#lx)\n",
|
|
||||||
rv);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_ref = reply.ref;
|
*_ref = reply.ref;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::GetAudioGainFor(const char * type, const char * item,
|
BMediaFiles::GetAudioGainFor(const char* type, const char* item,
|
||||||
float * out_audio_gain)
|
float* _audioGain)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
*out_audio_gain = 1.0f;
|
*_audioGain = 1.0f;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::SetRefFor(const char *type, const char *item,
|
BMediaFiles::SetRefFor(const char* type, const char* item,
|
||||||
const entry_ref &ref)
|
const entry_ref& ref)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t rv;
|
|
||||||
server_setreffor_request request;
|
|
||||||
server_setreffor_reply reply;
|
|
||||||
|
|
||||||
|
server_set_ref_for_request request;
|
||||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||||
request.ref = ref;
|
request.ref = ref;
|
||||||
|
|
||||||
TRACE("BMediaFiles::SetRefFor: sending SERVER_SETREFFOR\n");
|
server_set_ref_for_reply reply;
|
||||||
|
status_t status = QueryServer(SERVER_SET_REF_FOR, &request, sizeof(request),
|
||||||
rv = QueryServer(SERVER_SETREFFOR, &request, sizeof(request), &reply,
|
&reply, sizeof(reply));
|
||||||
sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv != B_OK) {
|
ERROR("BMediaFiles::SetRefFor: failed: %s\n", strerror(status));
|
||||||
ERROR("BMediaFiles::SetRefFor: failed to setreffor (error %#lx)\n",
|
return status;
|
||||||
rv);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -233,8 +193,8 @@ BMediaFiles::SetRefFor(const char *type, const char *item,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::SetAudioGainFor(const char * type, const char * item,
|
BMediaFiles::SetAudioGainFor(const char* type, const char* item,
|
||||||
float audio_gain)
|
float audioGain)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -242,25 +202,21 @@ BMediaFiles::SetAudioGainFor(const char * type, const char * item,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::RemoveRefFor(const char *type, const char *item,
|
BMediaFiles::RemoveRefFor(const char* type, const char* item,
|
||||||
const entry_ref &ref)
|
const entry_ref &ref)
|
||||||
{
|
{
|
||||||
status_t rv;
|
CALLED();
|
||||||
server_removereffor_request request;
|
|
||||||
server_removereffor_reply reply;
|
|
||||||
|
|
||||||
|
server_remove_ref_for_request request;
|
||||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||||
request.ref = ref;
|
|
||||||
|
|
||||||
TRACE("BMediaFiles::RemoveRefFor: sending SERVER_REMOVEREFFOR\n");
|
server_remove_ref_for_reply reply;
|
||||||
|
status_t status = QueryServer(SERVER_REMOVE_REF_FOR, &request,
|
||||||
rv = QueryServer(SERVER_REMOVEREFFOR, &request, sizeof(request), &reply,
|
sizeof(request), &reply, sizeof(reply));
|
||||||
sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv != B_OK) {
|
ERROR("BMediaFiles::RemoveRefFor: failed: %s\n", strerror(status));
|
||||||
ERROR("BMediaFiles::RemoveRefFor: failed to removereffor "
|
return status;
|
||||||
"(error %#lx)\n", rv);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -268,42 +224,65 @@ BMediaFiles::RemoveRefFor(const char *type, const char *item,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaFiles::RemoveItem(const char *type, const char *item)
|
BMediaFiles::RemoveItem(const char* type, const char* item)
|
||||||
{
|
{
|
||||||
status_t rv;
|
CALLED();
|
||||||
server_removeitem_request request;
|
|
||||||
server_removeitem_reply reply;
|
|
||||||
|
|
||||||
|
server_remove_media_item_request request;
|
||||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||||
|
|
||||||
TRACE("BMediaFiles::RemoveItem: sending SERVER_REMOVEITEM\n");
|
server_remove_media_item_reply reply;
|
||||||
|
status_t status = QueryServer(SERVER_REMOVE_MEDIA_ITEM, &request,
|
||||||
rv = QueryServer(SERVER_REMOVEITEM, &request, sizeof(request), &reply,
|
sizeof(request), &reply, sizeof(reply));
|
||||||
sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv != B_OK) {
|
ERROR("BMediaFiles::RemoveItem: failed: %s\n", strerror(status));
|
||||||
ERROR("BMediaFiles::RemoveItem: failed to removeitem (error %#lx)\n",
|
return status;
|
||||||
rv);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - private
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMediaFiles::_ClearTypes()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < fItems.CountItems(); i++)
|
||||||
|
delete (BString*)fItems.ItemAt(i);
|
||||||
|
|
||||||
|
fTypes.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMediaFiles::_ClearItems()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; i < fItems.CountItems(); i++)
|
||||||
|
delete (BString*)fItems.ItemAt(i);
|
||||||
|
|
||||||
|
fItems.MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - FBC padding
|
// #pragma mark - FBC padding
|
||||||
|
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_0(void *,...)
|
|
||||||
|
status_t
|
||||||
|
BMediaFiles::_Reserved_MediaFiles_0(void*,...)
|
||||||
{
|
{
|
||||||
// TODO: Someone didn't understand FBC
|
// TODO: Someone didn't understand FBC
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_1(void *,...) { return B_ERROR; }
|
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_2(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_1(void*,...) { return B_ERROR; }
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_3(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_2(void*,...) { return B_ERROR; }
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_4(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_3(void*,...) { return B_ERROR; }
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_5(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_4(void*,...) { return B_ERROR; }
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_6(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_5(void*,...) { return B_ERROR; }
|
||||||
status_t BMediaFiles::_Reserved_MediaFiles_7(void *,...) { return B_ERROR; }
|
status_t BMediaFiles::_Reserved_MediaFiles_6(void*,...) { return B_ERROR; }
|
||||||
|
status_t BMediaFiles::_Reserved_MediaFiles_7(void*,...) { return B_ERROR; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user