Skip to content
Permalink
Browse files

Add CoreContext::TVInWantingPlayback method

MythMusic resumes music playback when exiting TV Playback, however we don't want it to resume should TV playback be interrupted by another player (for example AirPlay)
  • Loading branch information
jyavenard committed Jul 14, 2013
1 parent 5201ed1 commit 5ed3c410ba311f57af24e20773c6f623b10dce4e
@@ -91,6 +91,7 @@ class MythCoreContextPrivate : public QObject
QMap<QObject *, QByteArray> m_playbackClients;
QMutex m_playbackLock;
bool m_inwanting;
bool m_intvwanting;

MythPluginManager *m_pluginmanager;
};
@@ -1492,6 +1493,18 @@ void MythCoreContext::WantingPlayback(QObject *sender)
d->m_inwanting = false;
}

/**
* Let the TV class tell us if we was interrupted following a call to
* WantingPlayback(). TV playback will later issue a TVPlaybackStopped() signal
* which we want to be able to filter
*/
void MythCoreContext::TVInWantingPlayback(bool b)
{
// when called, it will be while the m_playbackLock is held
// following a call to WantingPlayback
d->m_intvwanting = b;
}

/**
* Returns true if a client has requested playback.
* this can be used when one of the TVPlayback* is emitted to find out if you
@@ -1500,13 +1513,17 @@ void MythCoreContext::WantingPlayback(QObject *sender)
bool MythCoreContext::InWantingPlayback(void)
{
bool locked = d->m_playbackLock.tryLock();
bool intvplayback = d->m_intvwanting;

if (!locked && d->m_inwanting)
return true; // we're in the middle of WantingPlayback

if (!locked)
return false;

d->m_playbackLock.unlock();
return false;

return intvplayback;
}

bool MythCoreContext::TestPluginVersion(const QString &name,
@@ -176,6 +176,7 @@ class MBASE_PUBLIC MythCoreContext : public QObject, public MythObservable, publ
void UnregisterForPlayback(QObject *sender);
void WantingPlayback(QObject *sender);
bool InWantingPlayback(void);
void TVInWantingPlayback(bool b);

// Plugin related methods
bool TestPluginVersion(const QString &name, const QString &libversion,
@@ -196,6 +197,8 @@ class MBASE_PUBLIC MythCoreContext : public QObject, public MythObservable, publ

signals:
void TVPlaybackStarted(void);
//// TVPlaybackStopped signal should be used in combination with
//// InWantingPlayback() and treat it accordingly
void TVPlaybackStopped(void);
void TVPlaybackSought(qint64 position);
void TVPlaybackPaused(void);
@@ -301,6 +301,7 @@ void TV::StopPlayback(void)
PrepareToExitPlayer(ctx, __LINE__);
SetExitPlayer(true, true);
ReturnPlayerLock(ctx);
gCoreContext->TVInWantingPlayback(true);
}
}

@@ -453,6 +454,7 @@ bool TV::StartTV(ProgramInfo *tvrec, uint flags)
ReleaseTV(tv);

gCoreContext->emitTVPlaybackStopped();
gCoreContext->TVInWantingPlayback(false);

if (curProgram)
{
@@ -2084,6 +2086,7 @@ int TV::Playback(const ProgramInfo &rcinfo)
jumpToProgram = false;
allowRerecord = false;
requestDelete = false;
gCoreContext->TVInWantingPlayback(false);

PlayerContext *mctx = GetPlayerReadLock(0, __FILE__, __LINE__);
if (mctx->GetState() != kState_None)

0 comments on commit 5ed3c41

Please sign in to comment.
You can’t perform that action at this time.