| 29 | } |
| 30 | |
| 31 | DWORD WINAPI __stdcall WA2InputModule::PlayThread(WA2InputModule *_t) |
| 32 | { |
| 33 | xgm::INT16 *packet_buf; |
| 34 | int packet_size = 576 * _t->nch * _t->bps / 8; // �o�b�t�@�T�C�Y2048bytes�Œ� |
| 35 | int blank_time = 10; // �ŏ��̐��p�P�b�g�͖����ɂ���(DirectX plugin��) |
| 36 | int wsize; // dsp������̏������݃T�C�Y |
| 37 | int sample_size = _t->nch * _t->bps / 8; |
| 38 | int packet_samples = packet_size / sample_size; |
| 39 | |
| 40 | packet_buf = new xgm::INT16[packet_size]; // dsp�̂��߂�2�{�̗̈���m�� |
| 41 | memset(packet_buf,0,packet_size*sizeof(xgm::INT16)); |
| 42 | |
| 43 | while(!_t->killPlayThread) |
| 44 | { |
| 45 | if(_t->reset_flag) |
| 46 | { |
| 47 | _t->pl->Reset(); |
| 48 | _t->decode_pos = 0; |
| 49 | _t->reset_flag = false; |
| 50 | } |
| 51 | |
| 52 | if(_t->pl->IsStopped()) |
| 53 | { |
| 54 | if(_t->pMod->outMod->IsPlaying()) |
| 55 | continue; |
| 56 | else |
| 57 | { |
| 58 | _t->PreAutoStop(); |
| 59 | break; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if(_t->seek_flag) |
| 64 | { |
| 65 | int to_skip = _t->seek_pos - _t->decode_pos; |
| 66 | |
| 67 | if(to_skip > packet_samples) |
| 68 | { |
| 69 | _t->decode_pos += _t->pl->Skip(packet_samples); |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | _t->decode_pos += _t->pl->Skip(to_skip); |
| 74 | _t->pMod->outMod->Flush(POS2MS(_t->decode_pos,_t->rate)); |
| 75 | _t->seek_flag = false; |
| 76 | } |
| 77 | continue; |
| 78 | } |
| 79 | |
| 80 | if(_t->pMod->outMod->CanWrite() >= (packet_size<<(_t->pMod->dsp_isactive()?1:0))) |
| 81 | { |
| 82 | int write_pos = _t->decode_pos; |
| 83 | if(blank_time) |
| 84 | { |
| 85 | memset(packet_buf,0,packet_size*sizeof(xgm::INT16)); |
| 86 | blank_time--; |
| 87 | } |
| 88 | else |