#if ENABLE(TIZEN_AUDIO_SESSION_MANAGER)
static ASM_cb_result_t MediaPlayerAudioSessionEventSourcePause(ASM_event_sources_t eventSource, void* callbackData)
{
- MediaPlayer* player = static_cast<MediaPlayer*>(callbackData);
+ MediaPlayerPrivateGStreamer *priv = static_cast<MediaPlayerPrivateGStreamer*>(callbackData);
+ MediaPlayer* player = priv->player();
if (!player)
return ASM_CB_RES_IGNORE;
+ // This command will come in for any media element, regardless of the state of playback,
+ // so just ignore request on media that is not currently playing
+ if (!priv->playing())
+ return ASM_CB_RES_NONE;
+
switch (eventSource) {
case ASM_EVENT_SOURCE_CALL_START:
case ASM_EVENT_SOURCE_ALARM_START:
case ASM_EVENT_SOURCE_EMERGENCY_START:
case ASM_EVENT_SOURCE_OTHER_PLAYER_APP:
case ASM_EVENT_SOURCE_RESOURCE_CONFLICT:
+ priv->m_preemptionRequested = true;
player->pause();
player->playbackStateChanged();
return ASM_CB_RES_PAUSE;
static ASM_cb_result_t MediaPlayerAudioSessionEventSourcePlay(ASM_event_sources_t eventSource, void* callbackData)
{
- MediaPlayer* player = static_cast<MediaPlayer*>(callbackData);
+ MediaPlayerPrivateGStreamer *priv = static_cast<MediaPlayerPrivateGStreamer*>(callbackData);
+ MediaPlayer* player = priv->player();
if (!player)
return ASM_CB_RES_IGNORE;
- switch (eventSource) {
- case ASM_EVENT_SOURCE_ALARM_END:
- if (!player->hasVideo()) {
- player->play();
- return ASM_CB_RES_PLAYING;
- } else if (player->url().string().contains("camera://")) {
- player->play();
- return ASM_CB_RES_PLAYING;
- }
- return ASM_CB_RES_NONE;
- default:
- return ASM_CB_RES_NONE;
+ // Regardless of event source, start to play if resource manager
+ // commands it, but only if the specific media element is currently preempted
+ if (priv->m_preemptionActive) {
+ player->play();
+ player->playbackStateChanged();
}
+ return ASM_CB_RES_PLAYING;
}
static ASM_cb_result_t mediaPlayerPrivateAudioSessionNotifyCallback(int, ASM_event_sources_t eventSource, ASM_sound_commands_t command, unsigned int, void* callbackData)
#endif // ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER)
#if ENABLE(TIZEN_AUDIO_SESSION_MANAGER)
, m_audioSessionManager(AudioSessionManagerGStreamerTizen::createAudioSessionManager())
+ , m_preemptionRequested(false)
+ , m_preemptionActive(false)
#endif
, m_originalPreloadWasAutoAndWasOverridden(false)
, m_preservesPitch(false)
void MediaPlayerPrivateGStreamer::play()
{
#if ENABLE(TIZEN_AUDIO_SESSION_MANAGER)
+ m_preemptionActive = false;
if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PLAYING))
return;
#endif
void MediaPlayerPrivateGStreamer::pause()
{
#if ENABLE(TIZEN_AUDIO_SESSION_MANAGER)
- if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PAUSE))
- return;
+ if (m_preemptionRequested) {
+ // resource manager preempted the resource
+ m_preemptionActive = true;
+ m_preemptionRequested = false;
+ }
+ else {
+ // user requested the pause, release the resource
+ m_preemptionActive = false;
+ if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PAUSE))
+ return;
+ }
#endif
if (m_playBinReady == false) {
return state == GST_STATE_PAUSED;
}
+bool MediaPlayerPrivateGStreamer::playing() const
+{
+ GstState state;
+ gst_element_get_state(m_playBin.get(), &state, 0, 0);
+ return state == GST_STATE_PLAYING;
+}
+
bool MediaPlayerPrivateGStreamer::seeking() const
{
return m_seeking;
g_object_set(m_playBin.get(), "audio-sink", realSink, NULL);
#endif
if (m_audioSessionManager)
- m_audioSessionManager->registerAudioSessionManager(MM_SESSION_TYPE_SHARE, mediaPlayerPrivateAudioSessionNotifyCallback, player());
+ m_audioSessionManager->registerAudioSessionManager(MM_SESSION_TYPE_SHARE, mediaPlayerPrivateAudioSessionNotifyCallback, this);
#if ENABLE(TIZEN_AUDIO_SESSION_MANAGER_WITH_MURPHY)
GstElement *sink = gst_element_factory_make("pulsesink", "audio-sink");
if (sink != NULL) {