summaryrefslogtreecommitdiff
path: root/libresourceqt/src
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-19 10:38:19 +0200
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-02-19 10:38:19 +0200
commitda47faf6b036220e32e7ce90210530ba5ef9dc2b (patch)
tree07f2911f41f1ca504f42419e75d332d1994727ae /libresourceqt/src
parenta36aef2b7c5128785a60213a6607191a8bfb1ecf (diff)
implemented the 'audio' features
Diffstat (limited to 'libresourceqt/src')
-rw-r--r--libresourceqt/src/audio-resource.cpp7
-rw-r--r--libresourceqt/src/resource-engine.cpp76
-rw-r--r--libresourceqt/src/resource-engine.h6
-rw-r--r--libresourceqt/src/resource-set.cpp72
4 files changed, 61 insertions, 100 deletions
diff --git a/libresourceqt/src/audio-resource.cpp b/libresourceqt/src/audio-resource.cpp
index b8c049f..f3c345e 100644
--- a/libresourceqt/src/audio-resource.cpp
+++ b/libresourceqt/src/audio-resource.cpp
@@ -41,7 +41,7 @@ void AudioResource::setAudioGroup(const QString &newGroup)
qDebug("this = %p", this);
group = newGroup;
qDebug() << "Audio group changed! New group is: " << newGroup;
- emit audioGroupChanged(group);
+ emit audioPropertiesChanged(group, pid, streamName, streamValue);
}
quint32 AudioResource::processID() const
@@ -52,7 +52,8 @@ quint32 AudioResource::processID() const
void AudioResource::setProcessID(quint32 newPID)
{
pid = newPID;
- emit pidChanged(pid);
+ qDebug("New PID = %u", pid);
+ emit audioPropertiesChanged(group, pid, streamName, streamValue);
}
QString AudioResource::streamTagName() const
@@ -78,7 +79,7 @@ void AudioResource::setStreamTag(const QString &name, const QString &value)
{
streamName = name;
streamValue = value;
- emit streamTagChanged(name, value);
+ emit audioPropertiesChanged(group, pid, name, value);
}
ResourceType AudioResource::type() const
diff --git a/libresourceqt/src/resource-engine.cpp b/libresourceqt/src/resource-engine.cpp
index f788439..014d2cc 100644
--- a/libresourceqt/src/resource-engine.cpp
+++ b/libresourceqt/src/resource-engine.cpp
@@ -388,65 +388,43 @@ bool ResourceEngine::updateResources()
return true;
}
-bool ResourceEngine::registerAudioPid(quint32 pid)
+bool ResourceEngine::registerAudioProperties(const QString &audioGroup, quint32 pid,
+ const QString &name, const QString &value)
{
- if(pid == 0)
- return false;
-
- resmsg_t message;
- memset(&message, 0, sizeof(resmsg_t));
-
- message.audio.pid = pid;
-
- qDebug("audio pid %u", pid);
- return sendAudioMessage(&message);
-}
-
-bool ResourceEngine::registerAudioStreamTag(const QString &name, const QString &value)
-{
- if(name.isEmpty() || name.isNull() || value.isEmpty() || value.isNull())
- return false;
-
resmsg_t message;
memset(&message, 0, sizeof(resmsg_t));
+ QByteArray groupBa, nameBa, valueBa;
- QByteArray nameBa = name.toLatin1();
- QByteArray valueBa = value.toLatin1();
- message.audio.property.name = nameBa.data();
- message.audio.property.match.method = resmsg_method_equals;
- message.audio.property.match.pattern = valueBa.data();
-
- qDebug() << "audio stream tag " << name << ":" << value;
- return sendAudioMessage(&message);
-}
-
-bool ResourceEngine::registerAudioGroup(const QString &audioGroup)
-{
- if(audioGroup.isEmpty() || audioGroup.isNull())
- return false;
-
- resmsg_t message;
- memset(&message, 0, sizeof(resmsg_t));
-
- QByteArray ba = audioGroup.toLatin1();
- message.audio.group = ba.data();
-
- qDebug() << "audio group " << audioGroup;
- return sendAudioMessage(&message);
-}
+ if (pid != 0) {
+ message.audio.pid = pid;
+ qDebug("audio pid %u", pid);
+ }
+ if (!audioGroup.isEmpty() && !audioGroup.isNull()) {
+ resmsg_audio_t *audio;
+ groupBa = audioGroup.toLatin1();
+ message.audio.group = groupBa.data();
+ qDebug("audio group: %s", message.audio.group);
+ audio = &message.audio;
+ }
+ if (!name.isEmpty() && !name.isNull() && !value.isEmpty() && !value.isNull()) {
+ nameBa = name.toLatin1();
+ valueBa = value.toLatin1();
+ message.audio.property.name = nameBa.data();
+ message.audio.property.match.method = resmsg_method_equals;
+ message.audio.property.match.pattern = valueBa.data();
+ qDebug("audio stream tag is %s:%s", message.audio.property.name, message.audio.property.match.pattern);
+ }
-bool ResourceEngine::sendAudioMessage(resmsg_t *message)
-{
- message->audio.type = RESMSG_AUDIO;
- message->audio.id = resourceSet->id();
- message->audio.reqno = ++requestId;
+ message.audio.type = RESMSG_AUDIO;
+ message.audio.id = resourceSet->id();
+ message.audio.reqno = ++requestId;
- message->audio.type = RESMSG_AUDIO;
+ message.audio.type = RESMSG_AUDIO;
messageMap.insert(requestId, RESMSG_AUDIO);
qDebug("audio %u:%u", resourceSet->id(), requestId);
- int success = resproto_send_message(libresourceSet, message, statusCallbackHandler);
+ int success = resproto_send_message(libresourceSet, &message, statusCallbackHandler);
if(!success)
return false;
diff --git a/libresourceqt/src/resource-engine.h b/libresourceqt/src/resource-engine.h
index 594a20b..6caaef7 100644
--- a/libresourceqt/src/resource-engine.h
+++ b/libresourceqt/src/resource-engine.h
@@ -35,9 +35,8 @@ public:
bool releaseResources();
bool updateResources();
- bool registerAudioPid(quint32 pid);
- bool registerAudioStreamTag(const QString &name, const QString &value);
- bool registerAudioGroup(const QString &);
+ bool registerAudioProperties(const QString &audioGroup, quint32 pid,
+ const QString &name, const QString &value);
void handleConnectionIsUp();
@@ -69,7 +68,6 @@ private:
QMap<quint32, resmsg_type_t> messageMap;
quint32 connectionMode;
- bool sendAudioMessage(resmsg_t *message);
};
}
diff --git a/libresourceqt/src/resource-set.cpp b/libresourceqt/src/resource-set.cpp
index 00a0293..8d2668b 100644
--- a/libresourceqt/src/resource-set.cpp
+++ b/libresourceqt/src/resource-set.cpp
@@ -7,7 +7,7 @@ ResourceSet::ResourceSet(const QString &applicationClass, QObject * parent)
: QObject(parent), resourceClass(applicationClass), resourceEngine(NULL),
audioResource(NULL), autoRelease(false), alwaysReply(false),
initialized(false), pendingAcquire(false), pendingUpdate(false),
- pendingAudioGroup(true), pendingAudioStream(true), pendingAudioPid(true)
+ pendingAudioProperties(false)
{
identifier = (quint32)this;
memset(resourceSet, 0, sizeof(QPointer<Resource *>)*NumberOfTypes);
@@ -57,18 +57,17 @@ void ResourceSet::addResource(Resource *resource)
if (resource->type() == AudioPlaybackType) {
qDebug("audioResource... %p", resource);
audioResource = static_cast<AudioResource *>(resource);
- QObject::connect(audioResource, SIGNAL(pidChanged(quint32)),
- this, SLOT(handleAudioPidChange(quint32)));
- QObject::connect(audioResource, SIGNAL(audioGroupChanged(const QString &)),
- this, SLOT(handleAudioGroupChange(QString)));
- QObject::connect(audioResource, SIGNAL(streamTagChanged(const QString &, const QString &)),
- this, SLOT(handleAudioStreamTagChanged(const QString &, const QString &)));
- if(audioResource->streamTagIsSet())
- pendingAudioStream = true;
- if(audioResource->audioGroupIsSet())
- pendingAudioGroup = true;
- if(audioResource->processID() > 0)
- pendingAudioPid = true;
+ QObject::connect(audioResource,
+ SIGNAL(audioPropertiesChanged(const QString &, quint32,
+ const QString &, const QString &)),
+ this,
+ SLOT(handleAudioPropertiesChanged(const QString &, quint32,
+ const QString &, const QString &)));
+ if(audioResource->streamTagIsSet() || audioResource->audioGroupIsSet() ||
+ (audioResource->processID() > 0))
+ {
+ pendingAudioProperties = true;
+ }
}
delete resourceSet[resource->type()];
resourceSet[resource->type()] = resource;
@@ -204,10 +203,16 @@ bool ResourceSet::alwaysGetReply()
void ResourceSet::connectedHandler()
{
- if (pendingAudioGroup) {
+ if (pendingAudioProperties) {
qDebug() << "registering audio group: " << audioResource->audioGroup();
- resourceEngine->registerAudioGroup(audioResource->audioGroup());
- pendingAudioGroup = false;
+ qDebug() << "registering PID: " << audioResource->processID();
+ qDebug() << "registering audio stream: " << audioResource->streamTagName()
+ << ":" << audioResource->streamTagValue();
+ resourceEngine->registerAudioProperties(audioResource->audioGroup(),
+ audioResource->processID(),
+ audioResource->streamTagName(),
+ audioResource->streamTagValue());
+ pendingAudioProperties = false;
}
if (pendingUpdate) {
resourceEngine->updateResources();
@@ -289,38 +294,17 @@ void ResourceSet::handleResourcesBecameAvailable(quint32 availableResources)
emit resourcesBecameAvailable(listOfResources);
}
-void ResourceSet::handleAudioPidChange(quint32 newPid)
-{
- qDebug("Audio renderer PID = %u", newPid);
- if (initialized && resourceEngine->isConnectedToManager()) {
- qDebug("registering new PID");
- resourceEngine->registerAudioPid(newPid);
- }
- else {
- qDebug("registering PID later...");
- pendingAudioPid = true;
- }
-}
-
-void ResourceSet::handleAudioGroupChange(const QString &newGroup)
+void ResourceSet::handleAudioPropertiesChanged(const QString &group, quint32 pid,
+ const QString &name, const QString &value)
{
- qDebug() << "Audio group changed to: " << newGroup;
+ qDebug() << "Audio group is: " << group;
+ qDebug("Audio renderer PID = %u", pid);
if (initialized && resourceEngine->isConnectedToManager()) {
- qDebug("registering new audio group");
- resourceEngine->registerAudioGroup(newGroup);
+ qDebug("registering new audio settings");
+ resourceEngine->registerAudioProperties(group, pid, name, value);
}
else {
qDebug("registering new audio group LATER");
- pendingAudioGroup = true;
- }
-}
-
-void ResourceSet::handleAudioStreamTagChanged(const QString &name, const QString &value)
-{
- if (initialized && resourceEngine->isConnectedToManager()) {
- resourceEngine->registerAudioStreamTag(name, value);
- }
- else {
- pendingAudioStream = true;
+ pendingAudioProperties = true;
}
}