Permalink
Browse files

Remove unneeded sound modules and cleanup the .pro file

The sound modules weren't used in webappmanager, so can be removed,
plus the references to them in the .pro file.
Also removed references to unused #defines in the .pro file.

When built with Qt5, now includes QtWebkitWidget in the pri files.

Removed reference to serviceinstaller from the device.pri file

Open-webOS-DCO-1.0-Signed-off-by: Roger Stringer <roger.stringer@palm.com>

Change-Id: I2e43da62427722e2953266e56329d1042e439886
  • Loading branch information...
1 parent a300a29 commit cb164ae01334fae7eb6798603524936d251c758f @RS102839 RS102839 committed Jan 20, 2013
View
618 Src/sound/SoundPlayer.cpp
@@ -1,618 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#include "Common.h"
-
-#include "SoundPlayer.h"
-
-#include <map>
-#include <algorithm>
-#include <sys/prctl.h>
-
-#include "HostBase.h"
-#include "SoundPlayerPool.h"
-#include "Utils.h"
-#include "Logging.h"
-
-#define TRACE_DEBUG_THIS_FILE 0
-#define USE_COLOR_PRINTF 1
-
-#if TRACE_DEBUG_THIS_FILE
- #if USE_COLOR_PRINTF
- #define COLORESCAPE "\033["
- #define RESETCOLOR COLORESCAPE "0m"
- #define BOLDCOLOR COLORESCAPE "1m"
- #define REDOVERBLACK COLORESCAPE "1;31m"
- #define BLUEOVERBLACK COLORESCAPE "1;34m"
- #define YELLOWOVERBLACK COLORESCAPE "1;33m"
- #else
- #define COLORESCAPE
- #define RESETCOLOR
- #define BOLDCOLOR
- #define REDOVERBLACK
- #define BLUEOVERBLACK
- #define YELLOWOVERBLACK
- #endif
- #define PRINTF(fmt, args...) printf("%s: " fmt "\n", getTimeStamp(), ## args)
- #define PRINTF_RED(fmt, args...) printf(REDOVERBLACK "%s: " fmt RESETCOLOR "\n", getTimeStamp(), ## args)
- #define PRINTF_BLUE(fmt, args...) printf(BLUEOVERBLACK "%s: " fmt RESETCOLOR "\n", getTimeStamp(), ## args)
- #define PRINTF_YELLOW(fmt, args...) printf(YELLOWOVERBLACK "%s: " fmt RESETCOLOR "\n", getTimeStamp(), ## args)
- #define PRINTF_BOLD(fmt, args...) printf(BOLDCOLOR "%s: " fmt RESETCOLOR "\n", getTimeStamp(), ## args)
-
- #define DEBUG PRINTF
- #define MESSAGE PRINTF_BLUE
- #define WARNING PRINTF_YELLOW
- #define CRITICAL PRINTF_RED
-
-static const char * getTimeStamp()
-{
- static bool sInited = false;
- static struct timespec sLogStartSeconds = { 0 };
- static struct tm sLogStartTime = { 0 };
- if (!sInited)
- {
- time_t now = ::time(0);
- ::clock_gettime(CLOCK_MONOTONIC, &sLogStartSeconds);
- ::localtime_r(&now, &sLogStartTime);
- sInited = true;
- }
- struct timespec now;
- ::clock_gettime(CLOCK_MONOTONIC, &now);
- int ms = (now.tv_nsec - sLogStartSeconds.tv_nsec) / 1000000;
- int sec = sLogStartTime.tm_sec + int (now.tv_sec - sLogStartSeconds.tv_sec);
- if (ms < 0)
- {
- ms += 1000;
- --sec;
- }
- int min = sLogStartTime.tm_min + sec / 60;
- int hr = sLogStartTime.tm_hour + min / 60;
- min = min % 60;
- sec = sec % 60;
- static char sTimeStamp[128];
- ::sprintf(sTimeStamp, "%02d:%02d:%02d.%03d", hr, min, sec, ms);
- return sTimeStamp;
-}
-
-#else
- #define PRINTF(fmt, args...) (void)0
- #define PRINTF_RED(fmt, args...) (void)0
- #define PRINTF_BLUE(fmt, args...) (void)0
- #define PRINTF_YELLOW(fmt, args...) (void)0
- #define PRINTF_BOLD(fmt, args...) (void)0
-
- #define DEBUG g_debug
- #define MESSAGE g_message
- #define WARNING g_warning
- #define CRITICAL g_critical
-#endif
-
-int SoundPlayer::m_numInstances = 0;
-int SoundPlayer::m_activityCount = 0;
-
-#ifdef BOOST_NO_EXCEPTIONS
-#include <exception>
-void boost::throw_exception(std::exception const&)
-{ abort(); } //this function is supposed to never return, so abort() seems appropriate.
-#endif
-
-/**
- * Constructor: register proxy listener
- */
-SoundPlayer::SoundPlayer()
- : m_serviceHandle(0)
- , m_retries(0)
- , m_state(eState_Init)
- , m_fakeBackupRingtoneCount(0)
- , m_timer(HostBase::instance()->masterTimer(), this, &SoundPlayer::healthCheck)
- , m_activityID(0)
-{
- PRINTF_BLUE("SoundPlayer::SoundPlayer(%d)", getpid());
- m_mediaPlayerChangeListener = boost::shared_ptr<MediaPlayerChangeListener>(new SoundPlayerMediaPlayerChangeListener(this));
-}
-
-/**
- * Destructor: Stop anything we have going & disconnect proxy listener
- */
-SoundPlayer::~SoundPlayer()
-{
- PRINTF_BLUE("SoundPlayer::~SoundPlayer(%s)", getStateName());
- if (m_state == eState_PlayPending || m_state == eState_Playing)
- stop();
-
- if (m_player.get()) {
- m_player->removeMediaPlayerChangeListener(m_mediaPlayerChangeListener);
- m_player.reset((media::MediaPlayer*) 0);
- }
-
- // Important: Make sure to call this before the service handle destuction
- if (m_mediaPlayerChangeListener.get())
- m_mediaPlayerChangeListener.reset((media::MediaPlayerChangeListener*)0);
-
- if (m_serviceHandle) {
- LSError lserror;
- LSErrorInit(&lserror);
- if (!LSUnregisterPalmService(m_serviceHandle, &lserror)) {
- LSErrorPrint (&lserror, stderr);
- LSErrorFree (&lserror);
- }
-
- m_serviceHandle = 0;
- }
-}
-
-/**
- * Client request entry point
- */
-void SoundPlayer::play(const std::string& filePath, const std::string& streamClass, bool repeat, int duration)
-{
- WARNING("SoundPlayer::play(%s): %p: filePath: %s, streamClass: %s, repeat: %d, duration: %d",
- getStateName(), this, filePath.c_str(), streamClass.c_str(), repeat, duration);
-
- if (m_state == eState_Dead)
- {
- CRITICAL("SoundPlayer::play(%s): This player can not be reused!", getStateName());
- return;
- }
-
- if (m_state != eState_Init)
- stop();
-
- // recycling? move state machine back
- if (m_state == eState_Finished)
- setState(eState_Connected);
-
- m_filePath = filePath;
- m_streamClass = streamClass;
- m_audioStreamClass = kAudioStreamMedia;
-
- if (!m_streamClass.empty())
- {
- if (m_streamClass == "ringtones")
- m_audioStreamClass = kAudioStreamRingtone;
-
- else if (m_streamClass == "alarm")
- m_audioStreamClass = kAudioStreamAlarm;
-
- else if (m_streamClass == "alerts")
- m_audioStreamClass = kAudioStreamAlert;
-
- else if (m_streamClass == "notifications")
- m_audioStreamClass = kAudioStreamNotification;
-
- else if (m_streamClass == "calendar")
- m_audioStreamClass = kAudioStreamCalendar;
-
- else if (m_streamClass == "media")
- m_audioStreamClass = kAudioStreamMedia;
-
- else if (m_streamClass == "voicedial")
- m_audioStreamClass = kAudioStreamVoicedial;
-
- else if (m_streamClass == "flash")
- m_audioStreamClass = kAudioStreamFlash;
-
- else if (m_streamClass == "navigation")
- m_audioStreamClass = kAudioStreamNavigation;
-
- else if (m_streamClass == "defaultapp")
- m_audioStreamClass = kAudioStreamDefaultapp;
-
- else if (m_streamClass == "feedback")
- m_audioStreamClass = kAudioStreamFeedback;
-
- else
- {
- WARNING("SoundPlayer::play: unrecognized media class '%s' for '%s'. Will use media class.", streamClass.c_str(), filePath.c_str());
- m_audioStreamClass = kAudioStreamMedia;
- }
- }
-
- m_repeat = repeat;
- m_duration = float(duration) / 1000.f; // integer ms to float seconds
- checkForNextStep();
-}
-
-/**
- * Client side cancel point. Also used internally.
- */
-void SoundPlayer::stop()
-{
- PRINTF_BLUE("SoundPlayer::stop(%s)", getStateName());
- if (m_state == eState_PlayPending || m_state == eState_Playing)
- {
- if (VERIFY(m_player))
- {
- m_player->pause();
- m_player->unload();
- }
- setState(eState_Closing);
- }
- else
- { // not sure why we were not playing: don't take chance...
- WARNING("SoundPlayer::stop(%s): unexpected stop request. Declaring SoundPlayer object dead.", getStateName());
- setState(eState_Dead);
- }
- m_filePath.clear();
- m_streamClass.clear();
- m_lastPlayingTime = currentTime();
- m_fakeBackupRingtoneCount = 0;
- if (m_activityID)
- {
- gchar * request = g_strdup_printf("{\"id\":\"com.palm.sysmgr.soundplayer.%i\"}", m_activityID);
-
- LSError lserror;
- LSErrorInit(&lserror);
- bool activityStartRequestSuccess = LSCall(getServiceHandle(), "palm://com.palm.power/com/palm/power/activityEnd", request, NULL, NULL, NULL, &lserror);
- if (!activityStartRequestSuccess)
- {
- CRITICAL("SoundPlayer::stop: activity '%s' End failed", request);
- LSErrorPrint (&lserror, stderr);
- LSErrorFree (&lserror);
- }
- else
- DEBUG("SoundPlayer::stop: ended activity '%s'...", request);
-
- g_free(request);
- m_activityID = 0;
- }
-}
-
-/**
- * Connect to mediaserver using lunaservice.
- */
-LSPalmService* SoundPlayer::connectToBus()
-{
- PRINTF_BLUE("SoundPlayer::connectToBus(%s)", getStateName());
- VERIFY(m_state == eState_Connecting);
- setState(eState_Connecting);
-
- if (m_serviceHandle)
- return m_serviceHandle;
-
- bool result = true;
- LSError lserror;
- LSErrorInit(&lserror);
-
- result = LSRegisterPalmService(NULL, &m_serviceHandle, &lserror);
- if (!result)
- {
- CRITICAL("SoundPlayer::connectToBus: Could not register SoundPlayer");
- LSErrorPrint(&lserror, stderr);
- LSErrorFree(&lserror);
- // Make next health check fail ASAP...
- m_lastPlayingTime = 0;
- return NULL;
- }
-
- result = LSGmainAttachPalmService (m_serviceHandle, HostBase::instance()->mainLoop(), &lserror);
- if (!result)
- {
- CRITICAL("SoundPlayer::connectToBus: Could not attach SoundPlayer to main loop");
- LSErrorPrint(&lserror, stderr);
- LSErrorFree(&lserror);
- // Make next health check fail ASAP...
- m_lastPlayingTime = 0;
- return NULL;
- }
- return m_serviceHandle;
-}
-
-/**
- * This simply loads the media source URI and plays it.
- */
-void SoundPlayer::connected() {
- PRINTF_BLUE("SoundPlayer::connected(%s): loading '%s', as '%s'", getStateName(), m_filePath.c_str(), m_streamClass.c_str());
- if (VERIFY(m_state == eState_Connecting))
- setState(eState_Connected);
- checkForNextStep();
-}
-
-/**
- * Playback is moving
- */
-void SoundPlayer::currentTimeChanged()
-{
- if (VERIFY(m_player))
- {
- PRINTF_BOLD("SoundPlayer::currentTimeChanged(%s): %f sec", getStateName(), m_player->getCurrentTime());
- if (m_state == eState_PlayPending || m_state == eState_Playing)
- {
- setState(eState_Playing);
- m_lastPlayingTime = currentTime();
- if (!m_repeat && m_duration > 0 && m_player->getCurrentTime() >= m_duration)
- stop();
- }
- }
-}
-
-/**
- * The end of the stream has been reached (i.e. we played the entire stream).
- */
-void SoundPlayer::eosChanged()
-{
- if (VERIFY(m_player) && m_player->getEos()) {
- PRINTF_BLUE("SoundPlayer::eosChanged(%s): EOS", getStateName());
- if (m_state == eState_PlayPending || m_state == eState_Playing)
- {
- if (m_repeat)
- {
- m_player->seek(0);
- m_player->play();
- }
- else
- stop();
- }
- }
-}
-
-/**
- * The object we are playing was changed.
- */
-void SoundPlayer::sourceChanged()
-{
- if (!VERIFY(m_player))
- return;
- PRINTF_BLUE("SoundPlayer::sourceChanged(%s): '%s'", getStateName(), m_player->getSource().c_str());
- if (m_player->getSource().empty() && m_state == eState_Closing)
- {
- setState(eState_Connected);
- checkForNextStep();
- }
-}
-
-/**
- * Errors occur asynchronously. If an error occurs, this will be called.
- */
-void SoundPlayer::errorChanged()
-{
- if (!VERIFY(m_player))
- return;
- if (m_player->getError() != NO_ERROR)
- {
- CRITICAL("SoundPlayer::errorChanged(%s): %d", getStateName(), m_player->getError());
- onError();
- }
-}
-
-/**
- * Errors occur asynchronously. If an error occurs, this will be called.
- */
-void SoundPlayer::extendedErrorChanged()
-{
- if (!VERIFY(m_player))
- return;
- if (!m_player->getExtendedError().empty())
- {
- CRITICAL("SoundPlayer::extendedErrorChanged(%s): '%s'", getStateName(), m_player->getExtendedError().c_str());
- onError();
- }
-}
-
-/**
- * In case of error, try again
- */
-void SoundPlayer::onError()
-{
- if (VERIFY(m_player) && eState_PlayPending && m_retries++ < 3)
- {
- m_player->unload();
- m_player->load(getURI(), m_audioStreamClass);
- m_player->seek(0);
- m_player->play();
- }
-}
-
-/**
- * Set the state of the player
- */
-void SoundPlayer::setState(EState state)
-{
- // dead is dead...
- if (m_state != eState_Dead)
- {
- if (state != m_state)
- {
- if ((state == eState_Dead || state == eState_Finished) && (m_state != eState_Dead && m_state != eState_Finished))
- {
- m_timer.stop();
- SoundPlayerPool::instance()->queueFinishedPlayer(this);
- }
- }
- m_state = state;
- }
-}
-
-/**
- * Check if we can advance the state machine by loading or playing
- */
-void SoundPlayer::checkForNextStep()
-{
- if (m_state == eState_Init)
- {
- if (!m_filePath.empty() && VERIFY(m_player == 0))
- {
- setState(eState_Connecting);
- startTimer();
- m_player = media::MediaClient::createLunaMediaPlayer(*this);
- m_player->addMediaPlayerChangeListener(m_mediaPlayerChangeListener);
- }
- }
- else if (m_state == eState_Connected)
- {
- if (m_filePath.empty())
- { // if we had any problem, don't recycle this player...
- if (m_retries == 0)
- setState(eState_Finished);
- else
- setState(eState_Dead);
- }
- else if (VERIFY(m_player))
- {
- setState(eState_PlayPending);
- startTimer();
- m_player->load(getURI(), m_audioStreamClass);
- m_player->play();
- }
- }
-}
-
-/**
- * Simply start the healthCheck timer with a single refresh setting
- * Also start activity if necessary
- */
-void SoundPlayer::startTimer()
-{
- if (!m_timer.running())
- {
- m_timer.start(1000, false);
- m_activityID = ++m_activityCount;
-
- gchar * request = g_strdup_printf("{\"id\":\"com.palm.sysmgr.soundplayer.%i\",\"duration_ms\":60000}", m_activityID);
-
- LSError lserror;
- LSErrorInit(&lserror);
- bool activityStartRequestSuccess = LSCall(getServiceHandle(), "palm://com.palm.power/com/palm/power/activityStart", request, NULL, NULL, NULL, &lserror);
- if (!activityStartRequestSuccess)
- {
- CRITICAL("SoundPlayer::startTimer: activity '%s' Start failed", request);
- LSErrorPrint (&lserror, stderr);
- LSErrorFree (&lserror);
- }
- else
- DEBUG("SoundPlayer::startTimer: booked activity '%s'...", request);
-
- g_free(request);
- }
- m_lastPlayingTime = currentTime();
-}
-
-static const guint64 cConnectDelay = 8000;
-static const guint64 cLoadDelay = 3000;
-static const guint64 cPlayDelay = 1000;
-static const guint64 cCloseDelay = 2000;
-
-/**
- * Check that we aren't stuck waiting, while loading or playing...
- */
-bool SoundPlayer::healthCheck()
-{
- DEBUG("SoundPlayer::healthCheck(%s, %llu ms)", getStateName(), currentTime() - m_lastPlayingTime);
- if (!m_filePath.empty() && // we are supposed to play something
- ( (m_state == eState_Connecting && m_lastPlayingTime + cConnectDelay < currentTime()) || // but we can't connect, or
- (m_state == eState_PlayPending && m_lastPlayingTime + cLoadDelay < currentTime()) || // we can't load the file, or
- (m_state == eState_Playing && m_lastPlayingTime + cPlayDelay < currentTime()))) // we can't play the file
- {
- if (m_fakeBackupRingtoneCount == 0)
- { // log failure, when it first happens
- CRITICAL("SoundPlayer::healthCheck(%s): can't play '%s' as %s for %llu ms", getStateName(),
- m_filePath.c_str(), m_streamClass.c_str(), currentTime() - m_lastPlayingTime);
- m_retries++; // we failed to play. Remember this, so that we won't recycle this player.
- }
- if (m_audioStreamClass == kAudioStreamRingtone || m_audioStreamClass == kAudioStreamAlarm)
- { // back ringtone for ringtones & alarms
- if (m_fakeBackupRingtoneCount == 0)
- WARNING("SoundPlayer::healthCheck: using backup ringtone using alert notifications!");
- // Don't use alarm & ringtone sinks, because they trigger a ringtone vibration, which we are faking here!
- if ((m_fakeBackupRingtoneCount++ % 5) < 3)
- SoundPlayerPool::instance()->playFeedback("sysmgr_notification", "palerts"); // let's hope audiod & pulse are ok!
- }
- else if (m_audioStreamClass == kAudioStreamNotification)
- {
- WARNING("SoundPlayer::healthCheck: using default notification instead!");
- stop();
- SoundPlayerPool::instance()->playFeedback("sysmgr_alert", "palerts"); // let's hope audiod & pulse are ok!
- }
- else if (m_audioStreamClass == kAudioStreamCalendar)
- {
- WARNING("SoundPlayer::healthCheck: using default notification instead!");
- stop();
- SoundPlayerPool::instance()->playFeedback("sysmgr_alert", "pcalendar"); // let's hope audiod & pulse are ok!
- }
- else if (m_audioStreamClass == kAudioStreamAlert)
- {
- WARNING("SoundPlayer::healthCheck: using default alert instead!");
- stop();
- SoundPlayerPool::instance()->playFeedback("sysmgr_alert", "palerts"); // let's hope audiod & pulse are ok!
- }
- }
- else if (m_state == eState_Closing && m_lastPlayingTime + cCloseDelay < currentTime())
- {
- WARNING("SoundPlayer::healthCheck(%s): can't close for %llu ms. Declaring SoundPlayer object dead.", getStateName(), currentTime() - m_lastPlayingTime);
- setState(eState_Dead);
- }
- else
- {
- m_fakeBackupRingtoneCount = 0;
- }
-
- return true; // return true to repeat
-}
-
-/**
- * Return URI based on file name or URI
- */
-string SoundPlayer::getURI()
-{
- string uri;
- if (m_filePath.size() > 0 && m_filePath[0] == '/')
- uri = "file://" + m_filePath;
- else
- uri = m_filePath;
- return uri;
-}
-
-/**
- * Name of current state for tracing purposes
- */
-const char * SoundPlayer::getStateName()
-{
- switch (m_state)
- {
- case eState_Init: return "Init";
- case eState_Connecting: return "Connecting";
- case eState_Connected: return "Connected";
- case eState_PlayPending: return "Play Pending";
- case eState_Playing: return "Playing";
- case eState_Closing: return "Closing";
- case eState_Finished: return "Finished";
- case eState_Dead: return "Dead";
- }
- return "< ??? State ??? >";
-}
-
-/**
- * Current time in ms
- */
-guint64 SoundPlayer::currentTime()
-{
- struct timespec now;
- ::clock_gettime(CLOCK_MONOTONIC, &now);
- return guint64(now.tv_sec) * 1000ULL + guint64(now.tv_nsec) / 1000000ULL;
-}
-
-/**
- * Minor utility function
- */
-LSHandle * SoundPlayer::getServiceHandle()
-{
- return SoundPlayerPool::instance()->m_lsHandle;
-}
View
173 Src/sound/SoundPlayer.h
@@ -1,173 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#ifndef SOUNDPLAYER_H
-#define SOUNDPLAYER_H
-
-#include "Common.h"
-
-#include <string>
-#include <list>
-#include <glib.h>
-#include <pthread.h>
-
-#include "sptr.h"
-
-/**
- * these need to be define since qemux86 still uses gcc 4.2.1
- */
-#define BOOST_NO_TYPEID
-#define BOOST_NO_RTTI
-
-#include <media/LunaConnector.h>
-#include <media/MediaClient.h>
-#include <media/MediaPlayer.h>
-
-#include "Timer.h"
-
-using namespace media;
-using namespace boost;
-using namespace std;
-
-/**
- * Simple media playback class to demonstrate a possible way to connect up to the
- * luna bus and use a MediaPlayer object.
- */
-class SoundPlayer : public RefCounted, public LunaConnector {
-
- /*
- * This listener merely forwards notifications to SoundPlayer object
- * Can't use multiple inheritance, because it's refcounted via boost::shared_ptr
- */
- class SoundPlayerMediaPlayerChangeListener : public MediaPlayerChangeListener
- {
- public:
- SoundPlayerMediaPlayerChangeListener(SoundPlayer * player) : m_soundPlayer(player) {}
-
- void disconnect() { m_soundPlayer = 0; }
-
- virtual void currentTimeChanged() { if (m_soundPlayer) m_soundPlayer->currentTimeChanged(); }
- virtual void eosChanged() { if (m_soundPlayer) m_soundPlayer->eosChanged(); }
- virtual void sourceChanged() { if (m_soundPlayer) m_soundPlayer->sourceChanged(); }
- virtual void errorChanged() { if (m_soundPlayer) m_soundPlayer->errorChanged(); }
- virtual void extendedErrorChanged() { if (m_soundPlayer) m_soundPlayer->extendedErrorChanged(); }
-
- private:
- SoundPlayer * m_soundPlayer;
- };
-
- enum EState
- {
- // Created, but nothing happened yet
- eState_Init,
-
- // Waiting for connection
- eState_Connecting,
-
- // Connected, waiting for a request
- eState_Connected,
-
- // Play request sent, but not playing yet
- eState_PlayPending,
-
- // Playing. Audio is flowing out...
- eState_Playing,
-
- // Stop request issued. Waiting for completion
- eState_Closing,
-
- // Done: we're all done successfully (you can try to reuse us)
- eState_Finished,
-
- // Dead: we're finished (successful or not), and don't try to use us again!
- eState_Dead
- };
-
-public:
-
- /**
- * Construct a player to play the media content at the given URI.
- */
- SoundPlayer();
- ~SoundPlayer();
-
- void play(const std::string& filePath, const std::string& streamClass, bool repeat, int duration);
- void stop();
-
- bool dead() const { return m_state == eState_Dead; }
-
- static int m_numInstances; // to keep count of number of instantiations
-
-protected:
-
- /**
- * LunaConnector callback methods
- */
-
- virtual LSPalmService * connectToBus();
- virtual void connected();
-
- /**
- * MediaPlayerChangeListener callbacks methods
- */
-
- void currentTimeChanged();
- void eosChanged();
- void sourceChanged();
- void errorChanged();
- void extendedErrorChanged();
-
-private:
- /**
- * Internal implementation methods
- */
- bool healthCheck();
- void checkForNextStep();
- void setState(EState state);
- const char * getStateName();
- guint64 currentTime();
- void startTimer();
- string getURI();
- void onError();
-
- LSHandle * getServiceHandle();
-
-private:
- shared_ptr<MediaPlayer> m_player;
- LSPalmService* m_serviceHandle;
- string m_filePath;
- string m_streamClass;
- AudioStreamClass m_audioStreamClass;
- bool m_repeat;
- int m_retries;
- float m_duration;
- EState m_state;
- guint64 m_lastPlayingTime;
- int m_fakeBackupRingtoneCount;
- boost::shared_ptr<MediaPlayerChangeListener> m_mediaPlayerChangeListener;
-
- Timer<SoundPlayer> m_timer;
- int m_activityID;
-
- static int m_activityCount;
-};
-
-#endif /* SOUNDPLAYER_H */
View
46 Src/sound/SoundPlayerDummy.cpp
@@ -1,46 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#include "Common.h"
-
-#include "SoundPlayerDummy.h"
-
-int SoundPlayer::m_numInstances = 0;
-
-SoundPlayer::SoundPlayer()
-{
- m_numInstances++;
-}
-
-SoundPlayer::~SoundPlayer()
-{
- m_numInstances--;
-}
-
-void SoundPlayer::play(const std::string& filePath, const std::string& streamClass, bool repeat, int duration)
-{
-
-}
-
-void SoundPlayer::stop()
-{
-
-}
View
54 Src/sound/SoundPlayerDummy.h
@@ -1,54 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#ifndef SOUNDPLAYERDUMMY_H
-#define SOUNDPLAYERDUMMY_H
-
-#include "Common.h"
-
-#include <string>
-
-#include "sptr.h"
-
-/**
- * Simple media playback class to demonstrate a possible way to connect up to the
- * luna bus and use a MediaPlayer object.
- */
-class SoundPlayer : public RefCounted
-{
-public:
-
- /**
- * Construct a player to play the media content at the given URI.
- */
- SoundPlayer();
- ~SoundPlayer();
-
- void play(const std::string& filePath, const std::string& streamClass, bool repeat, int duration);
- void stop();
-
- bool dead() const { return true; }
-
- static int m_numInstances; // to keep count of number of instantiations
-};
-
-
-#endif /* SOUNDPLAYERDUMMY_H */
View
209 Src/sound/SoundPlayerPool.cpp
@@ -1,209 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#include "Common.h"
-
-#include "SoundPlayerPool.h"
-#include <algorithm>
-#include <cjson/json.h>
-
-#include "HostBase.h"
-#include "Preferences.h"
-
-static SoundPlayerPool* s_instance = 0;
-static const int kMaxPooledPlayers = 0;
-static const int kMaxPlayers = 5;
-
-SoundPlayerPool* SoundPlayerPool::instance()
-{
- if (!s_instance)
- new SoundPlayerPool;
-
- return s_instance;
-}
-
-SoundPlayerPool::SoundPlayerPool()
- : m_purgeTimer(HostBase::instance()->masterTimer(), this, &SoundPlayerPool::purgeTimerFired)
-{
- s_instance = this;
-
- bool ret;
- LSError error;
- LSErrorInit(&error);
-
- ret = LSRegister(NULL, &m_lsHandle, &error);
- if (!ret) {
- g_warning("Failed to register handler: %s", error.message);
- LSErrorFree(&error);
- return;
- }
-
- ret = LSGmainAttach(m_lsHandle, HostBase::instance()->mainLoop(), &error);
- if (!ret) {
- g_warning("Failed to attach service to main loop: %s", error.message);
- LSErrorFree(&error);
- return;
- }
-}
-
-SoundPlayerPool::~SoundPlayerPool()
-{
- s_instance = 0;
-
- // no-op
-}
-
-sptr<SoundPlayer> SoundPlayerPool::play(const std::string& filePath,
- const std::string& streamClass,
- bool repeat, int duration)
-{
- sptr<SoundPlayer> player = getPooledPlayer();
- if (!player.get()) {
- if (SoundPlayer::m_numInstances >= kMaxPlayers) {
- g_warning ("Exceeded maximum instances of sound players %d, ignoring request", kMaxPlayers);
- return 0;
- }
-
- player = new SoundPlayer;
- }
-
- // Add to list of active players
- m_activePlayers.push_back(player);
-
- player->play(filePath, streamClass, repeat, duration);
-
- return player;
-}
-
-void SoundPlayerPool::stop(sptr<SoundPlayer> player)
-{
- if (player.get())
- player->stop();
-
- // once the player is asynchronously closed, it will add
- // itself to the pool of dormant clients
-}
-
-void SoundPlayerPool::playFeedback(const std::string& name,
- const std::string& sinkName)
-{
- if (sinkName.empty() && !Preferences::instance()->playFeedbackSounds())
- return;
-
- bool ret;
- LSError error;
- LSErrorInit(&error);
-
- if (!m_lsHandle)
- return;
-
- json_object* json = json_object_new_object();
- json_object_object_add(json, "name", json_object_new_string(name.c_str()));
-
- if (!sinkName.empty())
- json_object_object_add(json, "sink", json_object_new_string(sinkName.c_str()));
-
- ret = LSCall(m_lsHandle, "palm://com.palm.audio/systemsounds/playFeedback",
- json_object_to_json_string(json), NULL, NULL, NULL, &error);
- if (!ret) {
- g_warning("Failed in playFeedback call: %s", error.message);
- LSErrorFree(&error);
- }
- json_object_put(json);
-}
-
-void SoundPlayerPool::queueFinishedPlayer(sptr<SoundPlayer> player)
-{
- // Add to list of finished players
- bool foundInFinishedPlayers = false;
- for (PlayerList::const_iterator it = m_finishedPlayers.begin();
- it != m_finishedPlayers.end(); ++it) {
- if (it->get() == player.get()) {
- foundInFinishedPlayers = true;
- break;
- }
- }
-
- if (!foundInFinishedPlayers)
- m_finishedPlayers.push_back(player);
-
- // Remove from list of active players
- for (PlayerList::iterator it = m_activePlayers.begin(); it != m_activePlayers.end(); ++it) {
- if (it->get() == player.get()) {
- m_activePlayers.erase(it);
- break;
- }
- }
-
- if (!m_purgeTimer.running())
- m_purgeTimer.start(0);
-}
-
-bool SoundPlayerPool::purgeTimerFired()
-{
- PlayerList::iterator it;
-
- // First delete all dead players
- it = m_finishedPlayers.begin();
- while (it != m_finishedPlayers.end()) {
-
- if ((*it)->dead())
- it = m_finishedPlayers.erase(it);
- else
- ++it;
- }
-
- int count = m_finishedPlayers.size();
- it = m_finishedPlayers.begin();
- while (it != m_finishedPlayers.end()) {
-
- if (count <= kMaxPooledPlayers)
- break;
-
- it = m_finishedPlayers.erase(it);
- }
-
- return false;
-}
-
-sptr<SoundPlayer> SoundPlayerPool::getPooledPlayer()
-{
-/*
- PlayerList::iterator it = m_finishedPlayers.begin();
- while (it != m_finishedPlayers.end()) {
-
- sptr<SoundPlayer> player = (*it);
- // explicitly remove from dormant set
- it = m_finishedPlayers.erase(it);
-
- if (player->dead())
- continue;
-
- return player;
- }
-
- return 0;
-*/
-
- // No pooling: mediaserver cannot handle back to back playbacks
- // on the same client very well
- return 0;
-}
View
74 Src/sound/SoundPlayerPool.h
@@ -1,74 +0,0 @@
-/* @@@LICENSE
-*
-* Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* LICENSE@@@ */
-
-
-
-
-#ifndef SOUNDPLAYERPOOL_H
-#define SOUNDPLAYERPOOL_H
-
-#include "Common.h"
-
-#include <list>
-#include <string>
-#include <lunaservice.h>
-
-#include "sptr.h"
-#include "Timer.h"
-
-#if defined(TARGET_DESKTOP) || defined(TARGET_EMULATOR)
-#include "SoundPlayerDummy.h"
-#else
-#include "SoundPlayer.h"
-#endif
-
-class SoundPlayerPool
-{
-public:
-
- static SoundPlayerPool* instance();
-
- sptr<SoundPlayer> play(const std::string& filePath,
- const std::string& streamClass,
- bool repeat, int duration);
- void stop(sptr<SoundPlayer> player);
-
- void playFeedback(const std::string& name, const std::string& sinkName=std::string());
-
-private:
-
- SoundPlayerPool();
- ~SoundPlayerPool();
-
- void queueFinishedPlayer(sptr<SoundPlayer> player);
- bool purgeTimerFired();
- sptr<SoundPlayer> getPooledPlayer();
-
-private:
-
- typedef std::list<sptr<SoundPlayer> > PlayerList;
-
- PlayerList m_activePlayers;
- PlayerList m_finishedPlayers;
- LSHandle* m_lsHandle;
- Timer<SoundPlayerPool> m_purgeTimer;
-
- friend class SoundPlayer;
-};
-
-#endif /* SOUNDPLAYERPOOL_H */
View
8 desktop.pri
@@ -1,6 +1,6 @@
# @@@LICENSE
#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
+# Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ TOP_DIR_ABS = $$system(cd $$TOP_DIR_REL; pwd)
WEBKIT_PATH = $$(WEBKIT_PATH)
isEmpty (WEBKIT_PATH) {
- WEBKIT_PATH = $$TOP_DIR_ABS/webkit4v8
+ WEBKIT_PATH = $$TOP_DIR_ABS/webkit4v8
}
DEFINES += TARGET_DESKTOP
@@ -71,7 +71,9 @@ INCLUDEPATH += \
$$(LUNA_STAGING)/include/luna-sysmgr-common \
$$(LUNA_STAGING)/usr/include
-
+contains(QT_VERSION, "^5.*") {
+ INCLUDEPATH += $$(LUNA_STAGING)/include/QtWebKitWidgets
+}
#install
target.path = $$(LUNA_STAGING)/bin
View
16 device.pri
@@ -1,6 +1,6 @@
# @@@LICENSE
#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
+# Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -45,6 +45,10 @@ INCLUDEPATH += \
$$(STAGING_INCDIR)/luna-sysmgr-common \
$$(STAGING_INCDIR)/ime \
+contains(QT_VERSION, "^5.*") {
+ INCLUDEPATH += $$(STAGING_INCDIR)/QtWebKitWidgets
+}
+
LIBS += -Wl,-rpath $$(STAGING_LIBDIR)
DEFINES += $$TARGET_TYPE HAS_LUNA_PREF=1 QT_PLUGIN QT_STATICPLUGIN HAS_QPA
@@ -69,25 +73,15 @@ include(device-known.pri)
contains(CONFIG_BUILD, webosdevice) {
## Known Device
- LIBS += -lserviceinstaller
} else {
warning($$MACHINE_NAME not matched in device-known.pri)
## Set this if you have nyx-modules for your build target (Highly recommended)
CONFIG_BUILD += nyx
- ## Set this if you have media-api to handle sound
- # CONFIG_BUILD += mediaapi
-
## You must have a QPA or can use the standard QPA (change the LIBS value to your QPA library)
LIBS += -lqpalm
- ## Activate ServiceInstaller, if available for your build target
- # LIBS += -lserviceinstaller
-
- ## Set this if you have libnapp and nrwindow available for your build target
- # CONFIG_BUILD += napp
-
}
## End of custom configuration for unknown build target
View
6 emulator.pri
@@ -1,6 +1,6 @@
# @@@LICENSE
#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
+# Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -66,6 +66,10 @@ contains (CONFIG_BUILD, webosemulator) {
$$(STAGING_INCDIR)/ime \
$$(STAGING_INCDIR)/luna-sysmgr-common \
+ contains(QT_VERSION, "^5.*") {
+ INCLUDEPATH += $$(STAGING_INCDIR)/QtWebKitWidgets
+ }
+
} else {
warning($$MACHINE_NAME not matched in emulator.pri)
}
View
44 webappmgr.pro
@@ -1,6 +1,6 @@
# @@@LICENSE
#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
+# Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -71,11 +71,6 @@ DEFINES += QT_WEBOS
# For shipping version of the code, as opposed to a development build. Set this to 1 late in the process...
DEFINES += SHIPPING_VERSION=0
-# Uncomment to compile in trace statements in the code for debugging
-# DEFINES += ENABLE_TRACING
-
-# DEFINES += HAVE_CALLGRIND=1
-
# This allows the use of the % for faster QString concatentation
# See the QString documentation for more information
# DEFINES += QT_USE_FAST_CONCATENATION
@@ -135,7 +130,6 @@ HEADERS += \
ProcessManager.h \
RemoteWindowData.h \
SharedGlobalProperties.h \
- SoundPlayerPool.h \
SyncTask.h \
SysMgrWebBridge.h \
SystemUiController.h \
@@ -158,6 +152,7 @@ QMAKE_CXXFLAGS += -DFIX_FOR_QT
QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-parameter -Wno-unused-variable -Wno-reorder -Wno-missing-field-initializers -Wno-extra
LIBS += -lcjson -lLunaSysMgrIpc -llunaservice -lpbnjson_cpp -lssl -lsqlite3 -lssl -lcrypto # -lgcov
+LIBS += -lLunaSysMgrCommon
linux-g++ {
include(desktop.pri)
@@ -222,56 +217,21 @@ else {
HEADERS += RemoteWindowDataSoftwareQt.h
}
-contains(CONFIG_BUILD, fb1poweroptimization) {
- DEFINES += FB1_POWER_OPTIMIZATION=1
-}
-
contains(CONFIG_BUILD, directrendering) {
DEFINES += DIRECT_RENDERING=1
}
-contains(CONFIG_BUILD, haptics) {
- DEFINES += HAPTICS=1
-}
-
-contains(CONFIG_BUILD, mediaapi) {
- SOURCES += SoundPlayer.cpp
- HEADERS += SoundPlayer.h
- LIBS += -lmedia-api
- DEFINES += HAS_MEDIA_API
-} else {
- SOURCES += SoundPlayerDummy.cpp
- HEADERS += SoundPlayerDummy.h
-}
-
contains(CONFIG_BUILD, memchute) {
LIBS += -lmemchute
DEFINES += HAS_MEMCHUTE
}
-contains(CONFIG_BUILD, hidlib) {
- INCLUDEPATH += $$(STAGING_INCDIR)/hid/IncsPublic
- LIBS += -lhid
- DEFINES += HAS_HIDLIB
-}
-
-contains(CONFIG_BUILD, affinity) {
- LIBS += -laffinity
- DEFINES += HAS_AFFINITY
-}
-
-contains(CONFIG_BUILD, napp) {
- INCLUDEPATH += $$(STAGING_INCDIR)/napp
- DEFINES += HAS_NAPP
-}
-
DESTDIR = ./$${BUILD_TYPE}-$${MACHINE_NAME}
OBJECTS_DIR = $$DESTDIR/.obj
MOC_DIR = $$DESTDIR/.moc
TARGET = WebAppMgr
-LIBS += -lLunaSysMgrCommon
# Comment these out to get verbose output
#QMAKE_CXX = @echo Compiling $(@)...; $$QMAKE_CXX

0 comments on commit cb164ae

Please sign in to comment.