sh4 eplayer prevent segfaults caused audio rework

Origin commit data
------------------
Branch: master
Commit: 542419f788
Author: DboxOldie <dbo@ddt>
Date: 2020-02-16 (Sun, 16 Feb 2020)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
DboxOldie
2020-02-16 19:52:10 +01:00
committed by vanhofen
parent bd1a6a2848
commit 5ec3c9e6f6
2 changed files with 10 additions and 8 deletions

View File

@@ -349,7 +349,7 @@ bool Player::SwitchVideo(int pid)
bool Player::SwitchAudio(int pid) bool Player::SwitchAudio(int pid)
{ {
Track *track = manager.getAudioTrack(pid); Track *track = manager.getAudioTrack(pid);
return input.SwitchAudio(track); return track ? input.SwitchAudio(track) : false;
} }
bool Player::SwitchSubtitle(int pid) bool Player::SwitchSubtitle(int pid)

View File

@@ -141,7 +141,7 @@ bool cPlayback::Stop(void)
bool cPlayback::SetAPid(int pid, bool /* ac3 */) bool cPlayback::SetAPid(int pid, bool /* ac3 */)
{ {
hal_info("%s\n", __func__); hal_info("%s:(%d)\n", __func__, pid);
return player->SwitchAudio(pid); return player->SwitchAudio(pid);
} }
@@ -308,12 +308,14 @@ void cPlayback::FindAllPids(int *pids, unsigned int *ac3flags, unsigned int *num
hal_info("%s\n", __func__); hal_info("%s\n", __func__);
unsigned int i = 0; unsigned int i = 0;
std::vector<Track> tracks = player->manager.getAudioTracks(); if (IsPlaying()) {
for (std::vector<Track>::iterator it = tracks.begin(); it != tracks.end() && i < *numpids; ++it) { std::vector<Track> tracks = player->manager.getAudioTracks();
pids[i] = it->pid; for (std::vector<Track>::iterator it = tracks.begin(); it != tracks.end() && i < *numpids; ++it) {
ac3flags[i] = (it->ac3flags > 2) ? 1 : 0; pids[i] = it->pid;
language[i] = it->title; ac3flags[i] = it->ac3flags;
i++; language[i] = it->title;
i++;
}
} }
*numpids = i; *numpids = i;
} }