Giter Site home page Giter Site logo

Comments (3)

sbooth avatar sbooth commented on June 3, 2024

I think this is the same issue discussed in #206 and I think it boils down to treating -openReturningError: synchronously when it is inherently asynchronous in this case due to network requests.

This problem occurs because there are attempts to read data from the input source (via sf_open_virtual in the case of WAVE, but it will differ by format) before the NSURLSessionDataTask has made any calls to the delegate returning data from the request. When this happens the input source returns a zero length which is typically reported as an unsupported format.

I feel like this is a design flaw in the way that HTTP input sources are handled. Years ago HTTP input was implemented using CFReadStream (see https://github.com/sbooth/SFBAudioEngine/blob/legacy/Input/HTTPInputSource.cpp if you're curious) which seemed to work at the time with the library's architecture. In the transition to Objective-C and Swift CFReadStream was replaced with the current design.

I don't have a great fix off the top of my head, but one possibility is exposing SFBHTTPInputSource as a public class and requiring users to ensure the network has returned data before trying to create a decoder from the input source. It's also possible that the library could handle that internally although I'm not sure what that would entail.

In a perfect world perhaps all reads would be asynchronous (taking a completion handler in Objective-C and using async in Swift) but that would be significant change to the way things work.

Bringing in @NattyNarwhal for any suggestions.

from sfbaudioengine.

NattyNarwhal avatar NattyNarwhal commented on June 3, 2024

I moved my application to AVFoundation, which from what I observe (could be inaccurate!) seems block only to load just enough of the file (metadata, maybe initial audio frames), then continues to load the rest in asynchronously behind the scenes; file progress is observable. You can also set an option to block a bit longer to load more data for more accurate seeks if the container can't be accurate about it.

In the SFBHTTPInputSource case, it seemed all the libraries it delegates to would fail because nothing was loaded of the file yet.

from sfbaudioengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.