Have MediaPlayer supports files with unknown duration:
* Controller: accept streams with unknown duration. * PlaybackManager: trusts the current frame start and end when frameCount not positive. Also don't stop playing when fStopPlayingFrame is zero. * MediaTrackAudioSupplier: only fills with silent when the frame count is not zero. * added some traces. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31569 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
170bf578be
commit
8856fd5fcf
|
@ -255,9 +255,7 @@ Controller::SetTo(const PlaylistItemRef& item)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->Duration() <= 0) {
|
if (t->Duration() <= 0) {
|
||||||
printf("Controller::SetTo: track index %d has no duration\n",i);
|
printf("Controller::SetTo: warning! track index %d has no duration\n", i);
|
||||||
mf->ReleaseTrack(t);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f.IsAudio()) {
|
if (f.IsAudio()) {
|
||||||
|
|
|
@ -224,6 +224,7 @@ PlaybackManager::MessageReceived(BMessage* message)
|
||||||
void
|
void
|
||||||
PlaybackManager::StartPlaying(bool atBeginning)
|
PlaybackManager::StartPlaying(bool atBeginning)
|
||||||
{
|
{
|
||||||
|
TRACE("PlaybackManager::StartPlaying()\n");
|
||||||
int32 playMode = PlayMode();
|
int32 playMode = PlayMode();
|
||||||
if (playMode == MODE_PLAYING_PAUSED_FORWARD)
|
if (playMode == MODE_PLAYING_PAUSED_FORWARD)
|
||||||
SetPlayMode(MODE_PLAYING_FORWARD, !atBeginning);
|
SetPlayMode(MODE_PLAYING_FORWARD, !atBeginning);
|
||||||
|
@ -235,6 +236,7 @@ PlaybackManager::StartPlaying(bool atBeginning)
|
||||||
void
|
void
|
||||||
PlaybackManager::StopPlaying()
|
PlaybackManager::StopPlaying()
|
||||||
{
|
{
|
||||||
|
TRACE("PlaybackManager::StopPlaying()\n");
|
||||||
int32 playMode = PlayMode();
|
int32 playMode = PlayMode();
|
||||||
if (playMode == MODE_PLAYING_FORWARD)
|
if (playMode == MODE_PLAYING_FORWARD)
|
||||||
SetPlayMode(MODE_PLAYING_PAUSED_FORWARD, true);
|
SetPlayMode(MODE_PLAYING_PAUSED_FORWARD, true);
|
||||||
|
@ -729,7 +731,7 @@ PlaybackManager::GetPlaylistTimeInterval(bigtime_t startTime,
|
||||||
bigtime_t endTimeForFrame = TimeForFrame(endFrame);
|
bigtime_t endTimeForFrame = TimeForFrame(endFrame);
|
||||||
endTime = min(endTime, endTimeForFrame);
|
endTime = min(endTime, endTimeForFrame);
|
||||||
bigtime_t intervalLength = endTime - startTime;
|
bigtime_t intervalLength = endTime - startTime;
|
||||||
|
|
||||||
// Finally determine the time bounds for the Playlist interval (depending
|
// Finally determine the time bounds for the Playlist interval (depending
|
||||||
// on the playing direction).
|
// on the playing direction).
|
||||||
switch (playingDirection) {
|
switch (playingDirection) {
|
||||||
|
@ -1418,10 +1420,9 @@ TRACE("PlaybackManager::_FrameForRangeFrame(%lld)\n", index);
|
||||||
TRACE(" frame range: %lld - %lld, count: %lld\n", startFrame, endFrame,
|
TRACE(" frame range: %lld - %lld, count: %lld\n", startFrame, endFrame,
|
||||||
frameCount);
|
frameCount);
|
||||||
// map the index into the index interval of the playing range
|
// map the index into the index interval of the playing range
|
||||||
if (frameCount > 0)
|
if (frameCount > 1)
|
||||||
index = (index % frameCount + frameCount) % frameCount;
|
index = (index % frameCount + frameCount) % frameCount;
|
||||||
else
|
|
||||||
index = 0;
|
|
||||||
// get the frame for the index
|
// get the frame for the index
|
||||||
int32 frame = startFrame;
|
int32 frame = startFrame;
|
||||||
switch (state->loop_mode) {
|
switch (state->loop_mode) {
|
||||||
|
@ -1576,7 +1577,7 @@ void
|
||||||
PlaybackManager::_CheckStopPlaying()
|
PlaybackManager::_CheckStopPlaying()
|
||||||
{
|
{
|
||||||
//printf("_CheckStopPlaying() - %lld, next: %lld\n", fStopPlayingFrame, NextFrame());
|
//printf("_CheckStopPlaying() - %lld, next: %lld\n", fStopPlayingFrame, NextFrame());
|
||||||
if (fStopPlayingFrame >= 0 && fStopPlayingFrame <= NextFrame()) {
|
if (fStopPlayingFrame > 0 && fStopPlayingFrame <= NextFrame()) {
|
||||||
StopPlaying();
|
StopPlaying();
|
||||||
NotifyStopFrameReached();
|
NotifyStopFrameReached();
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,8 @@ VideoConsumer::CreateBuffers(const media_format& format)
|
||||||
uint32 width = format.u.raw_video.display.line_width;
|
uint32 width = format.u.raw_video.display.line_width;
|
||||||
uint32 height = format.u.raw_video.display.line_count;
|
uint32 height = format.u.raw_video.display.line_count;
|
||||||
color_space colorSpace = format.u.raw_video.display.format;
|
color_space colorSpace = format.u.raw_video.display.format;
|
||||||
PROGRESS("VideoConsumer::CreateBuffers - Colorspace = %d\n", colorSpace);
|
PROGRESS("VideoConsumer::CreateBuffers - Width = %ld - Height = %ld - "
|
||||||
|
"Colorspace = %d\n", width, height, colorSpace);
|
||||||
|
|
||||||
fBuffers = new BBufferGroup();
|
fBuffers = new BBufferGroup();
|
||||||
status = fBuffers->InitCheck();
|
status = fBuffers->InitCheck();
|
||||||
|
|
|
@ -127,14 +127,14 @@ MediaTrackAudioSupplier::Read(void* buffer, int64 pos, int64 frames)
|
||||||
|
|
||||||
status_t error = InitCheck();
|
status_t error = InitCheck();
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
TRACE("Read() done\n");
|
TRACE("Read() InitCheck failed\n");
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert pos according to our offset
|
// convert pos according to our offset
|
||||||
pos += fOutOffset;
|
pos += fOutOffset;
|
||||||
// Fill the frames after the end of the track with silence.
|
// Fill the frames after the end of the track with silence.
|
||||||
if (pos + frames > fCountFrames) {
|
if (fCountFrames > 0 && pos + frames > fCountFrames) {
|
||||||
int64 size = max(0LL, fCountFrames - pos);
|
int64 size = max(0LL, fCountFrames - pos);
|
||||||
ReadSilence(SkipFrames(buffer, size), frames - size);
|
ReadSilence(SkipFrames(buffer, size), frames - size);
|
||||||
frames = size;
|
frames = size;
|
||||||
|
@ -528,6 +528,7 @@ status_t
|
||||||
MediaTrackAudioSupplier::_ReadUncachedFrames(void* buffer, int64 position,
|
MediaTrackAudioSupplier::_ReadUncachedFrames(void* buffer, int64 position,
|
||||||
int64 frames, bigtime_t time)
|
int64 frames, bigtime_t time)
|
||||||
{
|
{
|
||||||
|
TRACE("_ReadUncachedFrames()\n");
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
// seek to the position
|
// seek to the position
|
||||||
int64 currentPos = position;
|
int64 currentPos = position;
|
||||||
|
|
Loading…
Reference in New Issue