Skip to content

Commit

Permalink
Replace C style casting with C++ style casts
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartm committed Jan 31, 2012
1 parent 2d29fe6 commit e550ae5
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
35 changes: 29 additions & 6 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Expand Up @@ -1191,7 +1191,10 @@ void MusicCommon::customEvent(QEvent *event)

statusString = tr("Decoder error.");

DecoderEvent *dxe = (DecoderEvent *) event;
DecoderEvent *dxe = dynamic_cast<DecoderEvent *>(event);

if (!dxe)
return;

LOG(VB_GENERAL, LOG_ERR, QString("%1 %2").arg(statusString)
.arg(*dxe->errorMessage()));
Expand Down Expand Up @@ -1444,7 +1447,11 @@ void MusicCommon::customEvent(QEvent *event)
}
else if (event->type() == MusicPlayerEvent::TrackChangeEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

int trackNo = mpe->TrackID;

if (m_currentPlaylist)
Expand Down Expand Up @@ -1492,7 +1499,11 @@ void MusicCommon::customEvent(QEvent *event)
}
else if (event->type() == MusicPlayerEvent::TrackRemovedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

int trackID = mpe->TrackID;

if (m_currentPlaylist)
Expand Down Expand Up @@ -1527,7 +1538,11 @@ void MusicCommon::customEvent(QEvent *event)
}
else if (event->type() == MusicPlayerEvent::TrackAddedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

int trackID = mpe->TrackID;

if (m_currentPlaylist)
Expand Down Expand Up @@ -1581,7 +1596,11 @@ void MusicCommon::customEvent(QEvent *event)
else if (event->type() == MusicPlayerEvent::MetadataChangedEvent ||
event->type() == MusicPlayerEvent::TrackStatsChangedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

uint trackID = mpe->TrackID;

if (m_currentPlaylist)
Expand Down Expand Up @@ -1610,7 +1629,11 @@ void MusicCommon::customEvent(QEvent *event)
}
else if (event->type() == MusicPlayerEvent::AlbumArtChangedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

uint trackID = mpe->TrackID;

if (m_currentPlaylist)
Expand Down
38 changes: 29 additions & 9 deletions mythplugins/mythmusic/mythmusic/musicplayer.cpp
Expand Up @@ -108,7 +108,7 @@ MusicPlayer::MusicPlayer(QObject *parent, const QString &dev)
if (checkCD)
{
m_cdWatcher = new CDWatcherThread(m_CDdevice);
// don't start the cd watcher here
// don't start the cd watcher here
// since the playlists haven't been loaded yet
}

Expand Down Expand Up @@ -510,7 +510,10 @@ void MusicPlayer::customEvent(QEvent *event)
}
else if (event->type() == DecoderHandlerEvent::Info)
{
DecoderHandlerEvent *dxe = (DecoderHandlerEvent*)event;
DecoderHandlerEvent *dxe = dynamic_cast<DecoderHandlerEvent*>(event);
if (!dxe)
return;

if (getCurrentMetadata())
m_displayMetadata = *getCurrentMetadata();
m_displayMetadata.setArtist("");
Expand All @@ -521,7 +524,10 @@ void MusicPlayer::customEvent(QEvent *event)
}
else if (event->type() == DecoderHandlerEvent::Meta)
{
DecoderHandlerEvent *dhe = (DecoderHandlerEvent*)(event);
DecoderHandlerEvent *dhe = dynamic_cast<DecoderHandlerEvent*>(event);
if (!dhe)
return;

Metadata mdata(*dhe->getMetadata());

if (!m_playedList.isEmpty())
Expand Down Expand Up @@ -560,7 +566,11 @@ void MusicPlayer::customEvent(QEvent *event)
// handle MythEvent events
else if (event->type() == MythEvent::MythEventMessage)
{
MythEvent *me = (MythEvent*) event;
MythEvent *me = dynamic_cast<MythEvent*>(event);

if (!me)
return;

if (me->Message().left(14) == "PLAYBACK_START")
{
m_wasPlaying = m_isPlaying;
Expand Down Expand Up @@ -698,7 +708,10 @@ void MusicPlayer::customEvent(QEvent *event)
{
if (event->type() == OutputEvent::Error)
{
OutputEvent *aoe = (OutputEvent *) event;
OutputEvent *aoe = dynamic_cast<OutputEvent*>(event);

if (!aoe)
return;

LOG(VB_GENERAL, LOG_ERR, QString("Output Error - %1")
.arg(*aoe->errorMessage()));
Expand All @@ -713,7 +726,10 @@ void MusicPlayer::customEvent(QEvent *event)

QApplication::sendPostedEvents();

DecoderEvent *dxe = (DecoderEvent *) event;
DecoderEvent *dxe = dynamic_cast<DecoderEvent*>(event);

if (!dxe)
return;

LOG(VB_GENERAL, LOG_ERR, QString("Decoder Error - %1")
.arg(*dxe->errorMessage()));
Expand All @@ -724,7 +740,11 @@ void MusicPlayer::customEvent(QEvent *event)

if (event->type() == OutputEvent::Info)
{
OutputEvent *oe = (OutputEvent *) event;
OutputEvent *oe = dynamic_cast<OutputEvent*>(event);

if (!oe)
return;

m_currentTime = oe->elapsedSeconds();

if (!m_updatedLastplay)
Expand Down Expand Up @@ -974,7 +994,7 @@ Metadata *MusicPlayer::getNextMetadata(void)
return m_currentPlaylist->getSongAt(m_currentTrack + 1);
else
{
// if we are playing the last track then we need to take the
// if we are playing the last track then we need to take the
// repeat mode into account
if (m_repeatMode == REPEAT_ALL)
return m_currentPlaylist->getSongAt(0);
Expand Down Expand Up @@ -1035,7 +1055,7 @@ MusicPlayer::ShuffleMode MusicPlayer::toggleShuffleMode(void)
return m_shuffleMode;
}

void MusicPlayer::setShuffleMode(ShuffleMode mode)
void MusicPlayer::setShuffleMode(ShuffleMode mode)
{
int curTrackID = -1;
if (getCurrentMetadata())
Expand Down
17 changes: 14 additions & 3 deletions mythplugins/mythmusic/mythmusic/searchview.cpp
Expand Up @@ -89,7 +89,11 @@ void SearchView::customEvent(QEvent *event)
if (event->type() == MusicPlayerEvent::TrackRemovedEvent ||
event->type() == MusicPlayerEvent::TrackAddedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

int trackID = mpe->TrackID;

for (int x = 0; x < m_tracksList->GetCount(); x++)
Expand Down Expand Up @@ -132,7 +136,11 @@ void SearchView::customEvent(QEvent *event)
}
else if (event->type() == MusicPlayerEvent::MetadataChangedEvent)
{
MusicPlayerEvent *mpe = (MusicPlayerEvent*)(event);
MusicPlayerEvent *mpe = dynamic_cast<MusicPlayerEvent *>(event);

if (!mpe)
return;

uint trackID = mpe->TrackID;

for (int x = 0; x < m_tracksList->GetCount(); x++)
Expand All @@ -152,7 +160,10 @@ void SearchView::customEvent(QEvent *event)
}
else if (event->type() == DialogCompletionEvent::kEventType)
{
DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);
DialogCompletionEvent *dce = dynamic_cast<DialogCompletionEvent *>(event);

if (!dce)
return;

// make sure the user didn't ESCAPE out of the menu
if (dce->GetResult() < 0)
Expand Down

0 comments on commit e550ae5

Please sign in to comment.