* 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:
parent
7e5d04c543
commit
1fb5b54d2e
@ -80,11 +80,13 @@ find_media_addon_server_port()
|
||||
|
||||
|
||||
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;
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
* Authors:
|
||||
@ -9,8 +9,10 @@
|
||||
|
||||
|
||||
#include <MediaFiles.h>
|
||||
#include "DataExchange.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <AppMisc.h>
|
||||
#include <DataExchange.h>
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
const char BMediaFiles::B_SOUNDS[] = "Sounds";
|
||||
@ -19,7 +21,6 @@ const char BMediaFiles::B_SOUNDS[] = "Sounds";
|
||||
BMediaFiles::BMediaFiles()
|
||||
:
|
||||
fTypeIndex(-1),
|
||||
fCurrentType(""),
|
||||
fItemIndex(-1)
|
||||
{
|
||||
|
||||
@ -28,7 +29,8 @@ BMediaFiles::BMediaFiles()
|
||||
|
||||
BMediaFiles::~BMediaFiles()
|
||||
{
|
||||
// TODO: Cleanup!
|
||||
_ClearTypes();
|
||||
_ClearItems();
|
||||
}
|
||||
|
||||
|
||||
@ -36,50 +38,34 @@ status_t
|
||||
BMediaFiles::RewindTypes()
|
||||
{
|
||||
CALLED();
|
||||
status_t rv;
|
||||
server_rewindtypes_request request;
|
||||
server_rewindtypes_reply reply;
|
||||
|
||||
for (int32 i = 0; i < fTypes.CountItems(); i++)
|
||||
delete (BString*)fTypes.ItemAt(i);
|
||||
_ClearTypes();
|
||||
|
||||
fTypes.MakeEmpty();
|
||||
server_get_media_types_request request;
|
||||
request.team = BPrivate::current_team();
|
||||
|
||||
TRACE("BMediaFiles::RewindTypes: sending SERVER_REWINDTYPES\n");
|
||||
|
||||
rv = QueryServer(SERVER_REWINDTYPES, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
ERROR("BMediaFiles::RewindTypes: failed to rewindtypes "
|
||||
"(error %#lx)\n", rv);
|
||||
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;
|
||||
server_get_media_types_reply reply;
|
||||
status_t status = QueryServer(SERVER_GET_MEDIA_FILE_TYPES, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::RewindTypes: failed to rewind types: %s\n",
|
||||
strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
const char* types = (const char*)reply.address;
|
||||
for (int32 i = 0; i < reply.count; i++)
|
||||
fTypes.AddItem(new BString(types + i * B_MEDIA_NAME_LENGTH));
|
||||
|
||||
delete_area(clone);
|
||||
delete_area(reply.area);
|
||||
|
||||
fTypeIndex = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::GetNextType(BString *out_type)
|
||||
BMediaFiles::GetNextType(BString* _type)
|
||||
{
|
||||
CALLED();
|
||||
if (fTypeIndex < 0 || fTypeIndex >= fTypes.CountItems()) {
|
||||
@ -87,7 +73,7 @@ BMediaFiles::GetNextType(BString *out_type)
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
|
||||
*out_type = *(BString*)fTypes.ItemAt(fTypeIndex);
|
||||
*_type = *(BString*)fTypes.ItemAt(fTypeIndex);
|
||||
fTypeIndex++;
|
||||
|
||||
return B_OK;
|
||||
@ -95,61 +81,44 @@ BMediaFiles::GetNextType(BString *out_type)
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::RewindRefs(const char *type)
|
||||
BMediaFiles::RewindRefs(const char* type)
|
||||
{
|
||||
CALLED();
|
||||
status_t rv;
|
||||
server_rewindrefs_request request;
|
||||
server_rewindrefs_reply reply;
|
||||
|
||||
for (int32 i = 0; i < fItems.CountItems(); i++)
|
||||
delete (BString*)fItems.ItemAt(i);
|
||||
_ClearItems();
|
||||
|
||||
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",
|
||||
type);
|
||||
server_get_media_items_request request;
|
||||
request.team = BPrivate::current_team();
|
||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||
|
||||
rv = QueryServer(SERVER_REWINDREFS, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
ERROR("BMediaFiles::RewindRefs: failed to rewindrefs (error %#lx)\n",
|
||||
rv);
|
||||
return rv;
|
||||
server_get_media_items_reply reply;
|
||||
status_t status = QueryServer(SERVER_GET_MEDIA_FILE_ITEMS, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::RewindRefs: failed to rewind refs: %s\n",
|
||||
strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
if (reply.count>0) {
|
||||
char *items;
|
||||
area_id clone;
|
||||
|
||||
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);
|
||||
const char* items = (const char*)reply.address;
|
||||
for (int32 i = 0; i < reply.count; i++) {
|
||||
fItems.AddItem(new BString(items + i * B_MEDIA_NAME_LENGTH,
|
||||
B_MEDIA_NAME_LENGTH));
|
||||
}
|
||||
|
||||
fCurrentType = BString(type);
|
||||
delete_area(reply.area);
|
||||
|
||||
fCurrentType = type;
|
||||
fItemIndex = 0;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::GetNextRef(BString *out_type, entry_ref *out_ref)
|
||||
BMediaFiles::GetNextRef(BString* _type, entry_ref* _ref)
|
||||
{
|
||||
CALLED();
|
||||
if (fItemIndex < 0 || fItemIndex >= fItems.CountItems()) {
|
||||
@ -157,75 +126,66 @@ BMediaFiles::GetNextRef(BString *out_type, entry_ref *out_ref)
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
|
||||
*out_type = *(BString*)fItems.ItemAt(fItemIndex);
|
||||
*_type = *(BString*)fItems.ItemAt(fItemIndex);
|
||||
GetRefFor(fCurrentType.String(), _type->String(), _ref);
|
||||
|
||||
fItemIndex++;
|
||||
|
||||
GetRefFor(fCurrentType.String(), out_type->String(), out_ref);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
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.item, item, B_MEDIA_NAME_LENGTH);
|
||||
|
||||
TRACE("BMediaFiles::GetRefFor: sending SERVER_GETREFFOR\n");
|
||||
|
||||
rv = QueryServer(SERVER_GETREFFOR, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
entry_ref ref;
|
||||
*out_ref = ref;
|
||||
ERROR("BMediaFiles::GetRefFor: failed to getreffor (error %#lx)\n",
|
||||
rv);
|
||||
return rv;
|
||||
server_get_ref_for_reply reply;
|
||||
status_t status = QueryServer(SERVER_GET_REF_FOR, &request, sizeof(request),
|
||||
&reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
*out_ref = reply.ref;
|
||||
|
||||
*_ref = reply.ref;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::GetAudioGainFor(const char * type, const char * item,
|
||||
float * out_audio_gain)
|
||||
BMediaFiles::GetAudioGainFor(const char* type, const char* item,
|
||||
float* _audioGain)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
*out_audio_gain = 1.0f;
|
||||
*_audioGain = 1.0f;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::SetRefFor(const char *type, const char *item,
|
||||
const entry_ref &ref)
|
||||
BMediaFiles::SetRefFor(const char* type, const char* item,
|
||||
const entry_ref& ref)
|
||||
{
|
||||
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.item, item, B_MEDIA_NAME_LENGTH);
|
||||
request.ref = ref;
|
||||
|
||||
TRACE("BMediaFiles::SetRefFor: sending SERVER_SETREFFOR\n");
|
||||
|
||||
rv = QueryServer(SERVER_SETREFFOR, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
ERROR("BMediaFiles::SetRefFor: failed to setreffor (error %#lx)\n",
|
||||
rv);
|
||||
return rv;
|
||||
server_set_ref_for_reply reply;
|
||||
status_t status = QueryServer(SERVER_SET_REF_FOR, &request, sizeof(request),
|
||||
&reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::SetRefFor: failed: %s\n", strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -233,8 +193,8 @@ BMediaFiles::SetRefFor(const char *type, const char *item,
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::SetAudioGainFor(const char * type, const char * item,
|
||||
float audio_gain)
|
||||
BMediaFiles::SetAudioGainFor(const char* type, const char* item,
|
||||
float audioGain)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return B_OK;
|
||||
@ -242,25 +202,21 @@ BMediaFiles::SetAudioGainFor(const char * type, const char * item,
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::RemoveRefFor(const char *type, const char *item,
|
||||
BMediaFiles::RemoveRefFor(const char* type, const char* item,
|
||||
const entry_ref &ref)
|
||||
{
|
||||
status_t rv;
|
||||
server_removereffor_request request;
|
||||
server_removereffor_reply reply;
|
||||
CALLED();
|
||||
|
||||
server_remove_ref_for_request request;
|
||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||
request.ref = ref;
|
||||
|
||||
TRACE("BMediaFiles::RemoveRefFor: sending SERVER_REMOVEREFFOR\n");
|
||||
|
||||
rv = QueryServer(SERVER_REMOVEREFFOR, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
ERROR("BMediaFiles::RemoveRefFor: failed to removereffor "
|
||||
"(error %#lx)\n", rv);
|
||||
return rv;
|
||||
server_remove_ref_for_reply reply;
|
||||
status_t status = QueryServer(SERVER_REMOVE_REF_FOR, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::RemoveRefFor: failed: %s\n", strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@ -268,42 +224,65 @@ BMediaFiles::RemoveRefFor(const char *type, const char *item,
|
||||
|
||||
|
||||
status_t
|
||||
BMediaFiles::RemoveItem(const char *type, const char *item)
|
||||
BMediaFiles::RemoveItem(const char* type, const char* item)
|
||||
{
|
||||
status_t rv;
|
||||
server_removeitem_request request;
|
||||
server_removeitem_reply reply;
|
||||
CALLED();
|
||||
|
||||
server_remove_media_item_request request;
|
||||
strncpy(request.type, type, B_MEDIA_NAME_LENGTH);
|
||||
strncpy(request.item, item, B_MEDIA_NAME_LENGTH);
|
||||
|
||||
TRACE("BMediaFiles::RemoveItem: sending SERVER_REMOVEITEM\n");
|
||||
|
||||
rv = QueryServer(SERVER_REMOVEITEM, &request, sizeof(request), &reply,
|
||||
sizeof(reply));
|
||||
if (rv != B_OK) {
|
||||
ERROR("BMediaFiles::RemoveItem: failed to removeitem (error %#lx)\n",
|
||||
rv);
|
||||
return rv;
|
||||
server_remove_media_item_reply reply;
|
||||
status_t status = QueryServer(SERVER_REMOVE_MEDIA_ITEM, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
if (status != B_OK) {
|
||||
ERROR("BMediaFiles::RemoveItem: failed: %s\n", strerror(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_0(void *,...)
|
||||
|
||||
status_t
|
||||
BMediaFiles::_Reserved_MediaFiles_0(void*,...)
|
||||
{
|
||||
// TODO: Someone didn't understand FBC
|
||||
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_3(void *,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_4(void *,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_5(void *,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_6(void *,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_7(void *,...) { 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_3(void*,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_4(void*,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_5(void*,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_6(void*,...) { return B_ERROR; }
|
||||
status_t BMediaFiles::_Reserved_MediaFiles_7(void*,...) { return B_ERROR; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user