Fixed a crash
This commit is contained in:
		
							parent
							
								
									d60eecd9a9
								
							
						
					
					
						commit
						07958ec36b
					
				| @ -25,15 +25,15 @@ void AudioOutputSource::do_fade_out(size_t pop_count) { | ||||
|         if(auto fn = this->on_underflow; fn && fn(0)) | ||||
|             goto _test_for_fade; | ||||
| 
 | ||||
|         auto wptr = (float*) this->buffer.write_ptr(); | ||||
|         auto total_samples = std::min(samples_left, this->fadeout_sample_length); | ||||
|         if(total_samples == 0) return; //TODO Test against min_buffered_samples
 | ||||
| 
 | ||||
|         for(size_t index{0}; index < total_samples; index++) { | ||||
|         auto wptr = (float*) this->buffer.calculate_backward_write_ptr(total_samples * this->channel_count * sizeof(float)); | ||||
|         for(size_t index{0}; index <= total_samples; index++) { | ||||
|             const auto offset = (float) ((float) index / (float) total_samples); | ||||
|             const auto volume = log10f(1 - offset) / -2.71828182845904f; | ||||
|             const auto volume = log10f(offset) / -2.71828182845904f; | ||||
|             for(int channel{0}; channel < this->channel_count; channel++) | ||||
|                 *wptr-- *= volume; | ||||
|                 *wptr++ *= volume; | ||||
|         } | ||||
| 
 | ||||
|         log_trace(category::audio, tr("Will buffer due to fade out ({} | {})"), total_samples, *(float*) this->buffer.write_ptr()); | ||||
|  | ||||
| @ -243,6 +243,12 @@ namespace tc { | ||||
|         return this->memory.address + (offset % this->memory.capacity); | ||||
|     } | ||||
| 
 | ||||
|     char* ring_buffer::calculate_backward_write_ptr(size_t bytes) { | ||||
|         bytes %= this->memory.capacity; | ||||
|         auto offset{this->write_offset.load() + this->memory.capacity - bytes}; | ||||
|         return this->memory.address + (offset % this->memory.capacity); | ||||
|     } | ||||
| 
 | ||||
|     const void* ring_buffer::read_ptr() const { | ||||
|         auto offset{this->read_offset.load()}; | ||||
|         return this->memory.address + (offset % this->memory.capacity); | ||||
|  | ||||
| @ -18,7 +18,8 @@ namespace tc { | ||||
|             char* write_ptr(); | ||||
|             void advance_write_ptr(size_t /* count */); | ||||
| 
 | ||||
|             char* calculate_advanced_write_ptr(size_t /* count */bytes); | ||||
|             char* calculate_advanced_write_ptr(size_t /* count */); | ||||
|             char* calculate_backward_write_ptr(size_t /* count */); | ||||
| 
 | ||||
|             /* do not read more than the capacity! */ | ||||
|             [[nodiscard]] const void* read_ptr() const; | ||||
|  | ||||
| @ -118,7 +118,7 @@ int main(int argc, char** argv) { | ||||
|     { | ||||
|         auto admin = is_administrator(); | ||||
|         logger::info("App executed as admin: %s", admin ? "yes" : "no"); | ||||
|         if(!admin && false) { | ||||
|         if(!admin) { | ||||
|             logger::info("Requesting administrator rights"); | ||||
|             if(!request_administrator(argc, argv)) { | ||||
|                 execute_callback_fail_exit("permissions", "failed to get administrator permissions"); | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "TeaClient", | ||||
|   "version": "1.4.6", | ||||
|   "version": "1.4.6-1", | ||||
|   "description": "", | ||||
|   "main": "main.js", | ||||
|   "scripts": { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user