Ticket #9939: 0001-Fix-AIFF-and-SoundFile-BePac-Deluxe-now-runs-if-you-.patch

File 0001-Fix-AIFF-and-SoundFile-BePac-Deluxe-now-runs-if-you-.patch, 6.5 KB (added by puckipedia, 6 years ago)

Another Patch?

  • build/jam/images/definitions/regular

    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  
    140140] ;
    141141
    142142SYSTEM_ADD_ONS_MEDIA_PLUGINS += [ FFilterByBuildFeatures
     143    aiff_reader
    143144    ffmpeg@ffmpeg
    144145    raw_decoder
    145146] ;
  • src/add-ons/media/plugins/aiff_reader/Jamfile

    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 ;  
    44
    55UsePrivateHeaders media ;
    66
    7 Addon aiff_reader :
    8     aiff_reader.cpp
    9     : be libmedia.so $(TARGET_LIBSUPC++) ;
     7local architectureObject ;
     8for architectureObject in [ MultiArchSubDirSetup ] {
     9    on $(architectureObject) {
     10        Addon [ MultiArchDefaultGristFiles aiff_reader ] :
     11            aiff_reader.cpp
     12            : be media $(TARGET_LIBSUPC++)
     13            ;
     14    }
     15}
  • src/add-ons/media/plugins/aiff_reader/aiff_reader.cpp

    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  
    11/*
    22 * Copyright (c) 2003-2004, Marcus Overhagen
     3 * Copyright (c) 2014, Puck Meerburg
    34 * All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without modification,
  • src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp

    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  
    11/*
    22 * Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>
     3 * Copyright 2014, Puck Meerburg <puck@puckipedia.nl>
    34 * All rights reserved. Distributed under the terms of the GNU L-GPL license.
    45 */
    56
    AVFormatReader::Sniff(int32* _streamCount)  
    15471548    if (_streamCount != NULL)
    15481549        *_streamCount = streamCount;
    15491550
     1551    if (stream->Context()->audio_codec_id == CODEC_ID_NONE && stream->Context()->video_codec_id == CODEC_ID_NONE)
     1552        return B_ERROR;
     1553
    15501554    return B_OK;
    15511555}
    15521556
  • src/kits/media/SoundFile.cpp

    diff --git a/src/kits/media/SoundFile.cpp b/src/kits/media/SoundFile.cpp
    index 7428680..5eaf951 100644
    a b  
    11/***********************************************************************
    2  * AUTHOR: Marcus Overhagen
     2 * AUTHOR: Marcus Overhagen, Puck Meerburg (2014)
    33 *   FILE: SoundFile.cpp
    44 *  DESCR:
    55 ***********************************************************************/
     6#include <string.h>
     7
    68#include <MediaFile.h>
    79#include <MediaTrack.h>
    810#include <SoundFile.h>
     
    1517BSoundFile::BSoundFile()
    1618{
    1719    _init_raw_stats();
     20    PRINT(1, "Inited BSoundFile\n");
    1821}
    1922
    2023
    BSoundFile::BSoundFile(const entry_ref *ref,  
    2326{
    2427    _init_raw_stats();
    2528    SetTo(ref,open_mode);
     29    PRINT(1, "Inited BSoundFile with ref %p and open_mode 0x%x\n", ref, open_mode);
    2630}
    2731
    2832/* virtual */
    2933BSoundFile::~BSoundFile()
    3034{
     35    PRINT(1, "Destructor called\n");
    3136    delete fSoundFile;
    3237    delete fMediaFile;
    3338        // fMediaTrack will be deleted by the BMediaFile destructor
    BSoundFile::~BSoundFile()  
    3742status_t
    3843BSoundFile::InitCheck() const
    3944{
     45    PRINT(1, "InitCheck: ");
    4046    if (!fSoundFile) {
     47        PRINT(1, "fSoundFile not inited, so B_NO_INIT\n");
    4148        return B_NO_INIT;
    4249    }
    43     return fSoundFile->InitCheck();
     50    status_t f = fSoundFile->InitCheck();
     51    PRINT(1, "fSoundFile inited, so %d\n", f);
     52    return f;
    4453}
    4554
    4655
    size_t  
    239248BSoundFile::ReadFrames(char *buf,
    240249                       size_t count)
    241250{
    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;
    245264}
    246265
    247266
    size_t  
    249268BSoundFile::WriteFrames(char *buf,
    250269                        size_t count)
    251270{
    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);
    255274}
    256275
    257276
    258277/* virtual */ off_t
    259278BSoundFile::SeekToFrame(off_t n)
    260279{
    261     UNIMPLEMENTED();
     280    int64 frames = n;
     281    status_t status = fMediaTrack->SeekToFrame(
     282        &frames);
    262283
    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;
    264290}
    265291
    266292
    BSoundFile::_init_raw_stats()  
    306332}
    307333
    308334
     335int32
     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
    309346status_t
    310347BSoundFile::_ref_to_file(const entry_ref *ref)
    311348{
    BSoundFile::_ref_to_file(const entry_ref *ref)  
    328365    switch (mfi.family) {
    329366        case B_AIFF_FORMAT_FAMILY: fFileFormat = B_AIFF_FILE; break;
    330367        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;
    332369    }
    333370    int trackNum = 0;
    334371    BMediaTrack * track = 0;
    335372    media_format mf;
    336373    while (trackNum < media->CountTracks()) {
    337374        track = media->TrackAt(trackNum);
    338         status = track->EncodedFormat(&mf);
     375        status = track->DecodedFormat(&mf);
    339376        if (status != B_OK) {
    340377            media->ReleaseTrack(track);
    341378            delete media;
    BSoundFile::_ref_to_file(const entry_ref *ref)  
    393430    }
    394431    fMediaFile = media;
    395432    fMediaTrack = track;
     433    fSoundFile = file;
    396434    return B_OK;
    397435}
    398436