Giter Site home page Giter Site logo

Comments (6)

kcat avatar kcat commented on July 17, 2024

This doesn't look like proper use of the file IO factory. Each given filename needs to return a unique file/istream handle for the named file, rather than one membuf for all files. Your custom istream handle type also needs to implement seeking, or else the decoders will have problems.

from alure.

McSinyx avatar McSinyx commented on July 17, 2024

I think OP's final goal is to have an istream created from the factory from each ID, which is analogous to file handling. @lain3d: Here is a quite informative article on properly deriving std::streambuf.

from alure.

lain3d avatar lain3d commented on July 17, 2024

@McSinyx I'm now using the std::streambuf for that example + this seekoff:

membuf::pos_type membuf::seekoff(off_type off,
                 std::ios_base::seekdir dir,
                 std::ios_base::openmode which = std::ios_base::in) {
    if (dir == std::ios_base::cur)
        gbump(off);
    else if (dir == std::ios_base::end)
        setg(eback(), egptr() + off, egptr());
    else if (dir == std::ios_base::beg)
        setg(eback(), eback() + off, egptr());
    return gptr() - eback();
}

Unfortunately when I'm creating the object it looks like the underlying std::basic_streambuf is not updated..? So I'm still having the same problem as before.

image

from alure.

lain3d avatar lain3d commented on July 17, 2024

After I implemented membuf::seekpos it's getting further but for some reason not decoding the frame properly..

image

But if I instead use the file the audio plays fine.

from alure.

kcat avatar kcat commented on July 17, 2024

FWIW, this is what I use to create a std::istream that reads from a memory buffer instead of a file on disk:
https://github.com/kcat/openal-soft/blob/openal-soft-1.20.1/alc/hrtf.cpp#L111...L178

Your factory's openFile method would just need to create an idstream using the appropriate start and end data pointers.

from alure.

lain3d avatar lain3d commented on July 17, 2024

Hell yeah, got it working thanks to that.. I needed to have

this->setg(const_cast<char_type*>(begin_), const_cast<char_type*>(begin_),
         const_cast<char_type*>(end_)); 

in my constructor (I took it out earlier because the example from the above link did not have setg).. Thanks. :)

from alure.

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.