[haiku-commits] r38721 - haiku/trunk/src/apps/mediaplayer/supplier

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 19 Sep 2010 14:05:01 +0200 (CEST)

Author: stippi
Date: 2010-09-19 14:05:01 +0200 (Sun, 19 Sep 2010)
New Revision: 38721
Changeset: http://dev.haiku-os.org/changeset/38721

Modified:
   haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp
Log:
 * Coding style.
 * Always use keyframes. The BMediaTrack may not be able
   to implement FindKeyFrameForFrame(), so the detection
   may not work even though the track really does use
   keyframes. If it doesn't, then no harm is done anyway.


Modified: haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp
===================================================================
--- haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp       
2010-09-19 12:03:35 UTC (rev 38720)
+++ haiku/trunk/src/apps/mediaplayer/supplier/MediaTrackAudioSupplier.cpp       
2010-09-19 12:05:01 UTC (rev 38721)
@@ -239,40 +239,47 @@
        TRACE("_InitFromTrack()\n");
        // Try to suggest a big buffer size, we do a lot of caching...
        fFormat.u.raw_audio.buffer_size = 16384;
-       if (fMediaTrack && fMediaTrack->DecodedFormat(&fFormat) == B_OK
-               && fFormat.type == B_MEDIA_RAW_AUDIO) {
+       if (fMediaTrack == NULL || fMediaTrack->DecodedFormat(&fFormat) != B_OK
+               || fFormat.type != B_MEDIA_RAW_AUDIO) {
+               fMediaTrack = NULL;
+               return;
+       }
 
-               #ifdef TRACE_AUDIO_SUPPLIER
-                       char formatString[256];
-                       string_for_format(fFormat, formatString, 256);
-                       TRACE("_InitFromTrack(): format is: %s\n", 
formatString);
-                       TRACE("_InitFromTrack(): buffer size: %ld\n",
-                               fFormat.u.raw_audio.buffer_size);
-               #endif
+       #ifdef TRACE_AUDIO_SUPPLIER
+               char formatString[256];
+               string_for_format(fFormat, formatString, 256);
+               TRACE("_InitFromTrack(): format is: %s\n", formatString);
+               TRACE("_InitFromTrack(): buffer size: %ld\n",
+                       fFormat.u.raw_audio.buffer_size);
+       #endif
 
-               fBuffer = new (nothrow) char[fFormat.u.raw_audio.buffer_size];
-               _AllocateBuffers();
+       fBuffer = new (nothrow) char[fFormat.u.raw_audio.buffer_size];
+       _AllocateBuffers();
 
-               // Find out, if the track has key frames: as a heuristic we
-               // check, if the first and the second frame have the same 
backward
-               // key frame.
-               // Note: It shouldn't harm that much, if we're wrong and the
-               // track has key frame although we found out that it has not.
-               int64 keyFrame0 = 0;
-               int64 keyFrame1 = 1;
-               fMediaTrack->FindKeyFrameForFrame(&keyFrame0,
-                       B_MEDIA_SEEK_CLOSEST_BACKWARD);
-               fMediaTrack->FindKeyFrameForFrame(&keyFrame1,
-                       B_MEDIA_SEEK_CLOSEST_BACKWARD);
-               fHasKeyFrames = (keyFrame0 == keyFrame1);
+       // Find out, if the track has key frames: as a heuristic we
+       // check, if the first and the second frame have the same backward
+       // key frame.
+       // Note: It shouldn't harm that much, if we're wrong and the
+       // track has key frame although we found out that it has not.
+#if 0
+       int64 keyFrame0 = 0;
+       int64 keyFrame1 = 1;
+       fMediaTrack->FindKeyFrameForFrame(&keyFrame0,
+               B_MEDIA_SEEK_CLOSEST_BACKWARD);
+       fMediaTrack->FindKeyFrameForFrame(&keyFrame1,
+               B_MEDIA_SEEK_CLOSEST_BACKWARD);
+       fHasKeyFrames = (keyFrame0 == keyFrame1);
+#else
+       fHasKeyFrames = true;
+#endif
 
-               // get the length of the track
-               fCountFrames = fMediaTrack->CountFrames();
+       // get the length of the track
+       fCountFrames = fMediaTrack->CountFrames();
 
-               TRACE("_InitFromTrack(): keyframes: %d, frame count: %lld\n",
-                       fHasKeyFrames, fCountFrames);
-       } else
-               fMediaTrack = NULL;
+       TRACE("_InitFromTrack(): keyframes: %d, frame count: %lld\n",
+               fHasKeyFrames, fCountFrames);
+       printf("_InitFromTrack(): keyframes: %d, frame count: %lld\n",
+               fHasKeyFrames, fCountFrames);
 }
 
 // _FramesPerBuffer


Other related posts:

  • » [haiku-commits] r38721 - haiku/trunk/src/apps/mediaplayer/supplier - superstippi