* Some cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37717 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -31,14 +31,15 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (argc == 4) {
|
if (argc == 4) {
|
||||||
size_t size = strtoul(argv[2], NULL, 10);
|
size_t size = strtoul(argv[2], NULL, 10);
|
||||||
if (0 < size)
|
if (size > 0)
|
||||||
framesPerBufferPart = size;
|
framesPerBufferPart = size;
|
||||||
|
|
||||||
size = strtoul(argv[3], NULL, 10);
|
size = strtoul(argv[3], NULL, 10);
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
printf("at least 2 buffer parts are needed\n");
|
printf("at least 2 buffer parts are needed\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
if (0 < size)
|
if (size > 0)
|
||||||
bufferPartCount = size;
|
bufferPartCount = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ main(int argc, char *argv[])
|
|||||||
BEntry entry(argv[1]);
|
BEntry entry(argv[1]);
|
||||||
if (entry.InitCheck() != B_OK || !entry.Exists()) {
|
if (entry.InitCheck() != B_OK || !entry.Exists()) {
|
||||||
printf("cannot open input file\n");
|
printf("cannot open input file\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_ref entryRef;
|
entry_ref entryRef;
|
||||||
@@ -57,18 +58,18 @@ main(int argc, char *argv[])
|
|||||||
BMediaFile mediaFile(&entryRef);
|
BMediaFile mediaFile(&entryRef);
|
||||||
if (mediaFile.InitCheck() != B_OK) {
|
if (mediaFile.InitCheck() != B_OK) {
|
||||||
printf("file not supported\n");
|
printf("file not supported\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaFile.CountTracks() == 0) {
|
if (mediaFile.CountTracks() == 0) {
|
||||||
printf("no tracks found in file\n");
|
printf("no tracks found in file\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BMediaTrack *mediaTrack = mediaFile.TrackAt(0);
|
BMediaTrack *mediaTrack = mediaFile.TrackAt(0);
|
||||||
if (mediaTrack == NULL) {
|
if (mediaTrack == NULL) {
|
||||||
printf("problem getting track from file\n");
|
printf("problem getting track from file\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// propose format, let it decide frame rate, channels number and buf size
|
// propose format, let it decide frame rate, channels number and buf size
|
||||||
@@ -80,7 +81,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (mediaTrack->DecodedFormat(&format) != B_OK) {
|
if (mediaTrack->DecodedFormat(&format) != B_OK) {
|
||||||
printf("cannot set decoder output format\n");
|
printf("cannot set decoder output format\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("negotiated format:\n");
|
printf("negotiated format:\n");
|
||||||
@@ -98,7 +99,9 @@ main(int argc, char *argv[])
|
|||||||
BPushGameSound pushGameSound(framesPerBufferPart, &gsFormat,
|
BPushGameSound pushGameSound(framesPerBufferPart, &gsFormat,
|
||||||
bufferPartCount);
|
bufferPartCount);
|
||||||
if (pushGameSound.InitCheck() != B_OK) {
|
if (pushGameSound.InitCheck() != B_OK) {
|
||||||
printf("trouble initializing push game sound\n");
|
printf("trouble initializing push game sound: %s\n",
|
||||||
|
strerror(pushGameSound.InitCheck()));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 *buffer;
|
uint8 *buffer;
|
||||||
@@ -106,13 +109,13 @@ main(int argc, char *argv[])
|
|||||||
if (pushGameSound.LockForCyclic((void **)&buffer, &bufferSize)
|
if (pushGameSound.LockForCyclic((void **)&buffer, &bufferSize)
|
||||||
!= BPushGameSound::lock_ok) {
|
!= BPushGameSound::lock_ok) {
|
||||||
printf("cannot lock buffer\n");
|
printf("cannot lock buffer\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
memset(buffer, 0, bufferSize);
|
memset(buffer, 0, bufferSize);
|
||||||
|
|
||||||
if (pushGameSound.StartPlaying() != B_OK) {
|
if (pushGameSound.StartPlaying() != B_OK) {
|
||||||
printf("cannot start playback\n");
|
printf("cannot start playback\n");
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("playing, press [esc] to exit...\n");
|
printf("playing, press [esc] to exit...\n");
|
||||||
@@ -153,8 +156,8 @@ main(int argc, char *argv[])
|
|||||||
* (format.u.raw_audio.format
|
* (format.u.raw_audio.format
|
||||||
& media_raw_audio_format::B_AUDIO_SIZE_MASK);
|
& media_raw_audio_format::B_AUDIO_SIZE_MASK);
|
||||||
|
|
||||||
printf("\rtime: %.2f", (double) mediaTrack->CurrentTime()
|
printf("\rtime: %.2f",
|
||||||
/ 1000000LL);
|
(double)mediaTrack->CurrentTime() / 1000000LL);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user