added default sound events
implemented system_beep() by sending an event to the media addon server git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20728 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -75,9 +75,14 @@ enum {
|
|||||||
MEDIA_SERVER_GET_FORMATS,
|
MEDIA_SERVER_GET_FORMATS,
|
||||||
MEDIA_SERVER_MAKE_FORMAT_FOR,
|
MEDIA_SERVER_MAKE_FORMAT_FOR,
|
||||||
|
|
||||||
MEDIA_SERVER_SYSTEM_BEEP_EVENT
|
// add_system_beep_event()
|
||||||
|
MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT,
|
||||||
|
|
||||||
|
// media addon server
|
||||||
|
MEDIA_ADDON_SERVER_PLAY_MEDIA = '_TRU'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Raw port based communication
|
// Raw port based communication
|
||||||
enum {
|
enum {
|
||||||
ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS = 0x50,
|
ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS = 0x50,
|
||||||
@@ -1014,10 +1019,4 @@ struct controllable_set_parameter_data_reply : public reply_data
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SYSTEM_BEEP_EVENT_INVOKE = 1,
|
|
||||||
SYSTEM_BEEP_EVENT_ADD
|
|
||||||
};
|
|
||||||
#endif // _DATA_EXCHANGE_H
|
#endif // _DATA_EXCHANGE_H
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Jérôme Duval. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MEDIA_SOUNDS_H
|
||||||
|
#define _MEDIA_SOUNDS_H
|
||||||
|
|
||||||
|
#define MEDIA_NAME_KEY "be:media_name"
|
||||||
|
#define MEDIA_TYPE_KEY "be:media_type"
|
||||||
|
#define MEDIA_FLAGS_KEY "be:media_flags"
|
||||||
|
|
||||||
|
#define MEDIA_TYPE_SOUNDS "Sounds"
|
||||||
|
|
||||||
|
#define MEDIA_SOUNDS_BEEP "Beep"
|
||||||
|
#define MEDIA_SOUNDS_STARTUP "Startup"
|
||||||
|
#define MEDIA_SOUNDS_KEY_DOWN "Key Down"
|
||||||
|
#define MEDIA_SOUNDS_KEY_REPEAT "Key Repeat"
|
||||||
|
#define MEDIA_SOUNDS_KEY_UP "Key Up"
|
||||||
|
#define MEDIA_SOUNDS_MOUSE_DOWN "Mouse Down"
|
||||||
|
#define MEDIA_SOUNDS_MOUSE_UP "Mouse Up"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_ACTIVATED "Window Activated"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_CLOSE "Window Close"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_MINIMIZED "Window Minimized"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_OPEN "Window Open"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_RESTORED "Window Restored"
|
||||||
|
#define MEDIA_SOUNDS_WINDOW_ZOOMED "Window Zoomed"
|
||||||
|
|
||||||
|
#endif // _MEDIA_SOUNDS_H
|
||||||
@@ -8,17 +8,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "DataExchange.h"
|
#include "DataExchange.h"
|
||||||
|
#include "MediaSounds.h"
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
system_beep(const char *eventName)
|
system_beep(const char *eventName)
|
||||||
{
|
{
|
||||||
BMessenger messenger("application/x-vnd.Be.media-server");
|
BMessenger messenger("application/x-vnd.Be.addon-host");
|
||||||
if (!messenger.IsValid())
|
if (!messenger.IsValid())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
BMessage msg(MEDIA_SERVER_SYSTEM_BEEP_EVENT), reply;
|
BMessage msg(MEDIA_ADDON_SERVER_PLAY_MEDIA), reply;
|
||||||
msg.AddInt32("action", SYSTEM_BEEP_EVENT_INVOKE);
|
msg.AddString(MEDIA_NAME_KEY, eventName ? eventName : MEDIA_SOUNDS_BEEP);
|
||||||
msg.AddString("event", eventName);
|
msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS);
|
||||||
|
|
||||||
status_t err = messenger.SendMessage(&msg, &reply);
|
status_t err = messenger.SendMessage(&msg, &reply);
|
||||||
if ((err != B_OK)
|
if ((err != B_OK)
|
||||||
@@ -36,15 +37,15 @@ beep()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
add_system_beep_event(const char *eventName, uint32 flags)
|
add_system_beep_event(const char *name, uint32 flags)
|
||||||
{
|
{
|
||||||
BMessenger messenger("application/x-vnd.Be.media-server");
|
BMessenger messenger("application/x-vnd.Be.media-server");
|
||||||
if (!messenger.IsValid())
|
if (!messenger.IsValid())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
BMessage msg(MEDIA_SERVER_SYSTEM_BEEP_EVENT), reply;
|
BMessage msg(MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT), reply;
|
||||||
msg.AddInt32("action", SYSTEM_BEEP_EVENT_ADD);
|
msg.AddString(MEDIA_NAME_KEY, name);
|
||||||
msg.AddString("event", eventName);
|
msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS);
|
||||||
msg.AddInt32("flags", flags);
|
msg.AddInt32(MEDIA_FLAGS_KEY, flags);
|
||||||
|
|
||||||
status_t err = messenger.SendMessage(&msg, &reply);
|
status_t err = messenger.SendMessage(&msg, &reply);
|
||||||
if ((err != B_OK)
|
if ((err != B_OK)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <storage/FindDirectory.h>
|
#include <storage/FindDirectory.h>
|
||||||
#include <storage/Path.h>
|
#include <storage/Path.h>
|
||||||
#include "MMediaFilesManager.h"
|
#include "MMediaFilesManager.h"
|
||||||
|
#include "MediaSounds.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -18,6 +19,21 @@ MMediaFilesManager::MMediaFilesManager()
|
|||||||
fRunner(NULL)
|
fRunner(NULL)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
entry_ref ref;
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_BEEP, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_STARTUP, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_DOWN, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_REPEAT, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_KEY_UP, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_MOUSE_DOWN, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_MOUSE_UP, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_ACTIVATED, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_CLOSE, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_MINIMIZED, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_OPEN, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_RESTORED, ref, false);
|
||||||
|
SetRefFor(MEDIA_TYPE_SOUNDS, MEDIA_SOUNDS_WINDOW_ZOOMED, ref, false);
|
||||||
|
|
||||||
LoadState();
|
LoadState();
|
||||||
#if DEBUG >=3
|
#if DEBUG >=3
|
||||||
Dump();
|
Dump();
|
||||||
@@ -366,35 +382,21 @@ MMediaFilesManager::TimerMessage()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MMediaFilesManager::HandleSystemBeepEvent(BMessage *msg)
|
MMediaFilesManager::HandleAddSystemBeepEvent(BMessage *msg)
|
||||||
{
|
{
|
||||||
int32 action, flags;
|
uint32 flags;
|
||||||
BString event;
|
const char *name, *type;
|
||||||
status_t err = B_OK;
|
if ((msg->FindString(MEDIA_NAME_KEY, &name) != B_OK)
|
||||||
if ((msg->FindString("event", &event) != B_OK)
|
|| (msg->FindString(MEDIA_TYPE_KEY, &type) != B_OK)
|
||||||
|| (msg->FindInt32("action", &action) != B_OK)) {
|
|| (msg->FindInt32(MEDIA_FLAGS_KEY, (int32 *) &flags) != B_OK)) {
|
||||||
err = B_BAD_VALUE;
|
msg->SendReply(B_BAD_VALUE);
|
||||||
}
|
|
||||||
|
|
||||||
if (action == SYSTEM_BEEP_EVENT_ADD) {
|
|
||||||
if (msg->FindInt32("flags", &flags) != B_OK)
|
|
||||||
err = B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err != B_OK) {
|
|
||||||
msg->SendReply(err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action) {
|
entry_ref *pRef = NULL;
|
||||||
case SYSTEM_BEEP_EVENT_ADD: {
|
if (GetRefFor(type, name, &pRef) == B_ENTRY_NOT_FOUND) {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
SetRefFor(BMediaFiles::B_SOUNDS, event.String(), ref);
|
SetRefFor(type, name, ref);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SYSTEM_BEEP_EVENT_INVOKE: {
|
|
||||||
// TODO play the sound
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class MMediaFilesManager
|
|||||||
|
|
||||||
void TimerMessage();
|
void TimerMessage();
|
||||||
|
|
||||||
void HandleSystemBeepEvent(BMessage *msg);
|
void HandleAddSystemBeepEvent(BMessage *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int32 ReadPascalString(BFile &file, char **str);
|
static int32 ReadPascalString(BFile &file, char **str);
|
||||||
|
|||||||
@@ -803,8 +803,8 @@ ServerApp::MessageReceived(BMessage *msg)
|
|||||||
gFormatManager->MakeFormatFor(*msg);
|
gFormatManager->MakeFormatFor(*msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEDIA_SERVER_SYSTEM_BEEP_EVENT:
|
case MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT:
|
||||||
gMMediaFilesManager->HandleSystemBeepEvent(msg);
|
gMMediaFilesManager->HandleAddSystemBeepEvent(msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
inherited::MessageReceived(msg);
|
inherited::MessageReceived(msg);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "Notifications.h"
|
#include "Notifications.h"
|
||||||
#include "MediaMisc.h"
|
#include "MediaMisc.h"
|
||||||
#include "MediaRosterEx.h"
|
#include "MediaRosterEx.h"
|
||||||
|
#include "MediaSounds.h"
|
||||||
#include "SystemTimeSource.h"
|
#include "SystemTimeSource.h"
|
||||||
#include "MediaFilePlayer.h"
|
#include "MediaFilePlayer.h"
|
||||||
|
|
||||||
@@ -627,9 +628,15 @@ MediaAddonServer::MessageReceived(BMessage *msg)
|
|||||||
{
|
{
|
||||||
switch (msg->what)
|
switch (msg->what)
|
||||||
{
|
{
|
||||||
case '_TRU':
|
case MEDIA_ADDON_SERVER_PLAY_MEDIA:
|
||||||
{
|
{
|
||||||
PlayMediaFile(msg->FindString("be:media_type"), msg->FindString("be:media_name"));
|
const char *name, *type;
|
||||||
|
if ((msg->FindString(MEDIA_NAME_KEY, &name) != B_OK)
|
||||||
|
|| (msg->FindString(MEDIA_TYPE_KEY, &type) != B_OK)) {
|
||||||
|
msg->SendReply(B_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayMediaFile(type, name);
|
||||||
msg->SendReply(B_OK); // XXX don't know which reply is expected
|
msg->SendReply(B_OK); // XXX don't know which reply is expected
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user