From cb4fef02dbde8426c2b8feb39ccb1350d450ece8 Mon Sep 17 00:00:00 2001
From: Puck Meerburg <puck@puckipedia.nl>
Date: Sun, 8 Jun 2014 14:14:53 +0200
Subject: [PATCH] Fix AIFF and SoundFile, BePac Deluxe now runs (if you
blacklist ffmpeg)
---
build/jam/images/definitions/regular | 1 +
src/add-ons/media/plugins/aiff_reader/Jamfile | 12 +++--
.../media/plugins/aiff_reader/aiff_reader.cpp | 1 +
.../media/plugins/ffmpeg/AVFormatReader.cpp | 4 ++
src/kits/media/SoundFile.cpp | 62 +++++++++++++++++-----
5 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/build/jam/images/definitions/regular b/build/jam/images/definitions/regular
index c85e9c0..4eff8d3 100644
a
|
b
|
SYSTEM_ADD_ONS_MEDIA += [ FFilterByBuildFeatures
|
140 | 140 | ] ; |
141 | 141 | |
142 | 142 | SYSTEM_ADD_ONS_MEDIA_PLUGINS += [ FFilterByBuildFeatures |
| 143 | aiff_reader |
143 | 144 | ffmpeg@ffmpeg |
144 | 145 | raw_decoder |
145 | 146 | ] ; |
diff --git a/src/add-ons/media/plugins/aiff_reader/Jamfile b/src/add-ons/media/plugins/aiff_reader/Jamfile
index 55139da..22e2332 100644
a
|
b
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
4 | 4 | |
5 | 5 | UsePrivateHeaders media ; |
6 | 6 | |
7 | | Addon aiff_reader : |
8 | | aiff_reader.cpp |
9 | | : be libmedia.so $(TARGET_LIBSUPC++) ; |
| 7 | local architectureObject ; |
| 8 | for architectureObject in [ MultiArchSubDirSetup ] { |
| 9 | on $(architectureObject) { |
| 10 | Addon [ MultiArchDefaultGristFiles aiff_reader ] : |
| 11 | aiff_reader.cpp |
| 12 | : be media $(TARGET_LIBSUPC++) |
| 13 | ; |
| 14 | } |
| 15 | } |
diff --git a/src/add-ons/media/plugins/aiff_reader/aiff_reader.cpp b/src/add-ons/media/plugins/aiff_reader/aiff_reader.cpp
index 3e2dc58..788e6bc 100644
a
|
b
|
|
1 | 1 | /* |
2 | 2 | * Copyright (c) 2003-2004, Marcus Overhagen |
| 3 | * Copyright (c) 2014, Puck Meerburg |
3 | 4 | * All rights reserved. |
4 | 5 | * |
5 | 6 | * Redistribution and use in source and binary forms, with or without modification, |
diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
index aeed534..670b166 100644
a
|
b
|
|
1 | 1 | /* |
2 | 2 | * Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de> |
| 3 | * Copyright 2014, Puck Meerburg <puck@puckipedia.nl> |
3 | 4 | * All rights reserved. Distributed under the terms of the GNU L-GPL license. |
4 | 5 | */ |
5 | 6 | |
… |
… |
AVFormatReader::Sniff(int32* _streamCount)
|
1547 | 1548 | if (_streamCount != NULL) |
1548 | 1549 | *_streamCount = streamCount; |
1549 | 1550 | |
| 1551 | if (stream->Context()->audio_codec_id == CODEC_ID_NONE && stream->Context()->video_codec_id == CODEC_ID_NONE) |
| 1552 | return B_ERROR; |
| 1553 | |
1550 | 1554 | return B_OK; |
1551 | 1555 | } |
1552 | 1556 | |
diff --git a/src/kits/media/SoundFile.cpp b/src/kits/media/SoundFile.cpp
index 7428680..5eaf951 100644
a
|
b
|
|
1 | 1 | /*********************************************************************** |
2 | | * AUTHOR: Marcus Overhagen |
| 2 | * AUTHOR: Marcus Overhagen, Puck Meerburg (2014) |
3 | 3 | * FILE: SoundFile.cpp |
4 | 4 | * DESCR: |
5 | 5 | ***********************************************************************/ |
| 6 | #include <string.h> |
| 7 | |
6 | 8 | #include <MediaFile.h> |
7 | 9 | #include <MediaTrack.h> |
8 | 10 | #include <SoundFile.h> |
… |
… |
|
15 | 17 | BSoundFile::BSoundFile() |
16 | 18 | { |
17 | 19 | _init_raw_stats(); |
| 20 | PRINT(1, "Inited BSoundFile\n"); |
18 | 21 | } |
19 | 22 | |
20 | 23 | |
… |
… |
BSoundFile::BSoundFile(const entry_ref *ref,
|
23 | 26 | { |
24 | 27 | _init_raw_stats(); |
25 | 28 | SetTo(ref,open_mode); |
| 29 | PRINT(1, "Inited BSoundFile with ref %p and open_mode 0x%x\n", ref, open_mode); |
26 | 30 | } |
27 | 31 | |
28 | 32 | /* virtual */ |
29 | 33 | BSoundFile::~BSoundFile() |
30 | 34 | { |
| 35 | PRINT(1, "Destructor called\n"); |
31 | 36 | delete fSoundFile; |
32 | 37 | delete fMediaFile; |
33 | 38 | // fMediaTrack will be deleted by the BMediaFile destructor |
… |
… |
BSoundFile::~BSoundFile()
|
37 | 42 | status_t |
38 | 43 | BSoundFile::InitCheck() const |
39 | 44 | { |
| 45 | PRINT(1, "InitCheck: "); |
40 | 46 | if (!fSoundFile) { |
| 47 | PRINT(1, "fSoundFile not inited, so B_NO_INIT\n"); |
41 | 48 | return B_NO_INIT; |
42 | 49 | } |
43 | | return fSoundFile->InitCheck(); |
| 50 | status_t f = fSoundFile->InitCheck(); |
| 51 | PRINT(1, "fSoundFile inited, so %d\n", f); |
| 52 | return f; |
44 | 53 | } |
45 | 54 | |
46 | 55 | |
… |
… |
size_t
|
239 | 248 | BSoundFile::ReadFrames(char *buf, |
240 | 249 | size_t count) |
241 | 250 | { |
242 | | UNIMPLEMENTED(); |
243 | | |
244 | | return 0; |
| 251 | size_t frameRead = 0; |
| 252 | int64 frames = count; |
| 253 | while (count > 0) { |
| 254 | status_t status = fMediaTrack->ReadFrames( |
| 255 | reinterpret_cast<void *>(buf), &frames); |
| 256 | PRINT(1, "ReadFrames: status is %d, after reading %Ld frames (%d requested) into %p\n", status, frames, count, buf); |
| 257 | count -= frames; |
| 258 | frameRead += frames; |
| 259 | buf += fSampleSize * fChannelCount * frames; |
| 260 | if (status != B_OK) |
| 261 | return status; |
| 262 | } |
| 263 | return frameRead; |
245 | 264 | } |
246 | 265 | |
247 | 266 | |
… |
… |
size_t
|
249 | 268 | BSoundFile::WriteFrames(char *buf, |
250 | 269 | size_t count) |
251 | 270 | { |
252 | | UNIMPLEMENTED(); |
253 | | |
254 | | return 0; |
| 271 | PRINT(1, "WriteFrames: Writing %d frames from %p\n", count, buf); |
| 272 | return fMediaTrack->WriteFrames( |
| 273 | reinterpret_cast<void *>(buf), count); |
255 | 274 | } |
256 | 275 | |
257 | 276 | |
258 | 277 | /* virtual */ off_t |
259 | 278 | BSoundFile::SeekToFrame(off_t n) |
260 | 279 | { |
261 | | UNIMPLEMENTED(); |
| 280 | int64 frames = n; |
| 281 | status_t status = fMediaTrack->SeekToFrame( |
| 282 | &frames); |
262 | 283 | |
263 | | return 0; |
| 284 | PRINT(1, "Seeked to frame %d, got %ld (status = %d)\n", n, frames, status); |
| 285 | |
| 286 | if (status != B_OK) |
| 287 | return status; |
| 288 | |
| 289 | return frames; |
264 | 290 | } |
265 | 291 | |
266 | 292 | |
… |
… |
BSoundFile::_init_raw_stats()
|
306 | 332 | } |
307 | 333 | |
308 | 334 | |
| 335 | int32 |
| 336 | _ParseMimeType(char *mime_type) |
| 337 | { |
| 338 | if (strcmp(mime_type, "audio/x-aiff") == 0) |
| 339 | return B_AIFF_FILE; |
| 340 | if (strcmp(mime_type, "audio/x-wav") == 0) |
| 341 | return B_WAVE_FILE; |
| 342 | return B_UNKNOWN_FILE; |
| 343 | } |
| 344 | |
| 345 | |
309 | 346 | status_t |
310 | 347 | BSoundFile::_ref_to_file(const entry_ref *ref) |
311 | 348 | { |
… |
… |
BSoundFile::_ref_to_file(const entry_ref *ref)
|
328 | 365 | switch (mfi.family) { |
329 | 366 | case B_AIFF_FORMAT_FAMILY: fFileFormat = B_AIFF_FILE; break; |
330 | 367 | case B_WAV_FORMAT_FAMILY: fFileFormat = B_WAVE_FILE; break; |
331 | | default: fFileFormat = B_UNKNOWN_FILE; break; |
| 368 | default: fFileFormat = _ParseMimeType(mfi.mime_type); break; |
332 | 369 | } |
333 | 370 | int trackNum = 0; |
334 | 371 | BMediaTrack * track = 0; |
335 | 372 | media_format mf; |
336 | 373 | while (trackNum < media->CountTracks()) { |
337 | 374 | track = media->TrackAt(trackNum); |
338 | | status = track->EncodedFormat(&mf); |
| 375 | status = track->DecodedFormat(&mf); |
339 | 376 | if (status != B_OK) { |
340 | 377 | media->ReleaseTrack(track); |
341 | 378 | delete media; |
… |
… |
BSoundFile::_ref_to_file(const entry_ref *ref)
|
393 | 430 | } |
394 | 431 | fMediaFile = media; |
395 | 432 | fMediaTrack = track; |
| 433 | fSoundFile = file; |
396 | 434 | return B_OK; |
397 | 435 | } |
398 | 436 | |