mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	memblock: don't try to reuse PA_MEMBLOCK_APPENDED memblocks since they usually are much bigger than we want them
This commit is contained in:
		
							parent
							
								
									f84d755d6a
								
							
						
					
					
						commit
						9697c5dc18
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -368,6 +368,7 @@ pa_memblock *pa_memblock_new_fixed(pa_mempool *p, void *d, size_t length, pa_boo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
 | 
					    if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
 | 
				
			||||||
        b = pa_xnew(pa_memblock, 1);
 | 
					        b = pa_xnew(pa_memblock, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PA_REFCNT_INIT(b);
 | 
					    PA_REFCNT_INIT(b);
 | 
				
			||||||
    b->pool = p;
 | 
					    b->pool = p;
 | 
				
			||||||
    b->type = PA_MEMBLOCK_FIXED;
 | 
					    b->type = PA_MEMBLOCK_FIXED;
 | 
				
			||||||
| 
						 | 
					@ -394,6 +395,7 @@ pa_memblock *pa_memblock_new_user(pa_mempool *p, void *d, size_t length, pa_free
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
 | 
					    if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
 | 
				
			||||||
        b = pa_xnew(pa_memblock, 1);
 | 
					        b = pa_xnew(pa_memblock, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PA_REFCNT_INIT(b);
 | 
					    PA_REFCNT_INIT(b);
 | 
				
			||||||
    b->pool = p;
 | 
					    b->pool = p;
 | 
				
			||||||
    b->type = PA_MEMBLOCK_USER;
 | 
					    b->type = PA_MEMBLOCK_USER;
 | 
				
			||||||
| 
						 | 
					@ -506,12 +508,18 @@ static void memblock_free(pa_memblock *b) {
 | 
				
			||||||
            /* Fall through */
 | 
					            /* Fall through */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case PA_MEMBLOCK_FIXED:
 | 
					        case PA_MEMBLOCK_FIXED:
 | 
				
			||||||
        case PA_MEMBLOCK_APPENDED :
 | 
					 | 
				
			||||||
            if (pa_flist_push(PA_STATIC_FLIST_GET(unused_memblocks), b) < 0)
 | 
					            if (pa_flist_push(PA_STATIC_FLIST_GET(unused_memblocks), b) < 0)
 | 
				
			||||||
                pa_xfree(b);
 | 
					                pa_xfree(b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case PA_MEMBLOCK_APPENDED:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /* We could attached it unused_memblocks, but that would
 | 
				
			||||||
 | 
					             * probably waste some considerable memory */
 | 
				
			||||||
 | 
					            pa_xfree(b);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case PA_MEMBLOCK_IMPORTED: {
 | 
					        case PA_MEMBLOCK_IMPORTED: {
 | 
				
			||||||
            pa_memimport_segment *segment;
 | 
					            pa_memimport_segment *segment;
 | 
				
			||||||
            pa_memimport *import;
 | 
					            pa_memimport *import;
 | 
				
			||||||
| 
						 | 
					@ -546,8 +554,7 @@ static void memblock_free(pa_memblock *b) {
 | 
				
			||||||
            struct mempool_slot *slot;
 | 
					            struct mempool_slot *slot;
 | 
				
			||||||
            pa_bool_t call_free;
 | 
					            pa_bool_t call_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            slot = mempool_slot_by_ptr(b->pool, pa_atomic_ptr_load(&b->data));
 | 
					            pa_assert_se(slot = mempool_slot_by_ptr(b->pool, pa_atomic_ptr_load(&b->data)));
 | 
				
			||||||
            pa_assert(slot);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            call_free = b->type == PA_MEMBLOCK_POOL_EXTERNAL;
 | 
					            call_free = b->type == PA_MEMBLOCK_POOL_EXTERNAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue