Add null check when destroy sound manager vstream
[platform/core/multimedia/libmm-radio.git] / src / mm_radio_priv_hal.c
index 3d1f8d6..ac1cd92 100644 (file)
@@ -196,6 +196,8 @@ int _mmradio_create_radio(mm_radio_t *radio)
        radio->freq = DEFAULT_FREQ;
        memset(&radio->region_setting, 0, sizeof(MMRadioRegion_t));
        radio->local_volume = 1.0;
+       radio->vstream = NULL;
+       radio->stream_info = NULL;
 
        /* create msg queue for msg thread */
        radio->msg_queue = g_async_queue_new();
@@ -329,8 +331,14 @@ int _mmradio_unrealize(mm_radio_t *radio)
        _mmradio_stop(radio);
 
 #ifdef TIZEN_FEATURE_SOUND_VSTREAM
-       sound_manager_destroy_virtual_stream(radio->vstream);
-       sound_manager_destroy_stream_information(radio->stream_info);
+       if (radio->vstream) {
+               sound_manager_destroy_virtual_stream(radio->vstream);
+               radio->vstream = NULL;
+       }
+       if (radio->stream_info) {
+               sound_manager_destroy_stream_information(radio->stream_info);
+               radio->stream_info = NULL;
+       }
 #endif
 
        MMRADIO_SET_STATE(radio, MM_RADIO_STATE_NULL);