2104 |
void Loader::thread_function_sub(gig::progress_t& progress) |
void Loader::thread_function_sub(gig::progress_t& progress) |
2105 |
{ |
{ |
2106 |
RIFF::File* riff = new RIFF::File(filename); |
RIFF::File* riff = new RIFF::File(filename); |
2107 |
|
// due to the multi-threaded scenario use separate file I/O handles for |
2108 |
|
// each thread to avoid file I/O concurrency issues with .gig file |
2109 |
|
riff->SetIOPerThread(true); |
2110 |
|
|
2111 |
gig = new gig::File(riff); |
gig = new gig::File(riff); |
2112 |
|
|
2113 |
gig->GetInstrument(0, &progress); |
gig->GetInstrument(0, &progress); |
2221 |
__clear(); |
__clear(); |
2222 |
// create a new .gig file (virtually yet) |
// create a new .gig file (virtually yet) |
2223 |
gig::File* pFile = new gig::File; |
gig::File* pFile = new gig::File; |
2224 |
|
// due to the multi-threaded scenario use separate file I/O handles for |
2225 |
|
// each thread to avoid file I/O concurrency issues with .gig file |
2226 |
|
RIFF::File* pRIFF = pFile->GetRiffFile(); |
2227 |
|
pRIFF->SetIOPerThread(true); |
2228 |
// already add one new instrument by default |
// already add one new instrument by default |
2229 |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
gig::Instrument* pInstrument = pFile->AddInstrument(); |
2230 |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
pInstrument->pInfo->Name = gig_from_utf8(_("Unnamed Instrument")); |
3542 |
file = 0; |
file = 0; |
3543 |
set_file_is_shared(isSharedInstrument); |
set_file_is_shared(isSharedInstrument); |
3544 |
|
|
3545 |
|
// assuming libgig's file-IO-per-thread feature is enabled: by default |
3546 |
|
// the file stream is closed for individual threads (except of the original |
3547 |
|
// thread having opened the gig file), so open the file stream for this |
3548 |
|
// thread for being able to read the .gig file |
3549 |
|
// (see libgig's RIFF::File::SetIOPerThread() for details) |
3550 |
|
::RIFF::File* riff = gig->GetRiffFile(); |
3551 |
|
if (!riff->IsNew() && riff->GetMode() == ::RIFF::stream_mode_closed) { |
3552 |
|
try { |
3553 |
|
riff->SetMode(::RIFF::stream_mode_read); |
3554 |
|
} catch (...) { |
3555 |
|
printf("Failed opening '%s' in read mode\n", |
3556 |
|
riff->GetFileName().c_str()); |
3557 |
|
} |
3558 |
|
} |
3559 |
|
|
3560 |
this->filename = |
this->filename = |
3561 |
(filename && strlen(filename) > 0) ? |
(filename && strlen(filename) > 0) ? |
3562 |
filename : (!gig->GetFileName().empty()) ? |
filename : (!gig->GetFileName().empty()) ? |