@@ -369,6 +369,14 @@ static int period_to_usecs(struct snd_pcm_runtime *runtime)
369
369
return usecs ;
370
370
}
371
371
372
+ static void snd_pcm_set_state (struct snd_pcm_substream * substream , int state )
373
+ {
374
+ snd_pcm_stream_lock_irq (substream );
375
+ if (substream -> runtime -> status -> state != SNDRV_PCM_STATE_DISCONNECTED )
376
+ substream -> runtime -> status -> state = state ;
377
+ snd_pcm_stream_unlock_irq (substream );
378
+ }
379
+
372
380
static int snd_pcm_hw_params (struct snd_pcm_substream * substream ,
373
381
struct snd_pcm_hw_params * params )
374
382
{
@@ -452,7 +460,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
452
460
runtime -> boundary *= 2 ;
453
461
454
462
snd_pcm_timer_resolution_change (substream );
455
- runtime -> status -> state = SNDRV_PCM_STATE_SETUP ;
463
+ snd_pcm_set_state ( substream , SNDRV_PCM_STATE_SETUP ) ;
456
464
457
465
if (pm_qos_request_active (& substream -> latency_pm_qos_req ))
458
466
pm_qos_remove_request (& substream -> latency_pm_qos_req );
@@ -464,7 +472,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
464
472
/* hardware might be unusable from this time,
465
473
so we force application to retry to set
466
474
the correct hardware parameter settings */
467
- runtime -> status -> state = SNDRV_PCM_STATE_OPEN ;
475
+ snd_pcm_set_state ( substream , SNDRV_PCM_STATE_OPEN ) ;
468
476
if (substream -> ops -> hw_free != NULL )
469
477
substream -> ops -> hw_free (substream );
470
478
return err ;
@@ -512,7 +520,7 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
512
520
return - EBADFD ;
513
521
if (substream -> ops -> hw_free )
514
522
result = substream -> ops -> hw_free (substream );
515
- runtime -> status -> state = SNDRV_PCM_STATE_OPEN ;
523
+ snd_pcm_set_state ( substream , SNDRV_PCM_STATE_OPEN ) ;
516
524
pm_qos_remove_request (& substream -> latency_pm_qos_req );
517
525
return result ;
518
526
}
@@ -1320,7 +1328,7 @@ static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state)
1320
1328
{
1321
1329
struct snd_pcm_runtime * runtime = substream -> runtime ;
1322
1330
runtime -> control -> appl_ptr = runtime -> status -> hw_ptr ;
1323
- runtime -> status -> state = SNDRV_PCM_STATE_PREPARED ;
1331
+ snd_pcm_set_state ( substream , SNDRV_PCM_STATE_PREPARED ) ;
1324
1332
}
1325
1333
1326
1334
static struct action_ops snd_pcm_action_prepare = {
0 commit comments