Пример #1
0
// a: 0..6
void Player_SID::releaseChannel(int channel) {
	stopChannel(channel);
	if (channel >= 4) {
		return;
	}
	if (channel < 3) {
		SIDReg23Stuff = SIDReg23;
		clearSIDWaveform(channel);
	}
	func_4F45(channel);
	if (channel >= 3) {
		return;
	}
	if ((SIDReg23 != SIDReg23Stuff) &&
	    (SIDReg23 & 0x07) == 0)
	{
		if (filterUsed) {
			func_4F45(3);
			stopChannel(3);
		}
	}

	stopChannel(channel + 4);
}
Пример #2
0
void Player_MOD::do_mix(int16 *data, uint len) {
	int i;
	int dpos = 0;
	uint dlen = 0;
	memset(data, 0, 2 * len * sizeof(int16));
	while (len) {
		if (_playproc) {
			dlen = _mixamt - _mixpos;
			if (!_mixpos)
				_playproc(_playparam);
			if (dlen <= len) {
				_mixpos = 0;
				len -= dlen;
			} else {
				_mixpos = len;
				dlen = len;
				len = 0;
			}
		} else {
			dlen = len;
			len = 0;
		}
		for (i = 0; i < MOD_MAXCHANS; i++) {
			if (_channels[i].id) {
				Audio::st_volume_t vol_l = (127 - _channels[i].pan) * _channels[i].vol / 127;
				Audio::st_volume_t vol_r = (127 + _channels[i].pan) * _channels[i].vol / 127;
				for (uint j = 0; j < dlen; j++) {
					// simple linear resample, unbuffered
					int delta = (uint32)(_channels[i].freq * 0x10000) / _sampleRate;
					uint16 cfrac = ~_channels[i].ctr & 0xFFFF;
					if (_channels[i].ctr + delta < 0x10000)
						cfrac = delta;
					_channels[i].ctr += delta;
					int32 cpos = _channels[i].pos * cfrac / 0x10000;
					while (_channels[i].ctr >= 0x10000) {
						if (_channels[i].input->readBuffer(&_channels[i].pos, 1) != 1) {	// out of data
							stopChannel(_channels[i].id);
							goto skipchan;	// exit 2 loops at once
						}
						_channels[i].ctr -= 0x10000;
						if (_channels[i].ctr > 0x10000)
							cpos += _channels[i].pos;
						else
							cpos += (int32)(_channels[i].pos * (_channels[i].ctr & 0xFFFF)) / 0x10000;
					}
					int16 pos = 0;
					// if too many samples play in a row, the calculation below will overflow and clip
					// so try and split it up into pieces it can manage comfortably
					while (cpos < -0x8000) {
						pos -= 0x80000000 / delta;
						cpos += 0x8000;
					}
					while (cpos > 0x7FFF) {
						pos += 0x7FFF0000 / delta;
						cpos -= 0x7FFF;
					}
					pos += cpos * 0x10000 / delta;
					Audio::clampedAdd(data[(dpos + j) * 2 + 0], pos * vol_l / Audio::Mixer::kMaxMixerVolume);
					Audio::clampedAdd(data[(dpos + j) * 2 + 1], pos * vol_r / Audio::Mixer::kMaxMixerVolume);
				}
			}
skipchan:		;	// channel ran out of data
		}
		dpos += dlen;
	}
}
Пример #3
0
void SshScpSend::sshDataReceived()
{
    static char mem[1024];
    static size_t nread;
    static char *ptr;
    int rc;

    switch(_currentState)
    {
    case ScpPrepare:
        if(!sshChannel) {
            sshChannel = libssh2_scp_send(sshClient->session(), qPrintable(_destination), _fileinfo.st_mode & 0777, (unsigned long)_fileinfo.st_size);

            if ((!sshChannel) && (libssh2_session_last_errno(sshClient->session()) != LIBSSH2_ERROR_EAGAIN)) {
                char *errmsg;
                int errlen;
                libssh2_session_last_error(sshClient->session(), &errmsg, &errlen, 0);
                qDebug() << "ERROR : Unable to open a session: " << errmsg;
            }
            if(sshChannel) {
#ifdef DEBUG_SCPSEND
                qDebug() << "DEBUG : ScpPrepare Send Accepted";
#endif
                _currentState = ScpCopy;
            }
        }
        break;

    case ScpCopy:
        do {
            nread = fread(mem, 1, sizeof(mem), _local);
            if (nread <= 0) {
                /* end of file */
                _currentState = ScpEof;
                sshDataReceived();
                break;
            }
            ptr = mem;
            do {
                /* write the same data over and over, until error or completion */
                rc = libssh2_channel_write(sshChannel, ptr, nread);

                if (rc < 0) {
                    qDebug() << "ERROR : Copy error " << rc;
                    _currentState = ScpError;
                    break;
                }
                else {
                    /* rc indicates how many bytes were written this time */
                    ptr += rc;
                    nread -= rc;
                }
            } while (nread);
        } while(1);
        break;
    case ScpEof:
#ifdef DEBUG_SCPSEND
        qDebug() << "DEBUG : Sending EOF";
#endif
        libssh2_channel_send_eof(sshChannel);
        _currentState = ScpClose;
        break;

    case ScpClose:
#ifdef DEBUG_SCPSEND
        qDebug() << "DEBUG : Waiting EOF";
#endif
        libssh2_channel_wait_eof(sshChannel);
        _state = true;
        _currentState = ScpEnd;
        stopChannel();
        emit transfertTerminate();
        break;

    case ScpError:
        qDebug() << "ERROR : SCP ERROR";
        _state = false;
        stopChannel();
        emit transfertTerminate();
        break;

    case ScpEnd:
#ifdef DEBUG_SCPSEND
        qDebug() << "DEBUG : Wait end";
#endif
        break;
    }
}
Пример #4
0
void Sound::stopTankIdle()
{
    stopChannel(m_tankIdleChannel);
}