Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble loading vector of ofxHapPlayer objects #9

Open
nightshining opened this issue Aug 12, 2015 · 1 comment
Open

Trouble loading vector of ofxHapPlayer objects #9

nightshining opened this issue Aug 12, 2015 · 1 comment

Comments

@nightshining
Copy link

Hello,
I tried making a vector of ofxHapPlayers just as below:

vector<ofxHapPlayer> player;  //note: this piece was in .h file

 ofDirectory videoDir;
    videoDir.listDir("movies");

    for (int i = 0; i < (int)videoDir.size(); i++){

        ofxHapPlayer tempVideo;
        tempVideo.setup(videoDir.getPath(i));
        cout << "Loading Movie: " << videoDir.getPath(i) << endl;

        player.push_back(tempVideo);
    }

When running this code I would get the following error in my console:

Loading Movie: movies/Organ_Intro_1.mov
*Loading Movie: movies/Organ_Intro_3.mov
*VidPlayerDebug(8972,0xa0ea11d4) malloc: *
* error for object 0x6fda000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
*(lldb)

I made sure to log out that my paths were correct. I also tried a single ofxHapPlayer to load each video file which I did with total success. I then found a OF forum entry with the following code below. This code seems to work thus far. My understanding of what is happening is limited, but I thought it may be of interest to see what didn't work and what now works to see if there could be a fix in the addon, or if it's something I'm doing incorrectly on my end. Thanks for the help!

 vector<ofPtr<ofxHapPlayer> > player;  // this line of code was included in .h file

 ofDirectory videoDir;
    videoDir.listDir("movies");


    for (int i = 0; i < (int)videoDir.size(); i++){

        ofPtr<ofxHapPlayer> v (new ofxHapPlayer());
        v->loadMovie(videoDir.getPath(i));

        while(!v->isLoaded()) {

            ofSleepMillis(10);
            ofLog() << "sleeping" << endl;

        }

        player.push_back(v);
        player[i]->play();

    }
@bangnoise
Copy link
Owner

Yep, for now you will have to use new (and delete them if you ever remove them from the vector).

ofxHapPlayer lacks copy or assignment operators to manage its associated resources when you copy or assign it (it gets copied when you put it into the vector).

I'll leave this ticket open and fix that at some point... sorry if you wasted time on it.

bangnoise added a commit that referenced this issue Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants