@@ -267,7 +267,6 @@ static ngx_int_t
267
267
ngx_rtmp_gop_cache_alloc_cache (ngx_rtmp_session_t * s )
268
268
{
269
269
ngx_rtmp_codec_ctx_t * codec_ctx ;
270
- ngx_rtmp_core_srv_conf_t * cscf ;
271
270
ngx_rtmp_gop_cache_ctx_t * ctx ;
272
271
ngx_rtmp_gop_cache_t * cache , * * iter ;
273
272
@@ -281,11 +280,6 @@ ngx_rtmp_gop_cache_alloc_cache(ngx_rtmp_session_t *s)
281
280
return NGX_ERROR ;
282
281
}
283
282
284
- cscf = ngx_rtmp_get_module_srv_conf (s , ngx_rtmp_core_module );
285
- if (cscf == NULL ) {
286
- return NGX_ERROR ;
287
- }
288
-
289
283
if (ctx -> free_cache ) {
290
284
cache = ctx -> free_cache ;
291
285
ctx -> free_cache = cache -> next ;
@@ -378,19 +372,18 @@ ngx_rtmp_gop_cache_cleanup(ngx_rtmp_session_t *s)
378
372
ngx_rtmp_gop_cache_free_cache (s , cache );
379
373
}
380
374
381
- if (ctx -> pool ) {
382
- ngx_destroy_pool (ctx -> pool );
383
- ctx -> pool = NULL ;
384
- }
385
-
386
375
ctx -> video_seq_header = NULL ;
387
376
ctx -> audio_seq_header = NULL ;
388
377
ctx -> meta = NULL ;
389
378
390
- ctx -> cache_tail = ctx -> cache_head = NULL ;
379
+ if (ctx -> cache_head ) {
380
+ ctx -> cache_head -> next = ctx -> free_cache ;
381
+ ctx -> free_cache = ctx -> cache_head ;
382
+ ctx -> cache_head = NULL ;
383
+ }
384
+
385
+ ctx -> cache_tail = NULL ;
391
386
ctx -> gop_cache_count = 0 ;
392
- ctx -> free_cache = NULL ;
393
- ctx -> free_frame = NULL ;
394
387
ctx -> video_frame_in_all = 0 ;
395
388
ctx -> audio_frame_in_all = 0 ;
396
389
}
@@ -720,10 +713,10 @@ ngx_rtmp_gop_cache_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
720
713
ngx_rtmp_live_ctx_t * ctx ;
721
714
ngx_rtmp_gop_cache_app_conf_t * gacf ;
722
715
ngx_rtmp_live_app_conf_t * lacf ;
716
+ ngx_rtmp_live_chunk_stream_t * cs ;
723
717
ngx_rtmp_header_t ch ;
724
718
ngx_uint_t prio ;
725
719
ngx_uint_t csidx ;
726
- ngx_rtmp_live_chunk_stream_t * cs ;
727
720
728
721
gacf = ngx_rtmp_get_module_app_conf (s , ngx_rtmp_gop_cache_module );
729
722
if (gacf == NULL || !gacf -> gop_cache ) {
@@ -851,6 +844,7 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
851
844
ngx_rtmp_close_stream_t * v )
852
845
{
853
846
ngx_rtmp_live_ctx_t * ctx ;
847
+ ngx_rtmp_gop_cache_ctx_t * gctx ;
854
848
ngx_rtmp_live_app_conf_t * lacf ;
855
849
ngx_rtmp_gop_cache_app_conf_t * gacf ;
856
850
@@ -873,6 +867,16 @@ ngx_rtmp_gop_cache_close_stream(ngx_rtmp_session_t *s,
873
867
goto next ;
874
868
}
875
869
870
+ gctx = ngx_rtmp_get_module_ctx (s , ngx_rtmp_gop_cache_module );
871
+ if (gctx == NULL ) {
872
+ goto next ;
873
+ }
874
+
875
+ if (gctx -> pool ) {
876
+ ngx_destroy_pool (gctx -> pool );
877
+ gctx -> pool = NULL ;
878
+ }
879
+
876
880
ngx_rtmp_gop_cache_cleanup (s );
877
881
878
882
next :
0 commit comments